关于tc 中htb算法中的r2q和quantum的做用

2023-10-20 20:30
文章标签 算法 htb tc quantum r2q

本文主要是介绍关于tc 中htb算法中的r2q和quantum的做用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


tc qdisc add dev eth0 root handle 1: htb r2q 10 default 10


r2q:在规则中的作用是用来分配剩余带宽的全局变量,它的默认值为10,此时最实用的规则的速度为15KBps(120kbit)。

quantum与r2q的关系为quantum=rate/r2q,quantum的值必须在1500到60000之间,值越小越好

每个规则的quantum的值就是从父类借用带宽的因子(也就是每个子类每次可以从父类借用空闲带宽的大小)也可以说是与其他子类同时从父类借带宽的比例。

rate单位为Mbit时,上限临界值为 0.7左右,即r2q最小要设为0.7。rate单位为Gbit时,上限临界值为700左右,即r2q最小要设为700。

tc returns: "quantum of class # is small. Consider r2q change."

Reported by Alwin Garside  on 2009-01-28 2AffectsStatusImportanceAssigned toMilestone? Vulpes Triaged 点击图片看大图 中国学网 www.xue163.com
Low Alwin Garside Also affects project (?)  Also affects distribution/package  Nominate for series

Bug Description

It is documented in HTB manual. The complaint was not displayed before and sharing was silently wrong. Quantum of leaf should be between 1500 and 60000 and it is computed as rate/r2q (or can be supplied independly). So that if your maximal leaf rate is 1Mbit (120000Bps) then r2q should be 3. If max rate is 10kbit (1200Bps) then r2q should be 1. It is warning only and will not affect functionality, only precision. devik

Smallest rate : 16kbit = 2 kilobyt / r2q (=10) = 200. And this is < 1500. So you get warnings. Biggest rate : 100mbit = 12.5 mbyte / r2q = 1.2 Mbyte > 60.000. So you get warnings.

If you do tc qdisc add dev eth0 root handle 1: htb default 10 r2q 1 Smallest rate : 16kbit = 2kilobyte / r2k = 2000. And this is > 1500. So no warnings. Biggest rate : 100mbit = 12.5 mbyte / r2q = 12.5 Mbyte > 60.000. So you get warnings. But you can overrule the quantum : tc class add dev eth0 parent 1:1 classid 1:11 htb rate 128kbit burst 2k quantum 60000

Quantum is used when 2 classes are getting more bandwidth then the rate. So it's only important for sharing the remaining bandwidth. In that case, each class may send quantum bytes.

see: http://archives.free.net.ph/message/20051020.143239.c839805b.en.html#lartc


tc qdisc add dev eth0 root handle 1: htb r2q 10 default 10

r2q:在规则中的作用是用来分配剩余带宽的全局变量,它的默认值为10,此时最实用的规则的速度为15KBps(120kbit)。
quantum与r2q的关系为quantum=rate/r2q,quantum的值必须在1500到60000之间,值越小越好
每个规则的quantum的值就是从父类借用带宽的因子(也就是每个子类每次可以从父类借用空闲带宽的大小)也可以说是与其他子类同时从父类借带宽的比例。




TC HTB r2q

HTB:
quantum of class 10001 is big. Consider r2q change.



根据HTB的官方文档显示,quantum是在可以“借”的情况下,一次可以“借”多少,并且说这个值最好尽量的小,但要大于MTU;而且这个值是不用手动设置,它会根据r2q的值计算出来。


Changing burst will not remove the warning.  r2q is "rate to quantum" is used

to calculate the quantum for each class : quantum = rate / r2q.  Quantum must

be 1500 < quantum < 60000.  Otherwise you will get warnings from the kernel.

Solution : choose r2q so for each class 1500 < quantum < 60000

Or choose the best r2q you can and specify the quantum manually if you add a

class.



> tc qdisc add dev eth0 root handle 1: htb default 10

Default r2q = 10.



> tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit burst 2k

> tc class add dev eth0 parent 1:1 classid 1:10 htb rate 80mbit ceil 100mbit

> burst 2k

>

> tc class add dev eth0 parent 1:1 classid 1:11 htb rate 128kbit burst 2k

> tc class add dev eth0 parent 1:11 classid 1:21 htb rate 16kbit ceil 56kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:22 htb rate 16kbit ceil 40kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:23 htb rate 16kbit ceil 72kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:24 htb rate 16kbit ceil 64kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:25 htb rate 16kbit ceil 40kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:26 htb rate 16kbit ceil 40kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:27 htb rate 16kbit ceil 32kbit

> burst 2k

> tc class add dev eth0 parent 1:11 classid 1:28 htb rate 16kbit ceil 56kbit

> burst 2k

Smallest rate : 16kbit = 2 kilobyt / r2q (=10) = 200.  And this is < 1500.  So

you get warnings.

Biggest rate : 100mbit = 12.5 mbyte / r2q = 1.2 Mbyte > 60.000.  So you get

warnings. 



If you do

