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:
-
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.
-
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:
- Initially, the congestion window
cwndis set to a small value (e.g., 1 MSS, Maximum Segment Size). - For each acknowledgment (ACK) received for new data, the sender increases
cwndby one MSS. That is,cwnd = cwnd + 1(per ACK). - 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) -> ...
- Initially, the congestion window
- 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
cwndgrows 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:
- The sender switches to Additive Increase. That is, for each ACK received for new data,
cwndincreases by 1/cwnd MSS. A more intuitive way to think about it is:cwndincreases by 1 MSS per Round-Trip Time (RTT) (because approximatelycwndACKs are received within one RTT). - For example, if the current
cwnd=10, then after one RTT and successful transmission of 10 segments (receiving 10 ACKs),cwndwould increase to 11.
- The sender switches to Additive Increase. That is, for each ACK received for new data,
- Purpose: To shift from aggressive exponential probing to a conservative, linear climb, cautiously approaching the network's capacity limit to avoid triggering congestion.
- Trigger: When
-
c) Fast Retransmit
- Background: Traditional timeout retransmission wait time (RTO) is long and inefficient. Fast Retransmit is a mechanism for early retransmission.
- Process:
- 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.
- 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:
- 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.
- The sender sets
ssthreshto half the currentcwnd(but not less than 2):ssthresh = cwnd / 2. - Then, instead of resetting
cwndto 1 (a key difference from a timeout retransmission), the sender setscwndto the newssthreshvalue (orssthresh + 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.
-
-
Complete Flow Example
Assume a communication session:- Connection established, initial
cwnd = 1,ssthresh = 16. - Slow Start:
cwndgrows exponentially (1, 2, 4, 8, 16). - When
cwndreaches 16 (equal tossthresh), enter Congestion Avoidance,cwndbegins linear growth (17, 18, ...). - When
cwnd=24, a segment is lost, triggering Fast Retransmit (receiving 3 duplicate ACKs). - 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.
- Set new slow start threshold:
- 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
cwndstarting linear growth from 12. - If a timeout retransmission occurs during communication (a more severe congestion signal than receiving 3 duplicate ACKs), TCP takes stricter measures:
ssthresh = cwnd / 2.cwndis reset to 1.- Then restart the Slow Start process.
- Connection established, initial
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.