Detailed Explanation of TCP Congestion Avoidance Mechanism
1. Problem Background
In TCP congestion control, Congestion Avoidance is the core phase following Slow Start. Its goal is to steadily approach the network bottleneck bandwidth, avoiding network congestion caused by excessive data transmission. Unlike the exponential growth of slow start, congestion avoidance adopts a linear growth strategy to dynamically adjust the size of the congestion window (cwnd).
2. Core Mechanism: Transition from Slow Start to Congestion Avoidance
(1) Limitations of Slow Start
- Slow Start phase: cwnd starts from an initial value (e.g., 1 MSS) and increases by 1 MSS for each ACK received (exponential growth).
- Problem: If exponential growth continues, cwnd will quickly exceed network capacity, causing significant packet loss.
(2) Timing of Switching to Congestion Avoidance
- Threshold (ssthresh): Switch from Slow Start to Congestion Avoidance when cwnd ≥ ssthresh.
- Packet Loss Event: When timeout retransmission occurs or duplicate ACKs are received (triggering Fast Retransmit), ssthresh is reset, and congestion avoidance is entered.
3. Specific Rules of Congestion Avoidance
(1) Principle of Linear Growth
- For every RTT (Round-Trip Time), cwnd increases by 1 MSS (instead of "1 MSS per ACK" in Slow Start).
- Equivalent implementation: For each ACK received, cwnd increases by \(\frac{1}{cwnd}\) MSS (i.e., a cumulative increase of 1 MSS per RTT).
Formula:
\[ \text{cwnd} = \text{cwnd} + \frac{1}{\text{cwnd}} \quad (\text{unit: MSS}) \]
(2) Example Calculation (Assuming current cwnd = 10 MSS)
- Upon receiving the 1st ACK: cwnd = 10 + 1/10 = 10.1 MSS
- Upon receiving the 2nd ACK: cwnd = 10.1 + 1/10.1 ≈ 10.2 MSS
- ... After receiving 10 ACKs, cwnd ≈ 11 MSS (completing growth for one RTT).
4. Interaction Between Congestion Avoidance and Packet Loss Response
(1) Behavior upon Packet Loss
-
Timeout Retransmission:
- Considered severe network congestion; directly reset ssthresh = max(cwnd/2, 2 MSS).
- Reduce cwnd to 1 MSS and re-enter Slow Start.
-
Fast Retransmit (3 Duplicate ACKs):
- Trigger Fast Recovery, ssthresh = cwnd/2.
- cwnd = ssthresh + 3 MSS (because duplicate ACKs indicate data has left the network).
- Enter Congestion Avoidance phase (linear growth).
(2) Complete Flow Diagram
Slow Start (exponential growth) → cwnd ≥ ssthresh → Congestion Avoidance (linear growth)
↓
Detect Packet Loss
↓
Timeout: cwnd=1, Slow Start OR Duplicate ACKs: Fast Recovery → Congestion Avoidance
5. Why is Congestion Avoidance "Additive Increase"?
- Goal: When approaching network capacity, slowly probe available bandwidth through linear growth.
- Advantage: Avoids the aggressiveness of Slow Start, reducing the risk of consecutive packet loss.
- Analogy: Like slowly turning a faucet until the water flow is just full without overflowing (congestion).
6. Adjustments in Practical Applications (e.g., Linux TCP)
- Modern TCP algorithms (e.g., Cubic) have improved linear growth, but the core logic still retains the idea of congestion avoidance.
- Balancing efficiency and fairness through AIMD (Additive Increase, Multiplicative Decrease):
- Additive Increase: Linearly increase cwnd during Congestion Avoidance.
- Multiplicative Decrease: Halve ssthresh upon packet loss.
7. Summary
Congestion Avoidance is the core strategy of TCP in the stable phase. Through linear growth, it smoothly brings the sending rate close to the network bottleneck. Together with Slow Start and Fast Retransmit/Recovery, it forms a closed loop of congestion control. Its design embodies the philosophy of "cautious probing," ensuring a balance between high network throughput and low congestion.