TCP吞吐量模型推导计算
🧑💻 User
In a previous topic, we saw that the congestion window follows a sawtooth pattern. In the figure below, the congestion window is increased by 1 packet every RTT until it reaches the maximum value W. At this point, a loss is detected, and the cwnd is cut in half.
Given this behavior, we want to have a simple model that predicts the throughput for a TCP connection.
To make our model more realistic, let’s also assume that we have p = the probability loss. So, we assume that the network delivers 1/ p consecutive packets, followed by a single packet loss.
The TCP Protocol: TCP Throughput-1
Because the congestion window (cwnd) size increases a constant rate of 1 packet for every RTT, the height of the sawtooth is W / 2, and the width of the base is W / 2, which corresponds to W / 2 round trips, or RTT \ W / 2*.
The number of packets sent in one cycle is the area under the sawtooth. Therefore, the total number of packets sent is
$\left(\frac{W}{2}\right)^2 + \frac{1}{2} \left(\frac{W}{2}\right)^2 = \frac{3}{8}W^2$
As stated in our assumptions about our lossy network, it delivers 1/p packets followed by a loss. So we have
$\frac{1}{p}=\frac{3}{8} W^2$
and solving for W gives the maximum value $W = \sqrt[]{\frac{8}{3p}} = 2\cdot\sqrt[]{\frac{2}{3p}}$.
The rate that data that is transmitted, i.e., throughput/bandwidth, BW, is computed as:
BW = data per cycle / time per cycle
Substituting from above:
$BW = \frac{data\:per\:cycle}{time\:per\:cycle}\:=\:\frac{MSS\:\cdot\frac{\:3}{8}W^2}{RTT\:\cdot\frac{\:W}{2}}\:=\:\frac{\frac{MSS}{p}}{RTT\sqrt[]{\frac{2}{3p}}}$
We can collect all of our constants into $C\:=\:\sqrt{\frac{3}{2}}$, and compute the bandwidth
$BW\:=\:\frac{MSS}{RTT}\cdot\frac{C}{\sqrt{p}}$
In practice, because of additional parameters, such as small receiver windows, extra bandwidth availability, and TCP timeouts, our constant term C is usually less than 1. This means that bandwidth is bounded:
$BW\:<\:\frac{MSS}{RTT}\cdot\frac{1}{\sqrt{p}}$
References
- http://ccr.sigcomm.org/archive/1997/jul97/ccr-9707-mathis.pdf Links to an external site.
- https://blog.thousandeyes.com/a-very-simple-model-for-tcp-throughput/ Links to an external site.
🤖 Assistant
TCP 吞吐量模型 - 费曼学习法自检清单
📋 Checklist(自检清单)
第一部分:基础概念理解
- [ ] 1. 我能解释什么是拥塞窗口(Congestion Window,
cwnd)的锯齿模式(Sawtooth Pattern)吗? - [ ] 2. 我能说明 RTT(Round Trip Time,往返时间)在这个模型中的作用吗?
- [ ] 3. 我能解释丢包概率 p(Probability of Loss)的含义吗?
第二部分:锯齿图形分析
- [ ] 4. 我能解释为什么锯齿的高度是 W/2 吗?
- [ ] 5. 我能解释为什么锯齿的底边宽度是 W/2 个 RTT 吗?
- [ ] 6. 我能推导出一个周期内发送的数据包数量为 (3/8)W² 吗?
第三部分:数学推导
- [ ] 7. 我能解释 1/p = (3/8)W² 这个等式的含义吗?
- [ ] 8. 我能从上述等式推导出 W 的表达式吗?
- [ ] 9. 我能解释带宽(Bandwidth, BW)= 数据量/时间 的计算过程吗?
第四部分:最终公式理解
- [ ] 10. 我能写出并解释 TCP 吞吐量公式 BW = (MSS/RTT) × (C/√p) 吗?
- [ ] 11. 我能解释为什么实际中常数 C 通常小于 1 吗?
- [ ] 12. 我能用自己的话向别人解释这个模型的实际意义吗?
第五部分:应用与延伸
- [ ] 13. 如果丢包率 p 增加,吞吐量会如何变化?
- [ ] 14. 如果 RTT 增加,吞吐量会如何变化?
- [ ] 15. MSS(Maximum Segment Size,最大报文段大小)如何影响吞吐量?
✅ 答案与详解
问题 1:我能解释什么是拥塞窗口(cwnd)的锯齿模式吗?
答案:
拥塞窗口的锯齿模式描述了 TCP 拥塞控制的行为:
- 上升阶段:每经过一个 RTT,
cwnd增加 1 个数据包(加性增加,Additive Increase) - 下降阶段:当检测到丢包时,
cwnd减半(乘性减少,Multiplicative Decrease) - 这种 AIMD(Additive Increase Multiplicative Decrease)机制形成了锯齿状的图形
问题 2:RTT 在这个模型中的作用是什么?
答案:
RTT(往返时间)是:
- 发送数据包到收到确认(ACK)所需的时间
- 决定了
cwnd增长的速度(每个 RTT 增加 1) - 是计算吞吐量的关键分母:RTT 越大,吞吐量越低
问题 3:丢包概率 P 的含义是什么?
答案:
丢包概率 p 表示:
- 网络中每传输一定数量的数据包后会丢失一个包
- 具体来说,网络平均每传输 1/p 个连续数据包后,会发生一次丢包
- 例如:p = 0.01 意味着平均每 100 个包丢 1 个
问题 4:为什么锯齿的高度是 W/2?
答案:
- 当
cwnd达到最大值 W 时发生丢包 - 丢包后
cwnd减半,变为 W/2 - 因此锯齿从 W/2 增长到 W,高度差 = W - W/2 = W/2
问题 5:为什么锯齿的底边宽度是 W/2 个 RTT?
答案:
cwnd每个 RTT 增加 1 个数据包- 从 W/2 增长到 W,需要增加 W/2 个数据包
- 因此需要 W/2 个 RTT
- 时间 = RTT × W/2
问题 6:一个周期内发送的数据包数量为什么是 (3/8)W²?
答案:
锯齿图形可以分解为:
- 一个矩形:底 = W/2,高 = W/2 → 面积 = (W/2)²
- 一个三角形:底 = W/2,高 = W/2 → 面积 = (1/2) × (W/2)²
总面积 = (W/2)² + (1/2)(W/2)² = (W²/4) + (W²/8) = 3W²/8
问题 7:1/p = (3/8)W² 这个等式的含义是什么?
答案:
- 网络每传输 1/p 个数据包后发生一次丢包
- 一个完整的锯齿周期正好对应一次丢包事件
- 因此,一个周期内发送的包数 = 1/p
- 所以:1/p = (3/8)W²
问题 8:如何推导出 W 的表达式?
答案:
从 1/p = (3/8)W² 出发:
1 | W² = 8/(3p) |
问题 9:带宽的计算过程是什么?
答案:
1 | BW = 数据量(Data per cycle) / 时间(Time per cycle) |
问题 10:TCP 吞吐量公式的含义是什么?
答案:
其中 C = √(3/2) ≈ 1.22
含义:
- MSS/RTT:基础传输速率
- 1/√p:丢包率的影响因子,丢包率越高,吞吐量越低
- C:理论常数
问题 11:为什么实际中常数 C 通常小于 1?
答案:
实际网络中存在多种限制因素:
- 小的接收窗口(Small Receiver Windows)
- 额外的带宽可用性变化(Extra Bandwidth Availability)
- TCP 超时(TCP Timeouts)
- 因此实际带宽上界为:BW < (MSS/RTT) × (1/√p)
问题 12:这个模型的实际意义是什么?
答案:
这个模型告诉我们:
- TCP 吞吐量与 MSS 成正比
- TCP 吞吐量与 RTT 成反比(长距离连接性能差)
- TCP 吞吐量与 √p 成反比(丢包率影响显著)
- 这解释了为什么高延迟、高丢包的网络中 TCP 性能很差
问题 13:如果丢包率 P 增加,吞吐量会如何变化?
答案:
- 吞吐量与 1/√p 成正比
- p 增加 → √p 增加 → 1/√p 减小 → 吞吐量下降
- 例如:p 从 1% 增加到 4%,吞吐量减半
问题 14:如果 RTT 增加,吞吐量会如何变化?
答案:
- 吞吐量与 1/RTT 成正比
- RTT 增加 → 吞吐量线性下降
- 这就是为什么跨洋连接(高 RTT)的 TCP 性能较差
问题 15:MSS 如何影响吞吐量?
答案:
- 吞吐量与 MSS 成正比
- MSS 越大 → 每个数据包携带更多数据 → 吞吐量越高
- 但 MSS 受限于网络的 MTU(Maximum Transmission Unit)
🎯 核心公式总结
| 项目 | 公式 |
|---|---|
| 周期数据量 | (3/8)W² packets |
| 周期时间 | RTT × W/2 |
| 最大窗口 W | √(8/3p) |
| 吞吐量 | BW = (MSS/RTT) × (C/√p) |
| 实际上界 | BW < (MSS/RTT) × (1/√p) |
