Understand Why TCP needs three-way handshake (vernacular)

Source: Internet
Author: User


To understand why TCP requires a three-way handshake (vernacular), first of all, let's briefly introduce TCP three-way handshake www.2cto.com. In TCP/IP, TCP provides reliable connection services and uses three-way handshake to establish a connection. First handshake: when a connection is established, the client sends the syn Packet (syn = j) to the server and enters the SYN_SEND status. wait for confirmation from the server. Second handshake: the server receives the syn packet, you must confirm the customer's SYN (ack = j + 1) and send a SYN Packet (syn = k), that is, the SYN + ACK packet. At this time, the server enters the SYN_RECV status; the third handshake: the client receives the server's SYN + ACK package and sends the ACK (ack = k + 1) Confirmation package to the server. After the package is sent, the client and server enter the ESTABLISHED status, complete three handshakes. Through these three handshakes, the client establishes a reliable duplex connection with the server to start data transmission. The main purpose of the three-way handshake is to ensure that the connection is duplex, and the reliability is more guaranteed by the retransmission mechanism. But why do we have to perform three handshakes to ensure that the connection is duplex? Not twice? Let's take an example of two people communicating with each other in real life to simulate three handshakes. The first conversation: My wife asked Jia to go out for soy sauce and met a friend B halfway. Jia asked: Have you eaten, buddy? As a result, B listened to the song with his earphones. He did not hear the song and did not respond. A thought: Communication fails if he doesn't speak to you. It indicates that communication fails if Party B fails to accept the information transmitted by Party. If Party B hears what party A says, the first conversation is successful, and the second conversation follows. The second conversation: Party B heard what party A said, but he is a foreigner. He is not good at Chinese. He does not know what it means or how to answer it, so I casually answered a Chinese sentence: I went to the toilet. Jia immediately smiled and said, "Go to the toilet for dinner "? The road is different. Stay away from you and fail to communicate. It indicates that communication fails when B cannot make a correct response. If Party B has heard of Party A, he has made a correct response and asked: I have eaten, what about you? The second handshake is successful. The previous two conversations prove that Party B can understand what party A says and make a correct response. Next we will start the third dialogue. The third conversation: A and B said hello, and suddenly his wife shouted, "You are a dead ghost. How long have you been playing soy sauce? Let's see how I packed you up when I went home ", A is a strict wife and a strict manager. After hearing this, I was so scared that I ran home and left B alone. B thought to himself: Well, I have to go back, too. Communication failed. It indicates that communication fails when a cannot respond. If Jia also made the correct response: I did. The third conversation was successful, and the two had established a smooth communication channel. Then they began to continue chatting. The second and third conversations prove that Party A can understand what party B says and make a correct response. It can be seen that effective language communication between two people is necessary for the three conversations. Likewise, we can understand why TCP requires three handshakes: to ensure that the server can receive the client information and make the correct response, perform the first two operations (the first and second operations) to make sure that the client can receive information from the server and make a correct response, perform the next two (second and third) handshakes.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.