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 does TCP transport protocol control traffic?

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

TCP flow control, to put it simply, is to make the transmission rate of the data transmission side not too fast, so that the data receiver can receive it in time. Using the sliding window mechanism, it is very convenient to realize the flow control of the data transmission side on the TCP connection. The window unit of TCP is bytes, not a message segment. The sending window of the data transmission end cannot exceed the value of the receiving window given by the receiver. The mechanism of flow control is to control the packet loss rate. The main purpose is to let the data transmission end understand the current receiving capacity of the data receiver and flexibly adjust the transmission rate. The flow control mechanism diagram is shown in the following figure:

Slide the window:

TCP uses a variable size sliding window for flow control, and the size of the window is in bytes.

The data transfer window is agreed upon by both parties when the connection is established. However, in the process of communication, the data receiver can dynamically adjust the transmission window size of the other party at any time according to its own resources. An example of a sliding window is shown in the following figure:

The reason for the introduction of sliding window:

We can think of windows as buffers (but some windows are different from buffers).

Without these "windows", each piece of data sent by TCP must wait for the data receiver to confirm before sending the next piece of data, so the efficiency of TCP transmission is too low.

The solution is to continue to send data while the sender is waiting for confirmation, assuming that sending to the X segment is an acknowledgment from the data receiver, which is acceptable if X is within an acceptable range. This is why windows (buffers) are introduced.

Slide the window:

A, data receiver window X

The size of the receiver buffer. The receiver puts the window value in the window field in the header of the TCP message and transmits it to the sender.

B, congestion window Y

Sender buffer size

C, data transfer window Z

Upper limit of send window = Min [X, Y]

When X < Y, ① is the maximum value that the receiving capacity of the receiver limits the data transmission window.

When Y < X, ② is the maximum value of the network congestion limit data transmission window.

Sliding window example:

The data transmission side has sent 400 bytes of data, but only received an acknowledgement of the first 200 bytes of data, while the window size remains the same. It can also send 300 bytes.

The data transmission side received the confirmation of the first 400 bytes of data from the other side, but the other side informed the data transmission side that the window must be reduced to 400 bytes. Now the data transmission side can send up to 400 bytes of data.

Knowledge points to be mastered in the sliding window:

A. the data receiver puts the acceptable buffer size into the "window size" field in the header of TCP, and notifies the data transmission side through ACK.

B. the larger the window size field, the higher the throughput of the network.

C, window size refers to the maximum value at which you can continue to send data without waiting for a confirmation reply, that is, you can send data continuously without a reply from the data receiver.

D. In order to maintain the sliding window, the operating system kernel needs to open up a send buffer to record what data has not been answered at present, and only by confirming the answered data can it be deleted from the buffer. PS: if the send buffer is too large, there will be space overhead.

E. once the data receiver finds that its buffer is almost full, it will set the window size to a smaller value to notify the data transmitter. After receiving this value, the data transmitter will slow down its sending speed.

F. If the data receiver finds that its buffer is full, it will set the window size to 0. At this time, the data transmitter no longer transmits data, but needs to send a window probe data segment on a regular basis. Make the data receiver tell the data transmitter the size of the window.

PS: at the beginning of TCP, there is a 16 window field, which is used to store window size information.

Selection of sending time of TCP message Segment

1. TCP maintains a variable, which is equal to the maximum message segment length MSS. As long as the data stored in the cache reaches MSS bytes, it will be assembled into a TCP message segment and sent.

2. The sender's application program specifies that the message segment is required to be sent, that is, the push operation supported by TCP.

3. When a timer of the sender expires, the existing cache data will be loaded into the message segment and sent out.

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