Quantum & r2q

Let's assume we have 2 classes with the same parent :

Parent : ceil = rate = 100
class 1 : rate = 40 and ceil = 100
class 2 : rate = 20 and ceil = 100

(the used numbers are just theoretical to explain how it works)

Both classes are sending as much as they can. First, they are allowed to send enough packets to fulfill the rate even if they have different prio's. 
But the parent has some remaining bandwidth : 100 - 40 - 20 = 40. The remaining bandwidth is distributed according to the quantums. Each class can send "quantum" bytes at a turn.

Quantum is calculated as rate (in bytes) / r2q. r2q is by default 10 and can be overruled if you create an htb qdisc. Quantum can be overruled if you create an htb class. Quantum should be bigger then MTU (1500) so you can send the maximum packet in 1 turn and smaller then 60000 (hard coded in htb qdisc to prevent class starvation and too long delays). 
Errors on the quantum will not affect functionality, only precision. They are also logged via syslog so they can eat a lot of file space.

Packets that are sent when the class is allowed to send, are still matched against rate/ceil/burst/cburst. So a big quantum will not create bursts if you don't allow it with the burs/cburst parameters.

Counting packets with quantum can be strange. If we have a low rate class (rate = 5kbit), default quantum = 5000 / 10 = 500 bytes. But most packets are more then 500 bytes. Htb version 1 and 2 uses DRR, so a packet larger then 1000 bytes will be sent and it will remember how much it sent and wait until the packet is paid back before another packet is send. So if you send 1000 byte, next time the class is polled, you will not be allowed to send. 
Htb3 uses the WRR scheduler. When a packet with size > quantum is sent, it will be sent and an error that the quantum is too small will be logged. But there is no pay back. The WRR scheduler is faster then the DRR scheduler. So make sure quantum is bigger then the default packet size. For 15 kbyte/s and default r2q, quantum is 1500 and this is exactly the maximum packet size. If you want to tune htb for rates smaller then 15 kbyte/s, you can manually set the r2q and/or quantum.

An example 
The parent rate is 30 and it has 3 child classes c1, c2 and c3. The rate of the 3 classes is 10. Quantum of class2 = 1 and quantum of class3 = 2. Class 1 sends 4, so it gets 4. C2 and c3 are sending as much as they can so c2 and c3 get 10 (the rate is always satisfied). The parent still has 6 to distribute between c2 and c3. It will distributed according the quantums, so c2 gets 2 and c3 gets 4.

class rate traffic quantum bandwidth
c1 10 4 ? 4
c2 10 +++ 1 10+2=12
c3 10 +++ 2 10+4=14

Quantum & r2q的更多相关文章

  1. 【转载】linux下使用 TC 对服务器进行流量控制

    tc 介绍 在linux中,tc 有二种控制方法 CBQ 和 HTB.HTB 是设计用来替换 CBQ 的.HTB比CBQ更加灵活,但是CPU 开销也更大,通常高速的链路会使用CBQ,一般而言HTB使用 ...

  2. linux下使用 TC 对服务器进行流量控制

    tc 介绍 在linux中,tc 有二种控制方法 CBQ 和 HTB.HTB 是设计用来替换 CBQ 的.HTB比CBQ更加灵活,但是CPU 开销也更大,通常高速的链路会使用CBQ,一般而言HTB使用 ...

  3. TC HTB r2q

    HTB: quantum of class 10001 is big. Consider r2q change. 根据HTB的官方文档显示,quantum是在可以“借”的情况下,一次可以“借”多少,并 ...

  4. quantum sets

    the principles of quantum mechanics by p.a.m.dirac.

  5. Quantum Bogo sort浅谈

    1.普通的猴子排序(bogo sort) 猴子排序百科 en.wikipedia.org/wiki/Bogosort 不停的随机打乱序列,然后检查,直到排好序 复杂度O(n*n!) while not ...

  6. Openstack Quantum project 更名为 Neuron

    因为与磁带备份厂商Quantum商标冲突: The OpenStack Foundation has changed the name of its networking project from Q ...

  7. resmgr:cpu quantum 等待事件 top 1

    早上看昨天现场的报告,发现晚上七八点,resmgr:cpu quantum 等待事件排在i第一位,如下: 该事件是和资源管理相关的,如果启用资源管理计划,就可能遇到这个问题. 所以常规的解决方案是禁用 ...

  8. quantum theory

    the principles of quantum mechanics by p.a.m.dirac.

  9. 预见未来丨机器学习:未来十年研究热点 量子机器学习(Quantum ML) 量子计算机利用量子相干和量子纠缠等效应来处理信息

    微软研究院AI头条 https://mp.weixin.qq.com/s/SAz5eiSOLhsdz7nlSJ1xdA 预见未来丨机器学习:未来十年研究热点 机器学习组 微软研究院AI头条 昨天 编者 ...

随机推荐

  1. Git 提交大文件提示 fatal: The remote end hung up unexpectedly

    使用gitlab搭建的git server,如果直接使用http的方式去提交的话,提交小文件不会有问题,但是提交大文件时,会出错: fatal: The remote end hung up unex ...

  2. qml的打包问题

    qml2的打包问题: 相对于早期的项目,只需要打包plugin和动态库.带有sqlite的程序如果需要打包,需要打包如下东西: 1.打包AppData目录下的  Local/Qt Project/项目 ...

  3. 目前几款基于html5的前端框架:如Bootstrap、Foundation、Semantic UI 、Amaze UI

    Bootstrap是由Twitter在2011年8月推出的开源WEB前端框架,集合CSS 和HTML,使用了最新的浏览器技术,为快速WEB开发提供了一套前端工具包,包括布局.网格.表格.按钮.表单.导 ...

  4. 类成员函数作为pthread_create函数参数

    from:http://www.cnblogs.com/shijingxiang/articles/5389294.html 近日需要将线程池封装成C++类,类名为Threadpool.在类的成员函数 ...

  5. html中offsetTop、clientTop、scrollTop、offsetTop

    HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 获取对象的滚动高度. scrollLeft:设置或获取位于对 ...

  6. [转载]Android核心分析

    2013-12-19 15:44:03 转载自: http://blog.csdn.net/column/details/androidcore.html 很好的文章,阅读请跳转到转载链接,转载备以后 ...

  7. Spark运行环境的安装

    scala-2.9.3:一种编程语言,下载地址:http://www.scala-lang.org/download/    spark-1.4.0:必须是编译好的Spark,如果下载的是Source ...

  8. auto_ptr的使用原则

    auto_ptr是c++标准库中的一种严格所有权型的智能指针,实现在backward/auto_ptr.h文件中 pro: 1.做临时变量时,不需要手动去释放资源 void f() { ClassA ...

  9. Oracle中varchar,varchar2,nvarchar,nvarchar2的区别

    --varchar,varchar2 联系:1.varchar/varchar2用于存储可变长度的字符串比如varchar(20),存入字符串'abc',则数据库中该字段只占3个字节,而不是20个字节 ...

  10. 《剑指offer-名企面试官精讲典型编程题》读后感

    首先,不得不说这是一本好书!!! 我接触这本书是在学长的推荐下去看的,而且口碑还是挺好的一本书,豆瓣的评分也比较高,当我刚看了它,我就深深的爱上了这本书,到现在为止,我已经看了三遍这本书了,平时无聊时 ...