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

What is the status of TCP's three-way handshake and four waves

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares with you is about the three-way handshake and four waves of TCP and their status. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Without saying much, let's take a look at it.

Three-way handshake:

TCP's three-way handshake process:

The C side sends the SYN (SYN=1) flag and sends a SEQ number (SEQ is a random number) to indicate that you want to connect with the S side. (C: SYN_SENT S: LISTEN)

After receiving the packet containing (SYN=1), the S side indicates that it wants to accept the packet, then replies with an ACK number (ACK=SEQ+1), and then replies with a SYN=1,ACK=1 packet as well. (C:SYN_SENT, S:SYN_REVD)

The C side replies with an ACK number packet (ACK=SEQ+1), ACK= 1, and then the connection is established, and the rest of the work is to transmit. (C: ESTABLISHED S:ESTABLISHED)

Question:

There was a misunderstanding in this place that SYN and SYN number were the same thing. As a result, they were confused and did not really understand this three-way handshake. As a result, it was too late to repent. Add a few more questions

You won't take it for granted.

In the figure, you can see the first. First, 10.0.0.61 sends a SYN packet to 10.1.3.32, and the flag bit of SYN is 1, and a Seq number=2856901853 is sent.

The second article: 10.1.3.32 received the request, returned a SYN+ACK packet, and confirmation and connection package, Ack number=2856901853+1, and then randomly sent a random number of Seq=3836060639.

Third: 10.0.0.61 received the request, returned an ACK packet, ACK number=3836060639+1, and then sent a Seq= random number.

Through the above three, a stateful connection is established, followed by a process of data transmission.

The essence of the three-way handshake is that the two sides reliably exchange a Seq number, through which the order of subsequent transmissions is confirmed.

Wave four times:

The process of waving four times, the first important reminder is a sentence in Baidu encyclopedia, and TCP is full-duplex, so both sides need to close the connection.

Suppose A has already passed all the data.

A sends a packet with the FIN flag bit 1, indicating that it has completed the transmission.

B sends an ACK to indicate that he already knows and closes the connection from A-> B.

After a while, B also sent all the data, and then B sent a packet marked FIN 1, and then passed it to A.

A looks like a FIN sign, indicating that a disconnection signal from B has been received, and then A sends an ACK=1 packet to formally disconnect all connections.

Take a closer look at this description and find that there are several problems. first of all, A sent a FIN=1 packet, which only means that A has passed all the messages that should be transmitted. As for whether B receives it or not, A does not care whether it is received or not, or whether it knows.

So, obviously, things should not be like the above, like the three-way handshake, there must be the intervention of Seq number.

The correct process is as follows:

A sends a packet of FIN=1 and has a Seq number. (A:FIN_WAIT_1 B:ESTABLISHED)

After receiving it, B returns a packet of ACK=1 and a packet of Ack number= Seq number+1. (a: FIN_WAIT_1 B:CLOSE_WAIT)

After the transmission is completed, like another connection, send a FIN=1 packet and carry a Seq number at the same time. (A:FIN_WAIT_2 B:LAST_ACK)

When A receives it, it returns a packet of ACK=1 and sends the packet of Ack number = seq number + 1 to A. (A:TIME_WAIT B:CLOSED)

These are the three-way handshake and four waves of TCP and their status. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Servers

Wechat

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

12
Report