A: Summary overview
TCP as a reliable transport layer protocol, its essence is a series of methods such as sliding window, congestion avoidance and so on to control traffic. The data transfer rate can be adjusted based on server processing speed and network conditions, but the whole process is transparent to the developer. This article will be from sliding window, congestion control two aspects of TCP flow control operations. This series of articles are based on master Zhang gold digging pamphlet reading summary, interested friends can buy, absolute value
Two: receiving window
The server’s ability to process data is limited and it cannot receive data without limit. In the three-way handshake, there is a word attribute to mark the size of the receive window. The three-way handshake tells the receiver that the receive window is only this large, and that unacknowledged data can only be transmitted so much
The screenshot below shows an example of a SYN packet with a three-way handshake. You can see that the red box represents the size of the receive window. There are three values in the red box, with specific meanings as follows:
Window size
: Receives the window size, only 16 bytes is not enough to represent the window value, introducing the zoom scaleCalculated window
: Indicates the receiving window size after scalingWindow scale
: Zoom ratio
Calculated window = Window size * Window scale
Copy the code
As for why the values displayed in the captured Wireshark are incorrect, this needs to be studied. It should be possible to debug, but the current screenshots do show calculated values
Three: sliding window
Given the limitations of the receiving window, natural data transmission can’t exceed this value. What about the concept of sliding Windows? It slides like a cursor, and its composition is shown below:
green
: Indicates the data sent successfully and confirmed by ACKyellow
: Sends data waiting for ACK confirmation successfully (occupies the size of the sliding window)purple
: Remaining size of the slide window Number of bytes that can be sent (available size of the slide window)gray
: Subsequent data encoding
The size of the receiving window is the maximum size of the sliding window, and the available size of the sliding window changes dynamically during data transmission. However, the sliding window design only considers the processing power of the processor, but does not consider the road patency problem!! The server can process 100 megabytes of data, but 99 megabytes of data are stuck in traffic. Another design of flow control, congestion avoidance, will be discussed later
Four: slow start
The slow start is a wild trial. The process is as follows: After the transport layer cuts the data packets into N segments that meet the transmission requirements, 10 segments of data will be transmitted first. If the NORMAL ACK continues, 20 segments of data will be transmitted. Each transmission can be understood as network transmission status detection. Once the transmission network communication is detected to be normal, the number of its transmission will be doubled. This limitation is called congestion window
Five: Slow start threshold
Slow start unlimited exponential growth? Think of a sheet of paper folded to the height of Mount Everest, and the exponential explosion is a terrifying operation. So, in order to avoid unlimited exponential growth slow start, congestion window there is a limit is the slow start threshold, when the congestion window size reaches the slow start threshold will be its exponential growth strategy is modified to linear growth: the meaning of the RTT is a request to the response of the complete process, which may include multiple data packets and confirmed
- Slow start: The congestion window is less than the slow start threshold and grows exponentially, doubling after each RTT
- Congestion avoidance: If the congestion window is larger than the slow start threshold, it increases linearly and increases by 1 after each RTT