Why does TCP need a three-way handshake?

Why does TCP need a three-way handshake?

[[285361]]

First, let's briefly introduce the TCP three-way handshake. In the TCP/IP protocol, the TCP protocol provides reliable connection services and uses a three-way handshake to establish a connection.

First handshake: When establishing a connection, 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: When the server receives the SYN packet, it must confirm the client's SYN (ack=j+1) and send a SYN packet (syn=k) at the same time, that is, a SYN+ACK packet. At this time, the server enters the SYN_RECV state;

The third handshake: The client receives the SYN+ACK packet from the server and sends a confirmation packet ACK (ack=k+1) to the server. After this packet is sent, the client and server enter the ESTABLISHED state, completing the three-way handshake.

Through this three-way handshake, the client and the server establish a reliable duplex connection and start transmitting data.

The main purpose of the three-way handshake is to ensure that the connection is duplex, and reliability is more guaranteed by the retransmission mechanism. But why is it necessary to have a three-way handshake to ensure a duplex connection? Isn't it enough to have one handshake? Isn't it enough to have two handshakes? Let's take an example of two people communicating in language in real life to simulate the three-way handshake.

First conversation:

My wife asked A to go out to buy soy sauce. On the way, they met a friend B. A asked: "Brother, have you eaten?"

As a result, Person B was listening to music with headphones, and he didn't hear anything and didn't respond. Person A thought: There is no sound when I talk to you, so I won't talk to you anymore, communication failed. This means that if Person B can't receive the information sent by Person A, communication must have failed.

If B hears what A said, then the first conversation is successful and the second conversation will proceed.

Second conversation:

B heard what A said, but he is a foreigner and does not speak Chinese well. He does not know what A means and does not know how to respond, so he just randomly responds with a sentence he has learned in Chinese: I went to the toilet. A burst out laughing immediately after hearing this. "I went to the toilet to eat"? People with different ideals cannot work together. Stay away from you. Communication failed. This means that communication failed when B cannot make a correct response.

If B heard what A said, gave the correct response, and also asked in return: I have eaten, how about you? then the second handshake was successful.

The first two conversations proved that B could understand what A said and could give a correct response. Then the third conversation was conducted.

The third dialogue:

A just greeted B, and suddenly his wife called him, "You damned bastard, why did you take so long to come here? Wait till I get home and I'll deal with you." A is a henpecked husband, and he was so scared that he ran home without saying a word, leaving B alone. B thought: What kind of person is this? Well, I'll go home too. Communication failed. This means that communication failed when A was unable to respond.

If A also gives the correct answer: I ate it too, then the third conversation is successful, the two have established a smooth communication channel, and then they start a continuous chat.

The second and third conversations proved that Person A could understand what Person B said and could give a correct response. It can be seen that these three conversations are necessary for two people to have effective language communication.

Similarly, we can understand why TCP needs a three-way handshake:

In order to ensure that the server can receive the client's information and make a correct response, the first two (first and second) handshakes are performed.

In order to ensure that the client can receive the information from the server and make a correct response, the next two (second and third) handshakes are performed.

<<:  Is your cloud still manual? Five indispensable tools for cloud computing and infrastructure automation

>>:  5G will explode with AI, cloud, and edge computing

Blog    

Recommend

Five ways edge computing drives digital business

Every industry has created a new normal: if your ...

What does the arrival of 5G mean for the Internet of Things?

In today’s fast-paced, hyper-connected and tech-e...

How 5G deployment will impact enterprise network hardware and software

For most enterprises, IT teams will deploy fifth-...

What is 5G voice like now?

In the 5G era, real-time communication is still a...

Can the Internet of Things drive the deployment of IPv6?

IPv6 has features that IPv4 lacks, which makes it...

The momentum of large-scale commercial use of NB-IoT is unstoppable

The Internet of Things is the only way to the int...

How powerful is WiFi7? Three times faster than WiFi6, as fast as lightning

Now the latest wireless routers on the market bas...

New opportunities brought by 5G millimeter wave fixed wireless

The broadband industry’s new mission is to extend...