avatar

目录
TCP拥塞控制原理总结

TCP拥塞控制原理总结

🧑‍💻 User

Close


We begin with a general discussion about how TCP controls congestion. It decreases the window when the level of congestion goes up, and it increases the window when the level of congestion goes down. We refer to this combined mechanism as additive increase/multiplicative decrease (AIMD).

Additive Increase

The connection starts with a constant initial window, typically 2, and increases it additively. The idea behind additive increase is to increase the window by one packet every RTT (Round Trip Time). So, in the additive increase part of the AIMD, every time the sending host successfully sends a CongestionWindow (cwnd) number of packets it adds 1 to cwnd.

Also, in practice, this increase in AIMD happens incrementally. TCP does not wait for ACKs of all the packets from the previous RTT. Instead, it increases the congestion window size as soon as each ACK arrives. In bytes, this increment is a portion of the MSS (Maximum Segment Size).

Increment = MSS × (MSS / CongestionWindow)

CongestionWindow += Increment

Congestion control at TCP - AIMD-1

Congestion control at TCP - AIMD-1

Multiplicative Decrease

Once TCP detects congestion, it reduces the rate at which the sender transmits. So, when the TCP sender detects that a loss event has occurred, then it sets cwnd to half of its previous value. This decrease of the cwnd for each timeout corresponds to the “multiplicative decrease” part of AIMD. For example, suppose the cwnd is currently set to 16 packets. If a loss is detected, then cwnd is set to 8. Further losses would result in the cwnd to be reduced to 4, and then to 2, and then to 1. The value of cwnd cannot be reduced further than a value of 1 packet.

TCP continually increases and decreases the congestion window throughout the lifetime of the connection. If we plot cwnd with respect to time, we observe that it follows a sawtooth pattern as shown in the figure:

Congestion control at TCP - AIMD-3

Congestion control at TCP - AIMD-3

TCP Reno

Different implementations of TCP use variations to control congestion and maximize bandwidth usage. For example, TCP Reno uses two types of loss events as a signal of congestion. The first is the triple duplicate ACKs, which is considered mild congestion. In this case, the congestion window is reduced to half the original.

The second kind of congestion detection is timeout, i.e., when no ACK is received within a specified amount of time. It is considered a more severe form of congestion, and the congestion window is reset to the initial window size.

T he figure below shows the size of the congestion window before and after the two events described above:

Lastly, we note that “probing” refers to the fact that a TCP sender increases its transmission rate to probe for the rate at which congestion begins, then backs off from that rate, and then begins probing again to see if the congestion level has changed.


Error in the video slides.

The TCP window should increase by 1 packet every RTT.


References

Peterson, Section 6.3

Kurose, 6e, Section 3.7


🤖 Assistant

TCP 拥塞控制 (Congestion Control) - 费曼学习法自检清单


📋 Checklist 自检清单

第一部分:核心概念理解

  • [ ] 1. 我能用一句话解释什么是 AIMD (Additive Increase/Multiplicative Decrease) 吗?
  • [ ] 2. 我能解释为什么 TCP 要同时使用”加性增加”和”乘性减少”两种策略吗?

第二部分:加性增加 (Additive Increase)

  • [ ] 3. 我能解释 cwnd (Congestion Window) 是什么吗?
  • [ ] 4. 我能说出加性增加的核心规则是什么吗?(每 RTT 增加多少?)
  • [ ] 5. 我能写出增量计算公式吗?
  • [ ] 6. 我能解释为什么 TCP 不等所有 ACK 到达才增加窗口,而是每收到一个 ACK 就增加一点?

第三部分:乘性减少 (Multiplicative Decrease)

  • [ ] 7. 我能解释当检测到拥塞时,cwnd 如何变化吗?
  • [ ] 8. 如果 cwnd = 16,连续发生 3 次丢包,cwnd 最终变成多少?
  • [ ] 9. cwnd 的最小值是多少?

第四部分:TCP Reno 变体

  • [ ] 10. 我能区分 TCP Reno 中两种拥塞信号吗?
  • [ ] 11. Triple Duplicate ACKs (三次重复ACK) 触发什么响应?
  • [ ] 12. Timeout (超时) 触发什么响应?
  • [ ] 13. 为什么这两种情况的处理方式不同?

