一、The TCP Protocol
TCP is a protocol which belongs to the Transfer Layer of the four protocol layers. UDP is another protocol which belongs to the Transfer Layer too. But Tcp is differ from UDP as it’s reliable. So, what makes it so reliable? The answer is a 3-way handshake. It makes tcp reliable. You may wonder why it needs 3-way, not 2 or 4 or others? To answer this question, Let’s discuss it more in depth.
二、3-Way Handshake
To make TCP reliable, means that both server and client should know they can normally send and receive data to each other respectively. To achieve this goal, Let’s see these steps.(S: Server for short. C: Client for short)
1-way: C sends a sign[x] to S to tell S that I want to establish a connection with you, let me know if you can receive it.
2-way: (S already received a sign[x] ) S sends a sign[x+1] to C to tell C that I can receive your message correctly, Let me know if you can receive my message correctly too. So far, S can make sure it can receive the message from C, but it doesn’t know whether C can receive its message so that the 2-way handshake doesn’t work for this goal.
3-way: (C already received a sign[x+1]) C sends a sign[x+2] to S to tell S that I can receive your message correctly too. Till now, C knows that it can send the message to S and receive the message from S correctly.
When S receives the sign[x+2], it knows that it can send the message to C and receive the message from C correctly, and vice versa. So, it can establish a reliable connection now. Since 3-way can make sure this connection is reliable, you don’t need to confirm anything anymore. If you force a 4-way handshake, yes, it can work but it’s not efficient. A 3-way handshake is necessary and efficient for a reliable connection.
Let’s see a picture to help you understand these 3 ways.

本文深入解析了TCP协议的可靠性及其与UDP的区别,重点介绍了三次握手过程如何确保客户端与服务器之间的可靠连接,通过三个步骤详细说明了三次握手的必要性和效率。
3049

被折叠的 条评论
为什么被折叠?



