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. |
>>: 5G will explode with AI, cloud, and edge computing
This article is reproduced from the WeChat public...
From March 14th to 15th, the "Huawei China P...
Recently, the Ministry of Industry and Informatio...
By Kara Mullaley, Corning Inc. [[394802]] 5G netw...
LOCVPS is a long-established Chinese hosting comp...
RAKsmart launched the "New Year's Big Di...
Yecao Cloud has brought this year's Double 11...
In the rapidly evolving world of telecommunicatio...
For many people, communication is a very general ...
DediPath launched a Father's Day Sale. Becaus...
Some common sense mistakes can reduce the data ce...
As the core of the new generation of communicatio...
[[388835]] The COVID-19 pandemic has driven deman...
[[439196]] This article is reprinted from the WeC...
I have talked about service mesh, API gateway and...