当前位置:网站首页>Why does TCP protocol shake hands three times instead of two?

Why does TCP protocol shake hands three times instead of two?

2022-06-23 06:58:00 Shu Yang

       

Now suppose A And B In communication .
       

《 computer network 》 The textbook says so :

        If this happens now :A The first connection request message sent , But this connection request message has been stuck in the network for a long time , The delay is long until the connection is released B. This was originally a message that had long failed , but B I don't know ,B I mistakenly thought A Another connection request was made , So I happily went to A A confirmation message was replied , Agree to establish a connection .

        The problem arises , If we now use two handshakes , So the above situation ,B The connection has been established after the reply . and A It doesn't have to be the same B Establishing a connection , Of course, they will not pay attention to B Confirmation message sent , Not to mention B send data .B I don't know these ,B Think the connection has been established , Waiting in silence A Send data , This is a waste B Resources for .

        So a third handshake is necessary .

       
       

Other answers that are easy to understand :

        After the first handshake ,B got it —— I can receive A Message sent ( I can take it ).
        After the second handshake ,A got it —— I sent messages from the past B To receive , And I can also receive B Message sent ( I can send and receive ).
        After the third handshake ,B got it —— I sent it to A The news of A To receive ( I can send ).
        After three handshakes , Communication forms a closed loop , Both sides know that they can send and receive , It's ready to transfer data .

        If there is no third handshake ,B In fact, I don't know whether I can successfully send messages , because A I didn't reply to the message I sent , You may not be able to send messages successfully , So this third handshake is needed .

原网站

版权声明
本文为[Shu Yang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230556565556.html