免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6076 | 回复: 2
打印 上一主题 下一主题

请教Linux内核qos tbf令牌桶算法原理 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-04-22 18:47 |只看该作者 |倒序浏览
因为需要扩展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. */
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-04-26 12:53 |只看该作者
自己顶,没人知道?还是...

论坛徽章:
0
3 [报告]
发表于 2013-03-22 10:55 |只看该作者
楼主求救啊   请问你有令牌桶算法的源代码吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP