Manual:HTB-Token Bucket Algorithm: Difference between revisions
Created page with "==Overview== More info to come... 800px" |
No edit summary |
||
Line 1: | Line 1: | ||
{{Versions|v6.33+ }} | |||
==Overview== | ==Overview== | ||
This part of the wiki will concentrate on "Token Bucket" part of '''Hierarchical Token Bucket'''(HTB) - an algorithm inside the single queue. | |||
"Hierarchical" part of '''Hierarchical Token Bucket'''(HTB) queuing method are covered here: | |||
http://wiki.mikrotik.com/wiki/Manual:HTB | |||
==Token Bucket algorithm (Red part of Diagram)== | |||
The Token Bucket algorithm is based on an analogy to a bucket where tokens, representing in bytes, are added at specific rate. | |||
The bucket itself has a specified capacity. | |||
Queue gets tokens from parent queue, at a rate determined by parent queue. | |||
If the bucket fills to capacity, newly arriving tokens are dropped | |||
'''Bucket capacity = bucket-size * max-limit ''' | |||
*'''bucket size''' (0..10, Default:0.1) - queue option added in RouterOS v6.35, before that it had value ""0.1" that was impossible to change. | |||
Before letting any packet pass through queue, the bucket is inspected to see if it contains sufficient tokens at that moment. | |||
If, yes, the appropriate number of tokens, are removed ("cashed in") and packet can pass the queue. | |||
If, no, packets stays in the beginning of packet waiting queue until the appropriate amount of tokens are available. | |||
==Packet queue (Blue part of Diagram)== | |||
Size of this packet queue,sequence how packets are added to this queue, and when packets are discarded, are determined by: | |||
*'''queue-type''' - http://wiki.mikrotik.com/wiki/Manual:Queue#Kinds | |||
*'''queue-size''' - http://wiki.mikrotik.com/wiki/Manual:Queue_Size | |||
==Token rate selection (Black part of Diagram)== | |||
Maximal token rate at any given time is equal to highest active of these values: | |||
* '''limit-at''' (''NUMBER/NUMBER'') : normal upload/download data rate that is guaranteed to a target | |||
* '''max-limit''' (''NUMBER/NUMBER'') : maximal upload/download data rate that is allowed for a target to reach {{{...|to reach what}}} | |||
* '''burst-limit''' (''NUMBER/NUMBER'') : maximal upload/download data rate which can be reached while the burst is active | |||
'''burst-limit''' is active only when burst is in allowed state - mere info here: http://wiki.mikrotik.com/index.php?title=Manual:Queues_-_Burst | |||
In case '''limit-at''' was highest "Extra tokens" are issued to bypass parent queue '''max-limit''' limitation. | |||
==Diagram== | |||
[[File:bucket_size.png|800px]] | [[File:bucket_size.png|800px]] |
Revision as of 13:50, 10 May 2016
Applies to RouterOS: v6.33+
Overview
This part of the wiki will concentrate on "Token Bucket" part of Hierarchical Token Bucket(HTB) - an algorithm inside the single queue. "Hierarchical" part of Hierarchical Token Bucket(HTB) queuing method are covered here: http://wiki.mikrotik.com/wiki/Manual:HTB
Token Bucket algorithm (Red part of Diagram)
The Token Bucket algorithm is based on an analogy to a bucket where tokens, representing in bytes, are added at specific rate. The bucket itself has a specified capacity.
Queue gets tokens from parent queue, at a rate determined by parent queue.
If the bucket fills to capacity, newly arriving tokens are dropped
Bucket capacity = bucket-size * max-limit
- bucket size (0..10, Default:0.1) - queue option added in RouterOS v6.35, before that it had value ""0.1" that was impossible to change.
Before letting any packet pass through queue, the bucket is inspected to see if it contains sufficient tokens at that moment.
If, yes, the appropriate number of tokens, are removed ("cashed in") and packet can pass the queue.
If, no, packets stays in the beginning of packet waiting queue until the appropriate amount of tokens are available.
Packet queue (Blue part of Diagram)
Size of this packet queue,sequence how packets are added to this queue, and when packets are discarded, are determined by:
- queue-type - http://wiki.mikrotik.com/wiki/Manual:Queue#Kinds
- queue-size - http://wiki.mikrotik.com/wiki/Manual:Queue_Size
Token rate selection (Black part of Diagram)
Maximal token rate at any given time is equal to highest active of these values:
- limit-at (NUMBER/NUMBER) : normal upload/download data rate that is guaranteed to a target
- max-limit (NUMBER/NUMBER) : maximal upload/download data rate that is allowed for a target to reach to reach what
- burst-limit (NUMBER/NUMBER) : maximal upload/download data rate which can be reached while the burst is active
burst-limit is active only when burst is in allowed state - mere info here: http://wiki.mikrotik.com/index.php?title=Manual:Queues_-_Burst
In case limit-at was highest "Extra tokens" are issued to bypass parent queue max-limit limitation.