TCP server in the TCP/IP protocol, the TCP protocol provides a reliable connection service, using three handshake to establish a connection.
First handshake: When a connection is established, the client sends a SYN packet (SYN=J) to the server and enters the Syn_send state, waiting for the server to confirm;
Second handshake: The server receives the SYN packet, it must confirm the customer's SYN (ACK=J+1), and also send itself a SYN packet (syn=k), that is, the Syn+ack packet, when the server enters the SYN_RECV state;
Third handshake: The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, the packet is sent, the client and the server enter the established state, and the handshake is completed three times.
After three handshakes, the client and server begin transmitting data, and in the above process there are some important concepts:
Not connected queue: In the three-time handshake protocol, the server maintains an disconnected queue, which is listed as a SYN package (SYN=J) for each client, which indicates that the server has received a SYN packet and has issued a confirmation to the customer that it is waiting for the customer's confirmation package. The connections identified by these entries are in the SYN_RECV state of the server, and when the server receives the customer's confirmation package, the entry is deleted and the server enters the established state.
Backlog parameter: Represents the maximum number of seats that are not connected to a queue.
Syn-ack the number of times the server sends the Syn-ack package, if not received the customer confirmation package, the server for the first retransmission, waiting for a period of time still not received the customer confirmation package, the second retransmission, if the retransmission times than the system specified maximum retransmission times, the system will remove the connection information from the semi-connection queue. Note that the time to wait for each retransmission is not necessarily the same.
Half-Connection survival time: Refers to the maximum time that the entry of a semi-connected queue survives, that is, the maximum time that the service receives a SYN packet to confirm that the message is invalid, which is the maximum waiting time sum of all retransmission request packets. Sometimes we also call the half-connection survival time timeout time, syn_recv survival time.
Understanding of a TCP connection's disconnected queue