Interesting explanation of TCP three-way handshake and four-way wave

Interesting explanation of TCP three-way handshake and four-way wave

Students who have studied computer networks know that TCP is one of the most complicated protocols in computer network courses. There is a three-way handshake before communication, and a four-way handshake before disconnection. In the middle, there are flow control, congestion control, sliding windows, etc. Beginners will feel dizzy. In this short article, we will first introduce the three-way handshake and the four-way handshake, and then introduce other contents of the TCP protocol in the following articles.

[[267885]]

Basic communication process

We all know that TCP is a connection-oriented protocol that ensures that data arrives at the receiver without loss, duplication, or disorder. The TCP communication process is roughly as shown in the figure below.

The above figure shows the entire TCP communication process. First, a three-way handshake is performed to establish a connection (the green part). After the connection is established, normal communication can be carried out (the blue part). After the communication is completed, four handshakes are required to disconnect the connection (the red part).

Three-way handshake

The three-way handshake can be understood as follows:

The TCP client is a boy, and the TCP server is a girl. If a boy wants to pursue a girl, he must first establish a romantic relationship. This requires a process of establishing a romantic relationship.

Boy: Can we fall in love? (The client requests the server to establish a connection)

Girl: You want to chase me? Think it over! (The server asks the client to confirm the connection)

Boy: Yes, you are the girl of my dreams! (Client confirms the connection)

The three-way handshake establishes the "love relationship" between the TCP server and the client. Why is a three-way handshake necessary? Can't two handshakes do the job? From a communication perspective, two handshakes are enough for the client, but not for the server, because after two handshakes, the server only knows that the channel between the client and the server is open, but the channel between the server and the client is unknown, so both parties need to receive a confirmation message from the client to confirm that the message channels of both parties are ok.

Three-way handshake

Four waves

It takes four waves to break the connection, which can be understood as the boy and girl breaking up and need to go through the following discussion.

Boy: We are not suitable for each other, let's break up. (The client has no data to transmit)

Girl: What? We broke up so soon. It can't be over so soon. I have to settle the accounts with you! (There is still data that has not been sent on the server)

The girl is settling accounts with the boy... (unsent data continues to be transmitted)

Girl: Okay, let’s break up! (Data transmission completed on the server side)

Boy: OK, we will still be friends from now on... (Wait for Time_Wait to expire, and become single again)

One thing to note here is that after the client receives the message sent by the server that the data transmission is completed (the third wave), it cannot close the connection immediately (return to being single and looking for a new love), but must wait for 2MSL time to close, because during this period the server may not be able to receive the first wave. If it is not received, the server will resend the third wave message. At this time, if the client is closed, it will not be able to respond to the fourth wave message, making the four-wave process unable to complete.

<<:  The seven-layer network model and TCP, UDP, what happens in an HTTP request

>>:  Ruijie Networks launches Cloud Office 4.0 solution as an alternative to commercial PCs

Recommend

5G optical fiber product network construction requirements

5G is a leading technology in the new generation ...

Out-of-the-box infrastructure connectivity options

When it comes to connecting network devices acros...

Why are IDC companies keen on entering the broadband access network field?

Since the country launched the pilot business of ...

How to Choose the Right Data Cabling for Your Business

Are you building a new office? Is your current of...

Don’t let “number portability” confuse consumers

According to media reports, the Ministry of Indus...

Eleven years of Tianyi Exhibition: How China Telecom plans for the future of 5G

In June this year, the Ministry of Industry and I...

An overview of 10 common HTTP status codes

Overview The HTTP status code is a 3-digit code u...

Experts gather between REST, gRPC and GraphQL!

REST, GraphQL, and gRPC are the three most common...

An article on learning Go network library Gnet analysis

Introduction We analyzed the Go native network mo...

Three years after the license was issued, has 5G commercialization been successful?

​It coincides with the third anniversary of China...