Computer network high-frequency interview questions (7) - TCP three-way handshake and four waves

[1]    tcp three-way handshake

(1) The client sends a request packet to tell the server that I want to communicate with you. The syn position in the data packet is 1. Assuming its serial number is x, the client state becomes SYN_SENT

(2) After the server receives the request packet, it also sends a request packet to tell the client that the connection can now be made. The syn position in the data packet is 1, and the serial number is assumed to be y (note that the client serial number and the server serial number are not Any relationship, they are generated by their own kernels according to certain rules) but the 32-bit response number of this response packet must be x+1 (x+1 is because the syn bit of the packet sent by the client is considered to occupy a data, So tell the next packet must start from x+1) After sending, the server enters the SYN_RCVD state

(3) The client sends a response packet, and the high-speed server can communicate. The packet response number is y+1, and the client program the ESTABLISHED state, that is, the transmission state is possible. After the server receives the response packet, it becomes ESTABLISHED

【2】    Send data

The client sends one byte of data, so the serial number is x+1, and the server sends a response packet with the response number x+2, telling the client to start sending from x+2 next time.

[3]    Tcp waved four times

(1) The client sends a data packet requesting disconnection, telling the server that the data has been transmitted, I want to disconnect, send a FIN packet, the serial number is x+2, and the client enters the FIN_WAIT_1 state

(2) The server sends a response packet, telling the server that I already know, you disconnect, the response number is x+3 The server enters the CLOSE_WAIT state, and the client transfers to the FIN_WAIT_2 state after receiving the response

(3) The server sends a disconnected data packet, telling the client that since the transmission has been completed, my side is ready to close, the serial number is y+1, and the LAST_ACK state is entered after sending

(4) The client sends a response packet to tell the server, OK, I already know that you are going to disconnect, the response number is y+2, and the client enters the TIME_WAIT state

The TIME_WAIT state is also known as the 2MSL state. MSL is the maximum packet survival time defined in the system. Any tcp packet whose survival time in the network exceeds this value will be discarded. The reason for waiting for MSL is to prevent retransmission after the last ACK is lost. If the ACK is lost, the server resends the FIN


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324927435&siteId=291194637