第五部分:整体理解

  • [ ] 14. 我能画出 cwnd 随时间变化的 锯齿图 (sawtooth pattern) 吗?
  • [ ] 15. 我能解释 “probing” (探测) 在 TCP 拥塞控制中的含义吗?

第六部分:能否教给别人

  • [ ] 16. 我能用生活中的比喻向一个完全不懂网络的人解释 AIMD 吗?

✅ 参考答案

问题 1:我能用一句话解释什么是 AIMD 吗?

答案:AIMD 是 TCP 的拥塞控制机制——当网络通畅时缓慢增加发送速率(每 RTT 加 1),当检测到拥塞时快速减半发送速率。


问题 2:为什么 TCP 要同时使用”加性增加”和”乘性减少”?

答案

  • 加性增加:谨慎地探测网络容量,避免突然增加太多导致拥塞
  • 乘性减少:快速响应拥塞,迅速降低负载,防止网络崩溃
  • 组合效果:在效率和稳定性之间取得平衡

问题 3:cwnd (Congestion Window) 是什么?

答案:cwnd 是发送方维护的一个变量,表示在收到 ACK 之前可以发送的最大数据量(以 packets 或 bytes 计)。它控制着发送速率。


问题 4:加性增加的核心规则是什么?

答案:每经过一个 RTT (Round Trip Time),cwnd 增加 1 个 packet


问题 5:增量计算公式是什么?

答案

Code
1
2
Increment = MSS × (MSS / CongestionWindow)
CongestionWindow += Increment

其中 MSS (Maximum Segment Size) 是最大报文段大小。


问题 6:为什么 TCP 每收到一个 ACK 就增加窗口?

答案:这是增量式实现 (incremental implementation)。TCP 不等待一个 RTT 内所有 ACK 到达,而是每收到一个 ACK 就增加一小部分,这样响应更及时、更平滑。


问题 7:检测到拥塞时,cwnd 如何变化?

答案:cwnd 被设置为当前值的一半 (half)


问题 8:cwnd = 16,连续 3 次丢包后变成多少?

答案

  • 第 1 次丢包:16 → 8
  • 第 2 次丢包:8 → 4
  • 第 3 次丢包:4 → 2

最终 cwnd = 2


问题 9:cwnd 的最小值是多少?

答案1 packet,不能再低了。


问题 10:TCP Reno 中两种拥塞信号是什么?

答案
| 信号类型 | 严重程度 | 响应方式 |
|————-|————-|————-|
| Triple Duplicate ACKs (三次重复ACK) | 轻度拥塞 (mild) | cwnd 减半 |
| Timeout (超时) | 严重拥塞 (severe) | cwnd 重置为初始值 |


问题 11:Triple Duplicate ACKs 触发什么响应?

答案:cwnd 减半(乘以 0.5)。


问题 12:Timeout 触发什么响应?

答案:cwnd 重置为初始窗口大小 (initial window size),通常是 2。


问题 13:为什么两种情况处理方式不同?

答案

  • Triple Duplicate ACKs:说明网络还在传输数据(能收到重复 ACK),只是部分丢包,拥塞较轻
  • Timeout:说明完全收不到任何响应,网络可能严重拥塞,需要更激进地降速

问题 14:锯齿图 (sawtooth pattern) 是什么样的?

答案

Code
1
2
3
4
5
6
7
cwnd
^
| /\ /\ /\
| / \ / \ / \
| / \ / \ / \
| / \/ \/ \
+-------------------------> time

  • 斜向上:加性增加阶段
  • 垂直下降:检测到拥塞,乘性减少

问题 15:”Probing” 是什么意思?

答案:TCP 发送方不断试探网络容量——逐渐增加发送速率直到发生拥塞,然后退回,再继续试探。这是一个持续的”探测-退回-再探测”循环。


问题 16:生活比喻解释 AIMD

答案:想象你在高速公路上开车:

  • 加性增加:路况好时,你每分钟加速 5 km/h,小心翼翼地提速
  • 乘性减少:一旦看到前方堵车(拥塞),你立刻把速度减半
  • 锯齿模式:你不断加速→遇堵→减速→再加速,速度曲线像锯齿
  • Probing:你在试探”这条路最快能开多快而不堵”

🎯 学习建议

如果你能不看答案完成 80% 以上的 Checklist,说明你已经真正理解了 TCP AIMD!


评论