What is congestion control in TCP?

Overview

Networked systems commonly face congestion due to traffic overload on links beyond their capacity. It results in the loss of packets in the network and, as a result, can severely damage the user's experience. Although it is impossible to avoid congestion entirely, mechanisms exist to manage it proactively to prevent damaging effects. 

A congestion control protocol must have the following features: 

  • It must avoid congestion. As the primary goal of the algorithm, it must ensure that the bandwidth allocated to a particular host does not exceed the bandwidth of the bottleneck link, which could be responsible for congestion on the network. 
  • It should be fair. The network resources should be allocated fairly between different hosts.
  • The scheme must be efficient. As such, it should ensure that the sender efficiently utilizes the bandwidth. It should neither be too below the bandwidth of the bottleneck link nor should it entirely consume it. 

Before we can understand how TCP implements congestion control, there are two ideas that need clear understanding:

1. Congestion window size

It is known to the sender, and the bytes sent should never exceed the congestion window size. If the sending rate goes over the congestion window size, packets are lost and the sender is forced to retransmit them.

2. Receiver window size

It is an advertisement from the receiver about the number of bytes it can receive before dropping packets. As such, the sender must always send bytes less than or equal to the receiver window size to avoid retransmission of packets.

Hence, the formula for sender window size is:

Sender window size = Min(Congestion window size, Receiver window size)

Congestion control in TCP

TCP's mechanism for congestion control comprises three phases:

1. Slow start

The sender starts by setting the congestion window equal to the maximum segment size (1 MSS) and increases its size by one after each acknowledgment is received. The size of the congestion window hence increases exponentially in this phase, as shown below:

The congestion window size increases exponentially during slow start phase

The illustration shows how the congestion window size changes exponentially during the slow-start phase. The slow-start phase continues until the slow-start threshold is reached, which is defined as follows:

  • Slow-start threshold (SSH) = (Receiver window size / Maximum Segment Size) / 2

2. Congestion avoidance phase

This phase starts once the slow-start threshold is reached and continues until the congestion window becomes equal to the receiver window size. In this phase, the sender cautiously increases the congestion window by one after receiving an acknowledgment to avoid congestion. The congestion window increments as follows:

  • Congestion window size = congestion window size + 1

The progression of transmission up until now is shown below:

The transmission of data until receiver window size is reached

3. Congestion Detection Phase

In the last phase, TCP promptly acts when a packet loss is detected. Its reaction is based on the two types of congestion given below: 

1. Mild congestion

Congestion is mild when the sender receives three duplicate acknowledgments (ACKs) from the receiver. It indicates the possibility of only a few packets being dropped, which can be perceived through the ACKs received. When this happens, the following happens:

  • The congestion window is halved.
  • The slow-start threshold is set to this new congestion window value. 
  • The sender continues with the congestion avoidance phase until a loss is detected. 
2. Severe congestion

This case occurs when the retransmission timer of the sender expires. When this happens, the following happens:

  • The slow-start phase is started until the first loss is detected after the retransmission timer expires.
  • The sender sets the slow-start threshold to halve the current congestion window size.
  • Congestion window size is reduced to 1 MSS by the sender.
  • The slow-start phase is resumed until the congestion window reaches the slow-start threshold.
  • The sender then goes into the congestion avoidance phase until a loss of segments is detected through the retransmission timer expiry.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved