Manual:HTB-Token Bucket Algorithm: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:
http://wiki.mikrotik.com/wiki/Manual:HTB
http://wiki.mikrotik.com/wiki/Manual:HTB


==Token Bucket algorithm (Red part of Diagram)==
==Token Bucket algorithm (Red part of the diagram)==


The Token Bucket algorithm is based on an analogy to a bucket where tokens, represented in bytes, are added at specific rate.
The Token Bucket algorithm is based on an analogy to a bucket where tokens, represented in bytes, are added at specific rate.
Line 26: Line 26:
If, no, packets stays in the beginning of packet waiting queue until the appropriate amount of tokens are available.
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)==
==Packet queue (Blue part of the diagram)==


Size of this packet queue, sequence, how packets are added to this queue, and when packets are discarded, is determined by:
Size of this packet queue, sequence, how packets are added to this queue, and when packets are discarded, is determined by:
Line 33: Line 33:




==Token rate selection (Black part of Diagram)==
==Token rate selection (Black part the diagram)==


Maximal token rate at any given time is equal to highest active of these values:
Maximal token rate at any given time is equal to highest active of these values:
Line 45: Line 45:
In case '''limit-at''' was highest "Extra tokens" were issued to bypass parent queue '''max-limit''' limitation.
In case '''limit-at''' was highest "Extra tokens" were issued to bypass parent queue '''max-limit''' limitation.


==Diagram==
==The Diagram==


[[File:bucket_size.png|800px]]
[[File:bucket_size.png|800px]]

Revision as of 12:09, 10 May 2016

Version.png

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 is covered here: http://wiki.mikrotik.com/wiki/Manual:HTB

Token Bucket algorithm (Red part of the diagram)

The Token Bucket algorithm is based on an analogy to a bucket where tokens, represented 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 was hard-coded to "0.1".

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 the diagram)

Size of this packet queue, sequence, how packets are added to this queue, and when packets are discarded, is determined by:


Token rate selection (Black part the diagram)

Maximal token rate at any given time is equal to highest active of these values:

  • limit-at (NUMBER/NUMBER) : guaranteed upload/download data rate to a target
  • max-limit (NUMBER/NUMBER) : maximal upload/download data rate that is allowed for a target
  • burst-limit (NUMBER/NUMBER) : maximal upload/download data rate that is allowed for a target while the burst is active

burst-limit is active only when burst is in allowed state - more info here: http://wiki.mikrotik.com/index.php?title=Manual:Queues_-_Burst

In case limit-at was highest "Extra tokens" were issued to bypass parent queue max-limit limitation.

The Diagram

Bucket size.png