From wiki.mikrotik.com
Theory
Structure
Hierarchical Token Bucket (HTB) allows to create a hierarchical queue structure and determine relations between queues, like “parentchild” or “childchild”.As soon as queue has at least one child it becomes a inner queue, all queues without children  leaf queues. Leaf queues make actual traffic consumption, Inner queues are responsible only for traffic distribution. All leaf queues are treated on equal basis.
In RouterOS it is necessary to specify parent option to assign queue as a child to other queue
Dual Limitation
Each queue in HTB has two rate limits: CIR (Committed Information Rate) – (limitat in RouterOS) worst case scenario, flow will get this amount of traffic no matter what (assuming we can actually send so much data)
 MIR (Maximal Information Rate) – (maxlimit in RouterOS) best case scenario, rate that flow can get up to, if there queue’s parent has spare bandwidth
Note: CIR will be assigned to the corresponding queue no matter what. (even if maxlimit of the parent is exceeded)
That is why, to ensure optimal (as designed) usage of dual limitation feature, we suggest to stick to these rules:
 Sum of committed rates of all children must be less or equal to amount of traffic that is available to parent.

 CIR(parent)* ? CIR(child1) +…+ CIR(childN)
 *in case if parent is main parent CIR(parent)=MIR(parent)
 CIR(parent)* ? CIR(child1) +…+ CIR(childN)
 Maximal rate of any child must be less or equal to maximal rate of the parent

 MIR (parent) ? MIR(child1) & MIR (parent) ? MIR(child2) & … & MIR (parent) ? MIR(childN)
 0%  50% available traffic used  green
 51%  75% available traffic used  yellow
 76%  100% available traffic used  red
Priority
We already know that limitat (CIR) to all queues will be given out no matter what.Priority is responsible for distribution of remaining parent queues traffic to child queues so that they are able to reach maxlimit
Queue with higher priority will reach its maxlimit before the queue with lower priority. 8 is the lowest priority, 1 is the highest.
Make a note that priority only works:
 for leaf queues  priority in inner queue have no meaning.
 if maxlimit is specified (not 0)
In this section we will analyze HTB in action. To do that we will take one HTB structure and will try to cover all the possible situations and features, by changing the amount of incoming traffic that HTB have to recycle. and changing some options.
Structure
Our HTB structure will consist of 5 queues: Queue01 inner queue with two children  Queue02 and Queue03
 Queue02 inner queue with two children  Queue04 and Queue05
 Queue03 leaf queue
 Queue04 leaf queue
 Queue05 leaf queue
Example 1 : Usual case
 Queue01 limitat=0Mbps maxlimit=10Mbps
 Queue02 limitat=4Mbps maxlimit=10Mbps
 Queue03 limitat=6Mbps maxlimit=10Mbps priority=1
 Queue04 limitat=2Mbps maxlimit=10Mbps priority=3
 Queue05 limitat=2Mbps maxlimit=10Mbps priority=5
Result of Example 1
 Queue03 will receive 6Mbps
 Queue04 will receive 2Mbps
 Queue05 will receive 2Mbps
 Clarification: HTB was build in a way, that, by satisfying all limitats, main queue no longer have throughput to distribute
Example 2 : Usual case with maxlimit
 Queue01 limitat=0Mbps maxlimit=10Mbps
 Queue02 limitat=4Mbps maxlimit=10Mbps
 Queue03 limitat=2Mbps maxlimit=10Mbps priority=3
 Queue04 limitat=2Mbps maxlimit=10Mbps priority=1
 Queue05 limitat=2Mbps maxlimit=10Mbps priority=5
Result of Example 2
 Queue03 will receive 2Mbps
 Queue04 will receive 6Mbps
 Queue05 will receive 2Mbps
 Clarification: After satisfying all limitats HTB will give throughput to queue with highest priority.
Example 3 : Inner queue limitat
 Queue01 limitat=0Mbps maxlimit=10Mbps
 Queue02 limitat=8Mbps maxlimit=10Mbps
 Queue03 limitat=2Mbps maxlimit=10Mbps priority=1
 Queue04 limitat=2Mbps maxlimit=10Mbps priority=3
 Queue05 limitat=2Mbps maxlimit=10Mbps priority=5
Result of Example 3
 Queue03 will receive 2Mbps
 Queue04 will receive 6Mbps
 Queue05 will receive 2Mbps
 Clarification: After satisfying all limitats HTB will give throughput to queue with highest priority. But in this case inner queue Queue02 had limitat specified, by doing so, it reserved 8Mbps of throughput for queues Queue04 and Queue05. From these two Queue04 have highest priority, that is why it gets additional throughput.
Example 4 : Leaf queue limitat
 Queue01 limitat=0Mbps maxlimit=10Mbps
 Queue02 limitat=4Mbps maxlimit=10Mbps
 Queue03 limitat=6Mbps maxlimit=10Mbps priority=1
 Queue04 limitat=2Mbps maxlimit=10Mbps priority=3
 Queue05 limitat=12Mbps maxlimit=15Mbps priority=5
Result of Example 4
 Queue03 will receive ~3Mbps
 Queue04 will receive ~1Mbps
 Queue05 will receive ~6Mbps
 Clarification: Only by satisfying all limitats HTB was forced to allocate 20Mbps  6Mbps to Queue03, 2Mbps to Queue04, 12Mbps to Queue05, but our output interface is able to handle 10Mbps. As output interface queue is usually FIFO throughput allocation will keep ratio 6:2:12 or 3:1:6
Tidak ada komentar:
Posting Komentar