Review of TCP/IP Congestion Control

What Is Congestion

We all know that resources in computer networks are limited. When the demand for resources in the network exceeds the available portion within a certain period of time, it leads to a decrease in network performance, which is known as congestion.

In simpler terms, it means that too many data packets are sent, and the devices in the network cannot process them, resulting in a decline in network performance.

Why TCP Needs Congestion Control

Routers in the network have a queue for processing data packets. When the number of packets received by the router exceeds its processing capability, it leads to an excessively long queue. At this point, the router will unconditionally drop any newly received packets.

This causes the upper-layer TCP protocol to assume that the packets have been lost in the network, prompting it to retransmit those packets. However, the router will drop these retransmitted packets as well, and this cycle continues, leading to a dramatic decline in network performance and potentially causing network paralysis.

Therefore, TCP needs to control the number of packets sent to avoid a decline in network performance.

Difference Between Congestion Control and Flow Control

According to the answer in the book:

  • Congestion control is to prevent too much data from being injected into the network, thereby preventing routers or links in the network from becoming overloaded. The premise of congestion control is that the network can handle the current load. Congestion control is a global process that involves all hosts, all routers, and all factors related to reducing network transmission performance.

  • Flow control often refers to the control of communication volume between two points; it is an end-to-end issue. Flow control aims to suppress the sending rate of the sender so that the receiver can keep up with the reception.

Methods of Congestion Control

Slow Start

  • Congestion Window

The congestion window (cwnd) refers to a window maintained by the sender that dynamically changes based on network conditions. Generally, the sender will set its sending window equal to the size of the congestion window.

If flow control is considered, the sending window may also be smaller than the size of the congestion window.

  • Transmission Round

A transmission round refers to the sender sending all the data within its sending window and receiving an acknowledgment for the last byte.

For example, A sends all the data in its sending window to B continuously, and after B receives this data, it sends an acknowledgment back to A. Once A receives this acknowledgment, one transmission round is considered complete.

  • Slow Start Algorithm

The main method in the slow start algorithm is to gradually increase the sending window from small to large.

So, how does it increase specifically?

Simply put, after each transmission round, the size of cwnd is doubled.

For example:

First, the sender sets cwnd=1 (for ease of understanding, here the number of segments is used as the unit of window size). After receiving the acknowledgment from the receiver (which is the next transmission round), it sets cwnd=2 and then sends out the data in the sending window. After receiving the acknowledgment from the receiver again, the sender sets cwnd=4 and sends the data in the sending window again. Then the process is repeated.

It should be clear here that in the slow start algorithm, the term slow does not refer to the slow growth of cwnd, but rather that this method of sending a small amount of data packets at a time is much slower compared to sending a large amount of data all at once.

Of course, the size of cwnd cannot continue to grow exponentially; otherwise, it will quickly reach a level that causes network paralysis.

Therefore, after a certain period or condition, we must switch to the congestion avoidance algorithm to send data.

Congestion Avoidance

  • Slow Start Threshold (ssthresh)

As mentioned above, we cannot allow the cwnd in the slow start algorithm to grow arbitrarily, so we introduce a threshold called slow start threshold (ssthresh) to control the growth of cwnd.

The specific function is as follows:

  • cwnd < ssthresh, use the slow start algorithm

  • cwnd = ssthresh, either the slow start algorithm or the congestion avoidance algorithm can be used

  • cwnd > ssthresh, use the congestion avoidance algorithm

Another issue is how to set this ssthresh?

In TCP/IP, it is stipulated that whether in the slow start phase or the congestion avoidance phase, as long as congestion is detected in the network (acknowledgments are not received on time), ssthresh must be set to half the current sending window size (not less than 2).

  • Congestion Avoidance Process

The congestion avoidance algorithm also gradually increases the size of cwnd, but it uses linear growth instead of the exponential growth of the slow start algorithm.

Specifically, after each transmission round, the size of cwnd is increased by one (additive increase). If network congestion is detected, the size of ssthresh is reset using the method above (multiplicative decrease), and the slow start algorithm is executed again starting from cwnd=1.

As shown in the image below:

Review of TCP/IP Congestion Control

(Image source: Internet)

Fast Retransmit

As reviewed earlier, the principle of reliable transmission in TCP is the timeout retransmission mechanism. When combined with the above slow start and congestion avoidance, after sending the data, a timer is set. If the acknowledgment from the receiver is not received within the timer duration, the multiplicative decrease process is executed, and the slow start algorithm is restarted.

Fast retransmit allows the sender to initiate the multiplicative decrease process after receiving three duplicate acknowledgments in succession without having to wait for the retransmission timer to expire.

This requires that the receiver immediately sends a duplicate acknowledgment for any out-of-order segment it has not received, so that the sender can know about the lost segments early, rather than waiting to send data to carry the acknowledgment.

Fast Recovery

The fast recovery algorithm is an algorithm used in conjunction with the fast retransmit algorithm.

After using the fast recovery algorithm, when network congestion is detected and the multiplicative decrease process is executed, instead of setting cwnd=1 and restarting the slow start algorithm, cwnd is set to the ssthresh after the multiplicative decrease and the congestion avoidance algorithm is executed.

This is because the sender can assume that the network is likely not congested if it has received three duplicate acknowledgments in succession.

The congestion avoidance process using both fast retransmit and fast recovery is shown below:

Review of TCP/IP Congestion Control

(Image source: Internet)

What Is the Size of TCP’s Sending Window?

The upper limit of the sending window = Min{rwnd, cwnd}

rwnd: receiver’s window cwnd: sender’s congestion window

Read the original text Congestion control is a technical task.

Review of TCP/IP Congestion Control

Leave a Comment