关于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


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: LaTeX是一种基于TeX的排版系统,用于生成高质量的科学和技术文档。在LaTeX,可以使用algorithm2e或者algorithmicx这两个宏包来处理算法算法写作主要需要几个步骤: 1. 导入宏包 在LaTeX文档,需要添加以下代码来导入宏包: \usepackage{algorithm} \usepackage{algpseudocode} 其,algorithm宏包提供了algorithm环境,用于包裹整个算法,而algpseudocode提供了算法所需的基本语法和命令。 2. 编写算法 在algorithm环境,可以使用以下基本命令来描述算法: \begin{algorithm}[htb] \caption{算法名称} \label{alg:a1} \begin{algorithmic}[1] \Procedure{ProcedureName}{$parameters$} \State //算法过程 \EndProcedure \end{algorithmic} \end{algorithm} 其,第一行的algorithm环境名称可以根据需要更改,大括号内的内容为算法的名称。由于算法可以包含多个过程,因此可以在algorithmic环境使用Procedure命令来定义一个过程。 在过程内部,可以使用以下命令来描述算法的具体过程: $\bullet$ State命令:用于描述某个状态; $\bullet$ For/While命令:用于描述循环过程; $\bullet$ If/Else命令:用于描述条件判断; $\bullet$ Return命令:用于描述返回值; $\bullet$ AlgorithmicComment命令:用于添加注释。 例如,以下是一个简单的用algorithmicx宏包编写的简单算法: \begin{algorithm} \caption{递归算法实现} \label{alg:a1} \begin{algorithmic}[1] \Function{Factorial}{$n$} \If{$n==0$} \State \Return 1 \Else \State \Return $n*Factorial(n-1)$ \EndIf \EndFunction \end{algorithmic} \end{algorithm} 3. 调用算法 在调用算法时,可以使用ref命令来引用算法,例如: 如图\ref{alg:a1}所示,递归算法实现的阶乘计算。 以上就是在LaTeX编写算法的基本步骤,通过以上步骤,可以快速高效地编写各种算法。 ### 回答2: 在LaTeX算法,可以通过使用algorithm2e宏包来实现。Algorithm2e提供了一个简单而灵活的机制来编写算法,它不仅支持各种各样的算法结构,还可以配合使用伪代码和一些其他的语言元素,如条件分支和循环等。下面是一个在LaTeX编写算法的步骤: 1.安装algorithm2e宏包。算法是algorithm2e宏包的核心特性之一,这个宏包是LaTex用户可以使用的最流行的算法宏包之一。用户可以在TeX Live和MiKTeX找到与该宏包相应的包,或者也可以手动下载该宏包,并将其放在适当的位置上。 2.使用algorithm2e宏包。一旦安装成功,就可以使用该宏包了。首先,在LaTeX文档的顶部调用algorithm2e 包,如下所示: \usepackage{algorithm2e} 3.准备算法。现在可以开始编写算法了。下面是一个简单的示例算法: \begin{algorithm}[H] \SetAlgoLined \KwIn{输入数据 $x$} \KwOut{计算结果 $f(x)$} \eIf{$x>0$}{ $f(x)=x+5$\; }{ $f(x)=|x|$\; } \caption{一个简单的算法示例} \end{algorithm} 4.解释算法元素。在以上示例,$\SetAlgoLined$ 表示各行算法的分隔线,\KwIn 和\KwOut 是算法的输入和输出,而\eIf{condition}{then部分}{else部分}构成了一个条件分支的创建。 5.进一步提高。用户还可以通过不同的方式来提高算法的可读性,例如使用注释、子例程和标签等。下面是一个使用子例程和标签的高级示例: \begin{algorithm} $Result \gets MaximumFlow(G, s, t)$ \ForEach{$v \in G$}{ $v.color \gets WHITE$ } \ForEach{$v \in residualGraph(G)$}{ $v.color \gets BLUE$ } $2 \gets 3$\; \label{cmt} \ForEach{$Edge(u, v) \in G$} { \If{$u.color = BLUE$ and $v.color = WHITE$}{ \uline{Augment}($v$, $u$, $G$) \label{line} } } \caption{A simple example}\label{algo2e} \end{algorithm} 在上面的算法,\uline{Augment}代表子例程,而第五行的\label语句将该行命名为&ldquo;line&rdquo;。最后一行的\label语句将整个算法命名为&ldquo;algo2e&rdquo;。这些标签可以在文档链接到相应的算法行,从而实现针对详细算法的交互演示。 总之,在LaTeX 编写算法是相对简单和灵活的,用户只需通过提供简单格式的说明来实现算法在正文出现的目的。这几个步骤可以帮助用户了解如何编写LaTeX算法。 ### 回答3: 在latex,我们可以使用algorithm2e宏包来写算法。使用该宏包之前需要在文档开头添加如下代码: \usepackage[ruled,linesnumbered]{algorithm2e} 其,ruled表示算法会被框起来,linesnumbered表示算法每一行都会被编号。接着就可以开始编写算法了。 算法的基本结构如下: \begin{algorithm}[H] \caption{算法名称} \LinesNumbered \KwIn{输入} \KwOut{输出} \BlankLine 算法内容 \end{algorithm} 其,\caption{算法名称}表示算法的名称,\LinesNumbered表示开启行号,\KwIn和\KwOut表示输入和输出,\BlankLine是一个空行用于排版美观。算法内容可以使用以下语句: \If{条件}{执行语句} \While{条件}{执行语句} \For{变量从起始值到结束值}{执行语句} \Repeat{条件}{执行语句} \Switch{变量}{\Case{值1}{执行语句}\Case{值2}{执行语句}} 其,\If表示条件语句,\While表示循环语句,\For表示循环语句,\Repeat表示重复语句,\Switch表示条件语句,\Case表示分支语句。 算法还可以使用一些特殊命令来表示一些数学符号,如$\gets$表示赋值符号,$\ge$表示大于等于号,$\le$表示小于等于号等。 综上所述,使用algorithm2e宏包可以轻松地在latex编写算法。需要特别注意的是,算法的排版应该尽量美观、简洁,方便阅读和理解。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值