Why does TCP need a three-way handshake for connection establishment instead of two handshake?

Standard answer: Prevent the invalid connection request message segment from being received by the server, resulting in errors.

What does that mean?

 First, we need to explain what the invalid connection request is: If the connection request sent by the client to the server is lost, the client will send the connection request again after waiting for the response timeout. At this time, the last connection request is the "invalid" connection request!

If only two handshake are needed to establish a connection, there is not much change for the client. But it still needs to get the response from the server before entering the ESTABLISHED state. The server enters the ESTABLISHED state after receiving the connection request. At this time, if the network is congested and the connection request sent by the client is late to the server, the client will time out and resend the request. If the server receives and confirms the response correctly, the two parties will start communication and release the connection after the communication ends. At this point, if the invalid connection request arrives at the server, since there are only two handshakes, the server will enter the ESTABLISHED state after receiving the request, waiting to send data or actively send data. But at this time, the client has already entered the CLOSED state, and the server will wait forever, which wastes server connection resources!

I don’t know if the explanation is clear, welcome to discuss!

Guess you like

Origin blog.csdn.net/AntdonYu/article/details/103765553