tc qdisc add dev eth0 root handle 1: htb default 10 r2q 1

Smallest rate : 16kbit = 2kilobyte / r2k = 2000.  And this is > 1500.  So no

warnings.

Biggest rate : 100mbit = 12.5 mbyte / r2q = 12.5 Mbyte > 60.000.  So you get

warnings.  But you can overrule the quantum :

tc class add dev eth0 parent 1:1 classid 1:11 htb rate 128kbit burst 2k

quantum 60000



Quantum is used when 2 classes are getting more bandwidth then the rate.   So

it‘s only important for sharing the remaining bandwidth.  In that case, each

class may send quantum bytes.

TC HTB r2q


这篇关于关于tc 中htb算法中的r2q和quantum的做用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/249529

相关文章

openCV中KNN算法的实现

《openCV中KNN算法的实现》KNN算法是一种简单且常用的分类算法,本文主要介绍了openCV中KNN算法的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录KNN算法流程使用OpenCV实现KNNOpenCV 是一个开源的跨平台计算机视觉库,它提供了各

springboot+dubbo实现时间轮算法

《springboot+dubbo实现时间轮算法》时间轮是一种高效利用线程资源进行批量化调度的算法,本文主要介绍了springboot+dubbo实现时间轮算法,文中通过示例代码介绍的非常详细,对大家... 目录前言一、参数说明二、具体实现1、HashedwheelTimer2、createWheel3、n

SpringBoot实现MD5加盐算法的示例代码

《SpringBoot实现MD5加盐算法的示例代码》加盐算法是一种用于增强密码安全性的技术,本文主要介绍了SpringBoot实现MD5加盐算法的示例代码,文中通过示例代码介绍的非常详细,对大家的学习... 目录一、什么是加盐算法二、如何实现加盐算法2.1 加盐算法代码实现2.2 注册页面中进行密码加盐2.

Java时间轮调度算法的代码实现

《Java时间轮调度算法的代码实现》时间轮是一种高效的定时调度算法,主要用于管理延时任务或周期性任务,它通过一个环形数组(时间轮)和指针来实现,将大量定时任务分摊到固定的时间槽中,极大地降低了时间复杂... 目录1、简述2、时间轮的原理3. 时间轮的实现步骤3.1 定义时间槽3.2 定义时间轮3.3 使用时

如何通过Golang的container/list实现LRU缓存算法

《如何通过Golang的container/list实现LRU缓存算法》文章介绍了Go语言中container/list包实现的双向链表,并探讨了如何使用链表实现LRU缓存,LRU缓存通过维护一个双向... 目录力扣:146. LRU 缓存主要结构 List 和 Element常用方法1. 初始化链表2.

golang字符串匹配算法解读

《golang字符串匹配算法解读》文章介绍了字符串匹配算法的原理,特别是Knuth-Morris-Pratt(KMP)算法,该算法通过构建模式串的前缀表来减少匹配时的不必要的字符比较,从而提高效率,在... 目录简介KMP实现代码总结简介字符串匹配算法主要用于在一个较长的文本串中查找一个较短的字符串(称为

通俗易懂的Java常见限流算法具体实现

《通俗易懂的Java常见限流算法具体实现》:本文主要介绍Java常见限流算法具体实现的相关资料,包括漏桶算法、令牌桶算法、Nginx限流和Redis+Lua限流的实现原理和具体步骤,并比较了它们的... 目录一、漏桶算法1.漏桶算法的思想和原理2.具体实现二、令牌桶算法1.令牌桶算法流程:2.具体实现2.1

Python中的随机森林算法与实战

《Python中的随机森林算法与实战》本文详细介绍了随机森林算法,包括其原理、实现步骤、分类和回归案例,并讨论了其优点和缺点,通过面向对象编程实现了一个简单的随机森林模型,并应用于鸢尾花分类和波士顿房... 目录1、随机森林算法概述2、随机森林的原理3、实现步骤4、分类案例:使用随机森林预测鸢尾花品种4.1

不懂推荐算法也能设计推荐系统

本文以商业化应用推荐为例,告诉我们不懂推荐算法的产品,也能从产品侧出发, 设计出一款不错的推荐系统。 相信很多新手产品,看到算法二字,多是懵圈的。 什么排序算法、最短路径等都是相对传统的算法(注:传统是指科班出身的产品都会接触过)。但对于推荐算法,多数产品对着网上搜到的资源,都会无从下手。特别当某些推荐算法 和 “AI”扯上关系后,更是加大了理解的难度。 但,不了解推荐算法,就无法做推荐系

康拓展开(hash算法中会用到)

康拓展开是一个全排列到一个自然数的双射(也就是某个全排列与某个自然数一一对应) 公式: X=a[n]*(n-1)!+a[n-1]*(n-2)!+...+a[i]*(i-1)!+...+a[1]*0! 其中,a[i]为整数,并且0<=a[i]<i,1<=i<=n。(a[i]在不同应用中的含义不同); 典型应用: 计算当前排列在所有由小到大全排列中的顺序,也就是说求当前排列是第