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.
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
【51CTO.com Quick Translation】 Starting a new open...
Last month we shared the news that DogYun launche...
Basic concepts of lossless network First of all, ...
In 11 days, the world-renowned Beijing Winter Oly...
Introduction In the traditional historical stage,...
[Original article from 51CTO.com] On July 21 and ...
RAKsmart is offering VPS hosting at a super low p...
Aoyozhuji is also a long-established VPS hosting ...
The tribe shared information about Olu Cloud once...
Topic fuse: What is network slicing? This new con...
RackNerd has launched its 2021 New Year promotion...
LOCVPS is a long-established Chinese VPS service ...
Recently, the three major operators have released...
[51CTO.com original article] Recently, Huawei'...