请教Linux内核qos tbf令牌桶算法原理

发布于 2022-10-15 08:48:03 字数 4136 浏览 22 评论 0

因为需要扩展tbf以实现一些特殊的功能,但是发现很难看明白sch_tbf.c中的算法解释,另外搜索了一下相关资料,
都是说一些tbf基本原理,剩下的都是英文的资料,研究了半天,就是找不到头绪,希望了解算法的高人不吝赐教。

  1. from sch_tbf.c
  2. /*        Simple Token Bucket Filter.
  3.         =======================================
  4.         SOURCE.
  5.         -------
  6.         None.
  7.         Description.
  8.         ------------
  9.         A data flow obeys TBF with rate R and depth B, if for any
  10.         time interval t_i...t_f the number of transmitted bits
  11.         does not exceed B + R*(t_f-t_i).
  12.         Packetized version of this definition:
  13.         The sequence of packets of sizes s_i served at moments t_i
  14.         obeys TBF, if for any i<=k:
  15.         s_i+....+s_k <= B + R*(t_k - t_i)
  16.         Algorithm.
  17.         ----------
  18.         Let N(t_i) be B/R initially and N(t) grow continuously with time as:
  19.         N(t+delta) = min{B/R, N(t) + delta}
  20.         If the first packet in queue has length S, it may be
  21.         transmitted only at the time t_* when S/R <= N(t_*),
  22.         and in this case N(t) jumps:
  23.         N(t_* + 0) = N(t_* - 0) - S/R.
  24.         Actually, QoS requires two TBF to be applied to a data stream.
  25.         One of them controls steady state burst size, another
  26.         one with rate P (peak rate) and depth M (equal to link MTU)
  27.         limits bursts at a smaller time scale.
  28.         It is easy to see that P>R, and B>M. If P is infinity, this double
  29.         TBF is equivalent to a single one.
  30.         When TBF works in reshaping mode, latency is estimated as:
  31.         lat = max ((L-B)/R, (L-M)/P)
  32.         NOTES.
  33.         ------
  34.         If TBF throttles, it starts a watchdog timer, which will wake it up
  35.         when it is ready to transmit.
  36.         Note that the minimal timer resolution is 1/HZ.
  37.         If no new packets arrive during this period,
  38.         or if the device is not awaken by EOI for some previous packet,
  39.         TBF can stop its activity for 1/HZ.
  40.         This means, that with depth B, the maximal rate is
  41.         R_crit = B*HZ
  42.         F.e. for 10Mbit ethernet and HZ=100 the minimal allowed B is ~10Kbytes.
  43.         Note that the peak rate TBF is much more tough: with MTU 1500
  44.         P_crit = 150Kbytes/sec. So, if you need greater peak
  45.         rates, use alpha with HZ=1000 :-)
  46.         With classful TBF, limit is just kept for backwards compatibility.
  47.         It is passed to the default bfifo qdisc - if the inner qdisc is
  48.         changed the limit is not effective anymore.
  49. */

复制代码

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱殇璃 2022-10-22 08:48:03

自己顶,没人知道?还是...

半透明的墙 2022-10-22 08:48:03

楼主求救啊   请问你有令牌桶算法的源代码吗?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文