20200408-- computer network to enter the URL of a page shows what happens

Enter the URL
when you start typing a URL such as www.cnblogs.com tour is when you can go to search for relevant URL Recommend to your bookmarks or history in which

Browser to locate the IP address of the domain name

① initiated after a request, this tour will first resolve a name, it will be hard to see the local hosts file to see where there is no rule and the corresponding domain name, if any, direct use hosts file inside ip address.

② If there is no corresponding ip address can be found in the local hosts file, the browser will send a request to the local DNS DNS (domain name distribution system) server. The local DNS server usually your network access server provider, such as China Telecom, China Mobile.

③ query URL after you enter a DNS request reaches the local DNS server, the local DNS server first queries its cache record, this record if there is a cache, you can return the results directly, this process is recursive queries way. If not, the local DNS server should query the DNS root servers

④ root DNS server does not record the specific correspondence between domain names and IP addresses, but to tell the local DNS server, you can go to research into the domain server and domain server address given. This process is an iterative process

⑤ local DNS server continues to send a request to the server domain, in this case, the requested object is .com domain server. .com domain server after receiving the request, it will not return to direct correspondence between domain names and IP addresses, but to tell the local DNS server, server address resolution of your domain name

⑥ Finally, the local DNS server sends a request to resolve a domain name server, then you can receive a correspondence between domain names and IP addresses, not only to the local DNS server IP address back to the user's computer, but also to preserve the correspondence between the cache in order to prepare for the next query other users, you can return the results directly, speed up network access.
Here Insert Picture Description
TCP connection established
after the domain name to get the corresponding IP address, initiates a random port (1024 ~ 65535) to the WEB server program 80 requests the TCP port, the connection request to the core enters the TCP / IP protocol stack (for identifying the connection request packet solutions, the peel layer by layer), it is also possible to go through the firewall Netfilter (belonging to the kernel module) filter, eventually reaches WEB program, eventually established TCP / IP connection, the client TCP connection with the server is bound to say is "three-way handshake."

Here Insert Picture Description
The client sends a data packet with the SYN flag of the server, the server receives, return data with a SYN / ACK packet flag to show convey acknowledgment information, and finally return to the client with an ACK flag to pass packet, on behalf of the end of the handshake, the connection is successful.

Popularized after that:

Client: I'll tell you brother link

Server: Okay, agreed

Client: Go ahead

Http browser to initiate a request to the WEB server

After establishing a TCP connection, sends an HTTP request, the request is generally divided into three parts

The method of the request URI Protocol / version

Request header (Request Header)

Request body

The following is a complete request

Here Insert Picture Description
Server-side processing

The server after receiving a request from the web server (http server should be accurate to say) processes the request, such as Apache, Ngnix, IIS and so on. web server resolves a user request, to know what resources need to schedule file, and then process the user request and the corresponding parameters of the resource files, and call database information, and then return the result to the browser client via the web server.

Here Insert Picture Description

Close TCP connection

To avoid the server and client both resource consumption and loss, both when there is no request or response transfer, either party may initiate a shutdown request. 3-way handshake to create a TCP connection is similar to close the TCP connection requires 4-way handshake.

Here Insert Picture Description
The figure can be popularized:

Client: Buddy, I'm not here to pass data, we close links it

Server: good, I received, and I'm here to see if I still have to pass

Server: And I did not, close it

Client: Go ahead

Browser parses resources

Published 955 original articles · won praise 43 · views 80000 +

Guess you like

Origin blog.csdn.net/qq_36344771/article/details/105386176