TCP's sliding window and congestion window

Source: Internet
Author: User
Tags ack

Recent traffic control and congestion control in TCP TCP, which collects some information on the Internet, is summarized here.


No matter how complex the protocol is, I want to be sure to implement the Protocol's fields first. For TCP, flow control is nothing more than the number and window size above the fuss.


So let's take a look at what the 16-bit window size really does.

The window is divided into sliding windows and congestion windows.

The sliding window is the size of the window used by the data side to tell the cache size at the receiving end of the sending side, so as to control the size of the sending data, so as to achieve the purpose of traffic control.

Then for the data is the sending end of the congestion window, congestion window does not represent the cache, congestion window refers to a source-side traffic in a RTT can send the maximum number of packets


The following content to network

Sliding window Sliding window protocol is a transport layer for the flow control of a measure, the receiver by the notification sender's own window size, so as to control the sender's transmission speed, so as to prevent the sender sent too fast and caused by their own drowned. In recognition of the ACK, the ACK is usually understood to be an acknowledgment given after receiving the data ack,ack contains two very important information: one is expected to receive the next byte ordinal n, which means that the receiver has received the first n-1 bytes of data, at this time if the receiving party receives the first n+ 1 bytes of data instead of nth bytes of data, the receiver does not send an ACK that is ordinal n+2.   For example, if the receiver receives 1-1024 bytes, it sends an ACK with a confirmation number of 1025, but then receives 2049-3072, which does not send an ACK with a confirmation number of 3072 and still sends a 1025 ACK. The second is the current window size m, so the sender can calculate how many bytes of data can be sent after receiving the ACK, and assuming that the current sender has been sent to Byte X, the number of bytes that can be sent is y=m-(x-n). This is the basic principle of sliding window control flow. The sliding window protocol is shown in the figure: in this figure, we label the bytes from 1 to 11. The window advertised by the receiver is called the proposed window, which overrides the 4th byte to the 9th byte area, indicating that the receiver has confirmed the data including the 3rd byte, and the notification window size is 6. We know that the window size corresponds to the confirmation number. The sender calculates its available window, which indicates how much data can be sent immediately. When the receiving party confirms the data, the sliding window moves to the right. The relative motion of the two edges of the window increases or decreases the size of the window. We use three terms to describe the movement of the left and right edges of the window: The window is closed close to the edge of the border. This behavior occurs when the data is sent and confirmed. When the right edge of the window is moved, more data is allowed to be sent, which we call window opening. This behavior occurs when the receiving process on the other end reads the confirmed data and releases the receive cache for T C p. When the right edge moves to the left, it is called a window contraction.

Second, congestion window

So far, in all the examples in this chapter, the sender has sent multiple segments of the packet to the network at the outset until the window size advertised by the receiver has been reached. This is possible when both the sender and receiver are on the same LAN. However, if there are multiple routers and slow links between the sender and the receiver, some problems may occur. Some intermediate routers must cache groupings and potentially deplete the cache, [Jacobson 1988] proves how this connection is severely reducing the throughput of the TCP connection. Now, TCP needs to support an algorithm called slow start (slow start). The algorithm works by observing that the rate at which the new packet enters the network should be the same as the rate at which the other end returns confirmation.

Slow start adds another window to the sender's TCP: The Congestion window (congestion windows), which is recorded as CWnd. When a TCP connection is established with the host of another network, the congestion window is initialized to 1 segments (that is, the packet size advertised at the other end). Each time an ACK is received, the Congestion window adds a segment of the message (CWnd in bytes, but the slow start is incremented in the packet size). The sender takes the congestion window with the minimum value in the notification window as the sending upper limit. The Congestion window is the traffic control used by the sender, and the advertisement window is the traffic control used by the receiver.

The sender begins by sending a segment of the message, and then waits for an ACK. When the ACK is received, the congestion window increases from 1 to 2, which means that two segments of the message can be sent. When the ACK of these two segments is received, the congestion window is increased to 4. This is an exponential increase in the relationship.



Congestion avoidance is the traffic control used by the sender, and the notification window is the traffic control performed by the receiver. The former is an estimate of the network congestion that the sender feels, while the latter is related to the cache size available to the receiver on the connection.

Congestion control: Prevents excessive data from being injected into the network, which can prevent routers or links in the network from overloading. Congestion control has to do with a premise: the network can withstand the existing network load. Congestion control is a global process that involves all hosts, routers, and all the factors that are associated with reducing network transmission performance.

There are two cases of congestion occurring with timeouts and receiving duplicate confirmations,

Timeout will enable slow start and avoid congestion algorithm


Duplicate confirmations can avoid long waits, enabling fast retransmission and fast recovery











Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.