请教Linux内核qos tbf令牌桶算法原理
因为需要扩展tbf以实现一些特殊的功能,但是发现很难看明白sch_tbf.c中的算法解释,另外搜索了一下相关资料,
都是说一些tbf基本原理,剩下的都是英文的资料,研究了半天,就是找不到头绪,希望了解算法的高人不吝赐教。
- from sch_tbf.c
- /* Simple Token Bucket Filter.
- =======================================
- SOURCE.
- -------
- None.
- Description.
- ------------
- A data flow obeys TBF with rate R and depth B, if for any
- time interval t_i...t_f the number of transmitted bits
- does not exceed B + R*(t_f-t_i).
- Packetized version of this definition:
- The sequence of packets of sizes s_i served at moments t_i
- obeys TBF, if for any i<=k:
- s_i+....+s_k <= B + R*(t_k - t_i)
- Algorithm.
- ----------
- Let N(t_i) be B/R initially and N(t) grow continuously with time as:
- N(t+delta) = min{B/R, N(t) + delta}
- If the first packet in queue has length S, it may be
- transmitted only at the time t_* when S/R <= N(t_*),
- and in this case N(t) jumps:
- N(t_* + 0) = N(t_* - 0) - S/R.
- Actually, QoS requires two TBF to be applied to a data stream.
- One of them controls steady state burst size, another
- one with rate P (peak rate) and depth M (equal to link MTU)
- limits bursts at a smaller time scale.
- It is easy to see that P>R, and B>M. If P is infinity, this double
- TBF is equivalent to a single one.
- When TBF works in reshaping mode, latency is estimated as:
- lat = max ((L-B)/R, (L-M)/P)
- NOTES.
- ------
- If TBF throttles, it starts a watchdog timer, which will wake it up
- when it is ready to transmit.
- Note that the minimal timer resolution is 1/HZ.
- If no new packets arrive during this period,
- or if the device is not awaken by EOI for some previous packet,
- TBF can stop its activity for 1/HZ.
- This means, that with depth B, the maximal rate is
- R_crit = B*HZ
- F.e. for 10Mbit ethernet and HZ=100 the minimal allowed B is ~10Kbytes.
- Note that the peak rate TBF is much more tough: with MTU 1500
- P_crit = 150Kbytes/sec. So, if you need greater peak
- rates, use alpha with HZ=1000 :-)
- With classful TBF, limit is just kept for backwards compatibility.
- It is passed to the default bfifo qdisc - if the inner qdisc is
- changed the limit is not effective anymore.
- */
复制代码
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自己顶,没人知道?还是...
楼主求救啊 请问你有令牌桶算法的源代码吗?