Why do I need to shake hands three times, two or four times? ?

Why not twice? Because the computer and the server only do two handshake, it is only one-way communication, and TCP is a full-duplex communication that must ensure reliability.

1. If the second handshake fails, the C end will repeatedly send the SYN message, waiting for the opposite end to send the confirmation message, and the S end will save all the resources of the tcp connection. A
large number of this situation will cause the S resources to be exhausted.
2. If the second handshake is successful, S will repeat the SYN+ACK message if it does not receive the ACK.
3. After the second handshake, the two parties think that the connection is established successfully, and they can start communication. If the connection is not really established at this time, the
S end starts to send messages, which will cause network congestion.

Why not four times? Four times is actually possible in principle, that is, the second ACK and SYN are sent in two times. It is completely feasible in theory, but TCP is based on the premise of saving network resources.

        • If the computer continues to send SYN packets after the three-way handshake, what will happen to the server? ? ? This was futile at the time. After the third completion, the link has been established, and no matter how many times it is later, it is in vain.

        What happens if TCP establishes a connection at the same time? ? ?

At this time, only one full-duplex TCP link will be established, not two.

        • There is no difference between the two parties, both ends assume two roles at the same time, the client and the server.

Guess you like

Origin blog.csdn.net/feng8403000/article/details/114956165