HTTP protocol request process analysis

A, DNS name resolution

The user enters a URL (Uniform Resource Locator) or click on a link here to access www.baidu.com example.

1, www.baidu.com user input in the browser, the browser looks into its own cache, if there Baidu cache direct lookup. If there is no

2, find the hosts file host, hosts file if there is direct access to the host. If there is no

3, find the machine of choice for local DNS cache server, if Baidu's address exists, returned to the host, and then access Baidu through the host server. If there

4, the local DNS server cache to find. (Root domain), there is no specific address root domain, a .com domain will return

5, a local DNS look .com domain, returns baidu.com

6, the local DNS cache server will look for baidu.com resolution server, the IP address www.baidu.com returned to the local DNS cache server.

7, the local DNS cache server will first record the IP address of the next Baidu, and then returned to the host.

8, the host upon receiving the IP address returned directly to find Baidu's servers.

Second, the connection

1, the host will generate a random port (1000--65635) and server port 80 to establish a connection (three-way handshake)

  • At first the client and the server is turned off
  • The client sends a request to a server connected to the packet, the synchronization bit SYN = 1, the sequence number seq = x, expected sequence number x + 1. At this time, the client is in sync state has been sent.
  • After the server receives a request from a client to confirm receipt of the request ACK = 1, the sequence number acknowledgment ACK = x + 1. The client sends a request to the server connection request SYN = 1, the sequence number seq = y, expected sequence number y + 1, in this case the server has received the sync state.
  • Client receives a request from the server, confirming receipt of ACK = 1, the sequence number acknowledgment ACK = y + 1, the sequence number seq = x + 1, then the client and the server in a connected state

 

HTTP GET 2, after confirming the connection, the client transmits a header request to the server main body

3 HTTP response, the server transmits a head, the body to the client, the text

4, the client after receiving the content displayed to the user through a browser

Third, disconnect

1, when the client closes the browser page (fourth wave)

  • At the beginning of the client and server in a connected state
  • (1) The client sends a request to release the connection to the server segment FIN = 1, the sequence number seq = w, expected sequence number w + 1, then the client is in a state waiting for the termination.
  • (2) the client receives a request from a client to confirm receipt of ACK = 1, to confirm the sequence number seq = w + 1, while the server is closed waiting state, the server responding to the client, then the client is terminated wait 2 state
  • (3) When a client requests the server to respond to all began after disconnection request, the server sends a request to the client to terminate segment FIN = 1, the sequence number seq = v, expected sequence number v + 1, at this time Finally, the server waits for a client to receive.
  • (4) the server receives a request from the client to confirm receipt of ACK = 1, the sequence number acknowledgment ACK = v + 1, then the client is in the wait state, to respond to the client server, receive a response will be closed immediately, the client need to wait up to two segments of life before closing time
  • The client and the server is turned off, disconnecting the connection.

 

Guess you like

Origin www.cnblogs.com/tanxiaojuncom/p/11492616.html