linux tc qos burst 的使用

5 阅读1分钟

Ran terminal command: cd /root/f/kube-ovn && grep -E "decimalBurst|updatedDecimalBurst" test/e2e/iptables-eip-qos/e2e_test.go

公式: burst = rate × 1秒
      burst_bytes = rate_Mbps × 125,000 bytes
      burst_MB = burst_bytes / 1,048,576

测试用例验证:
┌──────────┬────────────────────┬────────────┬──────────┬─────────────┐
│ Rate     │ burst_bytes        │ burst_MB   │ 代码值   │ > MTU 1500? │
├──────────┼────────────────────┼────────────┼──────────┼─────────────┤
│ 0.5 Mbps │ 0.5×125000=62,500  │ 0.0596     │ 0.06     │ ✓ (41× MTU) │
│ 1.5 Mbps │ 1.5×125000=187,500 │ 0.1788     │ 0.18     │ ✓ (125× MTU)│
└──────────┴────────────────────┴────────────┴──────────┴─────────────┘

关键约束:
✓ burst > MTU (1500 bytes) - 防止 HTB 无法正常处理数据包
✓ burst = rate × 1秒 - 足够大让 TCP 正常工作
✓ 不会太大导致初始 burst 过长

参考文档:
https://man7.org/linux/man-pages/man8/tc-htb.8.html

确认正确且完善

Rateburst_bytesburst_MB代码值> MTU?
0.5 Mbps62,5000.05960.06✓ (41× MTU)
1.5 Mbps187,5000.17880.18✓ (125× MTU)

关键点已记录在注释中:

  • ✓ 参考文档链接
  • ✓ 原文引用
  • ✓ MTU 约束警告框
  • ✓ 失败案例 (burst=629 < MTU 导致问题)
  • ✓ 公式推导
  • ✓ 测试用例值