Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the three-way handshake of TCP

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to understand the three-way handshake of TCP". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First of all, a brief introduction to the TCP three-way handshake.

In TCP/IP protocol, TCP protocol provides reliable connection service and uses three-way handshake to establish a connection.

First handshake: when establishing a connection, the client sends a syn packet (syn=j) to the server, enters the SYN_SEND state, and waits for the server to confirm

Second handshake: when the server receives the syn packet, it must confirm the customer's SYN (ack=j+1). At the same time, it also sends a SYN packet (syn=k), that is, the SYN+ACK packet, and the server enters the SYN_RECV state.

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

Through such a three-way handshake, the client and the server establish a reliable duplex connection and begin to transmit data.

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 is it necessary to do a three-way handshake to ensure that the connection is duplex, not once? Can't you do it twice? Let's give an example of language communication between two people in real life to simulate a three-way handshake.

First conversation:

Wife let A go out to play soy sauce, met a friend B on the way, An asked: dude, have you eaten yet?

As a result, B was listening to music with headphones, but he didn't hear it at all and didn't respond. Jia thought to himself: I didn't speak to you, I didn't talk to you, and I failed to communicate with you. It shows that if B cannot receive the message from A, the communication must be a failure.

If B hears what A said, then the first dialogue is successful, followed by the second dialogue.

Second dialogue:

B heard what A said, but he is a foreigner, Chinese is not good, do not know what A said do not know how to answer, so casually answered a learned Chinese: I went to the toilet. On hearing this, An immediately laughed and sprayed, "go to the toilet to eat"? Different ways do not conspire with each other, stay away from you, communication failure. Explain that B fails to communicate if it is unable to make a correct response.

If B heard A's words, made the correct response, and also asked: I have eaten, how about you? So the second handshake was successful.

Through the first two conversations, it is proved that B can understand what A says and can make a correct response. Let's move on to the third dialogue.

Third dialogue:

A just said hello to B when suddenly his wife called him, "you son of a bitch, you've been playing soy sauce for such a long time, and see how I can deal with you when I get home." An is a wife who is so strict that he runs home without saying a word and leaves B hanging by himself. B thought: who is this, ah, I also go home, communication failure. It shows that if An is unable to respond, the communication fails.

If An also made the correct response: I also ate. So with the success of the third dialogue, the two have established a smooth communication channel, and then they began to chat continuously.

Through the second and third conversations, it is proved that A can understand what B is saying and can make a correct response.

It can be seen that the process of these three dialogues is necessary for two people to communicate effectively.

In the same way, we can understand why TCP needs a three-way handshake:

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

Of course, there is a more popular one.

When you try the phone function when you buy a mobile phone:

The old phone calls the new one: Hello, do you hear me?

The new machine returns to the old one: yes, do you hear me?

Old machine: I heard it.

Verify the call function OK!

This is the end of the content of "how to understand the three-way handshake of TCP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report