Process overview
- Browser to find the corresponding IP address domain name;
- The browser establishes a socket connection with the server based on the IP address;
- Browser and server communication: Browser request, server processing request;
- The browser is disconnected from the server.
The following is a detailed resolution:
Find an IP address based on a domain name
Conceptual interpretation
- IP Address: IP protocol for each network on the Internet and each host assigned a logical address. An IP address is like a house number, and an IP address is used to determine a host location. The server nature is also a host, want to access a server, must first know its IP address;
- Domain name (DN): IP address consists of four digits, the middle with the point number connection, in the use of difficult memory and easy to input errors, so we are familiar with the combination of letters and numbers to replace the pure number of IP address, such as we will only remember Www.baidu.com (Baidu domain name) rather than 220.181.112.244 (one of Baidu's IP addresses);
- DNS: Each domain name corresponds to one or more IP addresses that provide the same service server, only if you know the server IP address to establish a connection, so you need to resolve the domain name to an IP address through DNS.
Know the above concept, probably know to get the server's house number, you need to first convert the domain name to IP address. The conversion process is as follows (take the IP address of the query www.baidu.com as an example, where 2, 3, 4 steps are performed without the query succeeding in the previous step):
Lookup process
1. The browser searches its own DNS cache (maintains a corresponding table of domain name and IP address);
2. Search the DNS cache in the operating system (maintain a corresponding table of domain name and IP address);
3. Search operating system Hosts file (in Windows environment, maintain a domain name and IP address of the corresponding table);
4. The operating system will send the domain name to ldns (local domain name server, if you are connected to the Internet in the school, then the LDNS server is in the school, if through the telecommunications access to the Internet, then Ldns server in your local telecommunications there.) Ldns query its own DNS cache (the general search success rate is around 80%), the search succeeds returns the result, the failure initiates an iterative DNS resolution request;
- The Ldns to the root name server (the root name servers, which have no specific information about each domain name, but stores the addresses of the top-level domain names servers responsible for each domain, such as COM, net, org, etc.), where the root name server returns the COM domain's The address of the top-level domain name server;
- The Ldns initiates a request to the top-level domain name server of the COM domain and returns the Baidu.com domain name server address;
- Ldns to the baidu.com domain name server to initiate the request, obtains the www.baidu.com the IP address;
5.LDNS to return the resulting IP address to the operating system, while also caching the IP address;
6. The operating system will return the IP address to the browser, but also its own IP address cache;
7. At this point, the browser has been the domain name corresponding to the IP address.
Supplementary notes
- Domain names and URLs are two concepts: a domain name is a server or group of servers that is used to determine the location of the server on the Internet; a URL is a Uniform Resource locator used to determine where a particular file is located, for example, zhihu.com is a known domain name, where a known server can be found. , Zhihu.com/people/compileyouth is the URL, can be based on this URL to locate my knowledge of the home page;
- IP address and domain name is not one by one corresponding relationship: You can provide the same service server IP set to the same domain name, but at the same time a domain name can only resolve an IP address, at the same time, an IP address can bind multiple domain names, the number of unlimited;
Establish a connection--three times handshake
When you know the IP address of the server, you are now connected to the server.
Generally speaking, the establishment of communication connection needs to go through the following three processes:
- The host sends a request to the server to establish a connection (hello, I want to know you);
- The server sends a signal agreeing to the connection upon request (good, nice to meet you);
- When the host receives the signal to the connection, it sends a confirmation signal to the server again (I am glad to know you), since then, the host and the server have both established a connection.
Supplementary notes
- TCP protocol: Three handshake process using the TCP protocol, which can guarantee the reliability of information transmission, three handshake process, if a party does not receive a confirmation signal, the protocol will require a resend signal.
Web page request and display
After the server has established a connection with the host, the following host communicates with the server. Web page request is a one-way request process, that is, a host to the server to request data, the server returned the corresponding data process.
1. The browser generates HTTP requests based on the URL content, including the location of the request file, the way the file is requested, and so on;
2. When the server receives the request, it determines how to obtain the corresponding HTML file according to the contents of the HTTP request;
3. The server will send the resulting HTML file to the browser;
4. When the browser has not fully received the HTML file, it began rendering, display Web pages;
5. In the execution of HTML code, as required, the browser will continue to request pictures, CSS, Javsscript and other documents, the process with the request HTML;
Disconnect--four times to wave
1. The host sends a disconnect request to the server (late, I should go);
2. The server receives the request to send the acknowledgement to receive the request the signal (to know);
3. The server sends a disconnect notification to the host (I should also go);
4. The host is disconnected after receiving the disconnect and feedback a confirmation signal (well, good), the server after receiving confirmation signal disconnect;
Supplementary notes
- Why the server does not immediately agree to disconnect when it receives a disconnect request: When the server is receiving a disconnected request, the data may still not be sent, all the servers will send a confirmation signal, and all the data will be sent out before agreeing to disconnect.
- After the fourth handshake, the host sends a confirmation signal and does not disconnect immediately. Instead, it waits for 2 message delivery cycles because: if the confirmation information for the fourth handshake is lost, the server will resend the disconnect signal for the third handshake, and the server finds that the time the packet lost and the resend disconnected arrives at the host is just 2 Message transmission cycles.
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!