TCP Congestion Control Mechanisms

TCP Congestion Control Mechanisms

Description: TCP congestion control is one of the core mechanisms of the TCP protocol, designed to prevent network congestion collapse due to excessive data traffic. It dynamically adjusts the sender's data transmission rate to match the network's current carrying capacity. Congestion control is not based on the receiver's processing capability (that's flow control), but rather on the perceived load of intermediate network nodes (e.g., routers).

Solution Process/Knowledge Explanation:

  1. Core Idea and Basic Concepts

    • Goal: To maximize the utilization of network bandwidth while avoiding network congestion (router buffer overflow leading to massive packet loss).
    • Key Variable: The sender maintains a crucial variable—the Congestion Window (cwnd). It represents the maximum amount of data the sender can transmit at once without causing network congestion. The sender's actual effective window size = min(congestion window, receiver's advertised receive window).
    • How to Detect Congestion: TCP considers packet loss (timeout retransmission or receipt of duplicate ACKs) as the primary signal of network congestion.
  2. Four Core Algorithms of Congestion Control
    TCP congestion control consists of four interrelated algorithms: Slow Start, Congestion Avoidance, Fast Retransmit, and Fast Recovery.

    • a) Slow Start

      • Trigger: When a new TCP connection is established, or after a timeout retransmission (indicating severe congestion), the connection enters the slow start phase.
      • Process:
        1. Initially, the congestion window cwnd is set to a small value (e.g., 1 MSS, Maximum Segment Size).
        2. For each acknowledgment (ACK) received for new data, the sender increases cwnd by one MSS. That is, cwnd = cwnd + 1 (per ACK).
        3. This results in exponential growth: send 1 segment -> receive 1 ACK -> cwnd=2 (can send 2 segments) -> receive 2 ACKs -> cwnd=4 (can send 4 segments) -> ...
      • Purpose: To quickly inject data into the network, probe the available bandwidth, and avoid flooding an unknown network with large amounts of data from the start.
      • End Condition: When cwnd grows to a preset Slow Start Threshold (ssthresh), it transitions to the "Congestion Avoidance" phase. Alternatively, if packet loss is detected, the slow start process ends.
    • b) Congestion Avoidance

      • Trigger: When cwnd >= ssthresh, the connection enters the congestion avoidance phase.
      • Process:
        1. The sender switches to Additive Increase. That is, for each ACK received for new data, cwnd increases by 1/cwnd MSS. A more intuitive way to think about it is: cwnd increases by 1 MSS per Round-Trip Time (RTT) (because approximately cwnd ACKs are received within one RTT).
        2. For example, if the current cwnd=10, then after one RTT and successful transmission of 10 segments (receiving 10 ACKs), cwnd would increase to 11.
      • Purpose: To shift from aggressive exponential probing to a conservative, linear climb, cautiously approaching the network's capacity limit to avoid triggering congestion.
    • c) Fast Retransmit

      • Background: Traditional timeout retransmission wait time (RTO) is long and inefficient. Fast Retransmit is a mechanism for early retransmission.
      • Process:
        1. If the sender receives 3 consecutive duplicate ACKs (i.e., the 4th identical ACK), it has strong reason to believe a specific segment is lost (rather than severe network-wide congestion), because subsequent segments have arrived at the receiver, triggering duplicate ACKs.
        2. The sender does not wait for the retransmission timer to expire but immediately retransmits the segment expected by the receiver.
      • Purpose: To recover from the loss of a single packet more quickly, improving transmission efficiency.
    • d) Fast Recovery

      • Trigger: Usually entered after triggering Fast Retransmit. It complements Fast Retransmit.
      • Process:
        1. Receiving 3 duplicate ACKs indicates that although packet loss occurred, data is still flowing (otherwise duplicate ACKs wouldn't be received). Therefore, network congestion might not be as severe as a timeout scenario.
        2. The sender sets ssthresh to half the current cwnd (but not less than 2): ssthresh = cwnd / 2.
        3. Then, instead of resetting cwnd to 1 (a key difference from a timeout retransmission), the sender sets cwnd to the new ssthresh value (or ssthresh + 3, accounting for the 3 packets that have left the network). Afterwards, it enters the Congestion Avoidance phase with linear growth.
      • Purpose: To avoid plummeting the window to 1 (returning to Slow Start) in cases of non-severe congestion, which would cause a drastic drop in throughput. This allows the connection to recover to a reasonable data rate more quickly.
  3. Complete Flow Example
    Assume a communication session:

    1. Connection established, initial cwnd = 1, ssthresh = 16.
    2. Slow Start: cwnd grows exponentially (1, 2, 4, 8, 16).
    3. When cwnd reaches 16 (equal to ssthresh), enter Congestion Avoidance, cwnd begins linear growth (17, 18, ...).
    4. When cwnd=24, a segment is lost, triggering Fast Retransmit (receiving 3 duplicate ACKs).
    5. Immediately enter Fast Recovery:
      • Set new slow start threshold: ssthresh = 24 / 2 = 12.
      • Set congestion window to the new threshold: cwnd = 12.
      • Retransmit the lost segment.
    6. After successful retransmission, a new ACK is received, confirming the lost segment. The connection exits the Fast Recovery phase and directly enters the Congestion Avoidance phase, with cwnd starting linear growth from 12.
    7. If a timeout retransmission occurs during communication (a more severe congestion signal than receiving 3 duplicate ACKs), TCP takes stricter measures:
      • ssthresh = cwnd / 2.
      • cwnd is reset to 1.
      • Then restart the Slow Start process.

Through the coordinated operation of these four algorithms, TCP can intelligently adapt to changing network conditions, striking a balance between efficient bandwidth utilization and network stability.