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

The transmission process of TCP data

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

Share

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

Figure 1:TCP socket data exchange process

The figure above shows the process in which host A passes 200 bytes to host B twice (two packets). First, host A sends 100 bytes of data through a packet, and the Seq number of the packet is set to 1200. To confirm this, host B sends an ACK packet to host An and sets the Ack number to 1301.

In order to ensure the accurate arrival of the data, the destination machine must immediately return the ACK packet after receiving the data packet (including SYN packet, FIN packet, popular packet, etc.). This transmission can just confirm the success of data transmission.

At this point, the Ack number is 1301 instead of 1201, because the increment of the Ack number is the number of bytes of data transmitted. Assuming that each Ack number does not add the number of bytes transferred, it is possible to confirm the transmission of the packet, but it is impossible to understand that a part of the 100-byte accurate transmission is still missing, for example, only 80 bytes. Therefore, confirm the Ack number according to the following formula:

Ack number = Seq number + number of bytes passed + 1

In contrast to the three-way handshake agreement, the original purpose of adding 1 is to inform the other party of the Seq number to be passed.

The following is an analysis of packet loss during the transmission process, as shown in the following figure:

Figure 2:TCP socket data transmission process failure

The figure above shows that 100byte data was passed to host B through a Seq 1301 packet, but something went wrong at both ends and host B did not receive it. After a period of time, Host A still did not receive an ACK confirmation about Seq 1301, so the quiz retransmitted the data.

In order to complete the retransmission of the data packet, the TCP socket starts the quasi-timer every time it sends the packet. If the ACK packet returned by the destination machine is not received within a certain period of time, the timer expires and the packet will be retransmitted.

The figure above shows the situation of packet loss, there will also be ACK packet loss, and it will also be retransmitted. Retransmission timeout (RTO, Retransmission Time Out)

If this value is too large, it will lead to unnecessary waiting, and too small will lead to unnecessary retransmission. In fact, it is best to collect RTT time, but it is also subject to the change of collection interval and transient delay, so in practice, adaptive static algorithms (such as Jacobson algorithm and Karn algorithm, etc.) are definitely out of time.

The round-trip time (RTT,Round-Trip Time) shows the total experienced delay from the sending end to the receiving end receiving the ACK acknowledgement packet from the receiving end (the receiving end acknowledges immediately after receiving the data). Number of retransmissions

The number of retransmissions of TCP packets varies depending on piecemeal settings. In some bits and pieces, a packet will only be retransmitted 3 times. If the ACK acknowledgement of the packet is not received after 3 retransmissions, it will not be retransmitted. However, some highly requested business bits and pieces will retransmit lost packets from time to time to ensure the normal interaction of business data as much as possible.

The initial requirement is that the sender will not empty the input buffer until it receives the ACK acknowledgement packet from the other side.

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

Network Security

Wechat

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

12
Report