Community discussions

sergejs
MikroTik Support
Topic Author
Posts: 6615
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

### Queue bucket-size option explained

We have made documentation for the new Token Bucket option, it is new exciting and powerful feature for queues and bandwidth limitation. Detailed information and configuration example are here,
http://wiki.mikrotik.com/wiki/Manual:HT ... _Algorithm

Short diagram explaining Tocken Bucket algoritm,

nz_monkey
Forum Guru
Posts: 1810
Joined: Mon Jan 14, 2008 1:53 pm
Location: Straya
Contact:

### Re: Queue bucket-size option explained

Very interesting.

Thanks Mikrotik.
http://thebrotherswisp.com/ | Mikrotik MTCNA, MTCRE, MTCINE | Fortinet FTCNA, FCNSP, FCT | Extreme Networks ENA

macgaiver
Forum Guru
Posts: 1717
Joined: Wed May 18, 2005 5:57 pm
Location: Sol III, Sol system, Sector 001, Alpha Quadrant

### Re: Queue bucket-size option explained

After reading this i played around my test setup and realized that there setup "large parent queue bucket size, small child queue bucket size" are beneficial in situations when you have many child queue - now child queue that just started to use traffic in already saturated environment have much easier time to get initial traffic.

In short - queues got more responsive to usage changes, cause parent queue have an extra tokens for "unexpected expenses"

Also, i'm starting to thing old burst is starting to become redundant, this implementation with just one option is easier that old 3 option solution anyways.
With great knowledge comes great responsibility, because of ability to recognize id... incompetent people much faster.

freemannnn
Long time Member
Posts: 655
Joined: Sun Oct 13, 2013 7:29 pm

### Re: Queue bucket-size option explained

Large Queue Bucket
Lets try to apply the same logic to a situation when bucket-size is at its maximal value:

/queue tree
In this case bucket-size=10, so bucket-capacity= 10 x 10M = 100M

If the bucket is full (that is, client was not using full capacity of the queue for some time), the next 100Mb of traffic can pass through the queue at an unrestricted speed.

So you can have:

20Mbps transfer speed for 10s
60Mbps transfer burst for 2s
1Gbps transfer burst for approximately 100ms

i cant understand how seconds are calculated in the above example. why is 10s for 20mbps?
if 100mb traffic can pass through at an unrestricted speed, why is 20mbps for 10s?
is there an excel formula so we calculate easy how many mb or sec will be the burst result?

ZeroByte
Forum Guru
Posts: 4048
Joined: Wed May 11, 2011 6:08 pm

### Re: Queue bucket-size option explained

i cant understand how seconds are calculated in the above example. why is 10s for 20mbps?
if 100mb traffic can pass through at an unrestricted speed, why is 20mbps for 10s?
is there an excel formula so we calculate easy how many mb or sec will be the burst result?
Because in 10 seconds, you will have earned another 100M of tokens.

It only takes 5sec @ 20M/s to spend 100M of tokens....
BUT during that 5 sec, you also earned 50M more tokens....
That 50M takes 2.5 sec to spend, while earning another 25M of tokens...
etc...

If you want a formula, it's basically this:

Time to empty/full = absval(Bucket Size * Token Rate / (Data Rate - Token Rate))

Time means "fill from empty" if the data rate is below the token rate, and it means "empty from full" if data rate is greater than token rate.
If they're the same, it's divide by zero, so avoid that.

Obviously this formula assumes a silly thing - a constant data rate.

Ultimately, though, it's not right to think in those terms - data rates are almost never constant, and it's impossible to predict whether a stream will "save up" its tokens or use them constantly, etc.
When given a spoon,
you should not cling to your fork.
The soup will get cold.

wispwest
Member
Posts: 477
Joined: Tue May 19, 2009 3:48 am

### Re: Queue bucket-size option explained

We are using Simple Queues for each customer, some Mikrotiks have 400-500 of them. We enter the customer name, IP address, then select a PCQ on the advanced tab to select the Download/Upload rate, the PCQ's have a burst timer where they can for example go to 7Mb for 40 minutes, then drops to around 1/2 the burst rate, around 3-4Mb/s.

After upgrading firmware's we're noticing now the 'bucket size', which all are defaulted to 0.100, do we need to change anything to keep everything running 100% the same, or is 0.100 default not have any change on our existing setup?

Cha0s
Forum Veteran
Posts: 882
Joined: Tue Oct 11, 2005 4:53 pm

### Re: Queue bucket-size option explained

http://wiki.mikrotik.com/wiki/Manual:HT ... diagram.29
bucket size (0..10, Default:0.1) - queue option was added in RouterOS v6.35, before that it was hard-coded to a value of "0.1".
As shown in the documentation, prior to v6.35, it was hard-coded to 0.1.
So after upgrade it shouldn't behave differently since it keeps the default value: 0.1.

Note
newbie
Posts: 49
Joined: Fri Jun 03, 2016 12:39 pm

### Re: Queue bucket-size option explained

Can u plz give me an example on how to use it on an 20/1 adsl connection and setting max limit to 10 in 1 of 8 queues in simple queue? What numbers offers me what?

Note
newbie
Posts: 49
Joined: Fri Jun 03, 2016 12:39 pm

### Re: Queue bucket-size option explained

anyone not yet? good job.

I suspect that this feature is not working and u just shame to admit it. it is not bad if is not working. just someone write something, for us to stop waste our time.

damianivereigh
just joined
Posts: 11
Joined: Sun May 22, 2016 1:06 am

### Re: Queue bucket-size option explained

So given the above, if we want to have a setup with almost no burstiness (we have a downstream network that polices the traffic at 10ms intervals!), really I need the bucket size to be only big enough for one packet (1500 bytes). So at 100Mb would be a bucket size of 0.00012 (0.00012*10000000/8 = 1500). Pity you can't specify the size directly (in bytes).

Is that right?

damianivereigh
just joined
Posts: 11
Joined: Sun May 22, 2016 1:06 am

### Re: Queue bucket-size option explained

I have just realised what this parameter actually is. It is really "bucket-time" - the amount of time it will take to fill the bucket up from empty when there is no packet flow. The number of seconds of token flow (which is set by the max-limit/limit-at etc) that can be stored in there (after which the tokens overflow). It also appears to have a lower limit of 0.001 - i.e. 1ms, which is good enough for what we want.

omidkosari
Trainer
Posts: 613
Joined: Fri Sep 01, 2006 4:18 pm
Location: Iran , Karaj
Contact:

### Re: Queue bucket-size option explained

Is there any benefit playing with Queue bucket-size to overcome DOS/DDOS and queuing 100% cpu usage ? If yes how ?
MTCNA , MTCRE, MTCWE, Mikrotik Certified Trainer

JulieHardy
just joined
Posts: 3
Joined: Thu Jan 05, 2017 10:25 am

### Re: Queue bucket-size option explained

Time means "fill from empty" if the data rate is below the token rate, and it means "empty from full" if data rate is greater than token rate.

Note
newbie
Posts: 49
Joined: Fri Jun 03, 2016 12:39 pm

### Re: Queue bucket-size option explained

does bucket size work to unlimited queues? Or i have to set limits? if not, it will very good feature to work under unlimited queues........ i think.

set burst time only, unlimited the other values and borrow buckets from parent for ex.

does this work?

ajack46
newbie
Posts: 37
Joined: Tue Mar 28, 2017 9:08 am

### Re: Queue bucket-size option explained

does bucket size work to unlimited queues? Or i have to set limits? if not, it will very good feature to work under unlimited queues........ i think.

set burst time only, unlimited the other values and borrow buckets from parent for ex.

does this work?
Does not the diagram say it has a burst limit and a burst limit at max, meaning they are giving out a range. And not something unlimited?

darkbreaker
just joined
Posts: 3
Joined: Thu Sep 14, 2017 6:22 pm

### Re: Queue bucket-size option explained

Hi all!
I'm a newbie here, so I'll try to explain my problem in ROS therminology as close as I can. My problem is "a ghost" property of queue tree/simple queues. I actually spent 12+ hours yesterday reading WIKI, manual, example scripts etc. but I couldn't find a way to do a realy simple thing: how to set the "limit-at" value be higher then "max-limit" Can anybody here enlight me so I can say : hey, i'm stupid, because otherwise my so far good opinion of ROS programmers will be very degraded. This post here is mainly reason to join forum, and here is what I don't like: this pic below. In this algorthm, <limit-at token rate> will never be engaged , or I'm blind. You tell me...
``````[admin@GoranmarGW] > /queue tree add name=test_queue max-limit=10M limit-at=20M parent=global
failure: -max-limit less than -limit
``````
And Mikrotik says:
We have made documentation for the new Token Bucket option, it is new exciting and powerful feature for queues and bandwidth limitation. Detailed information and configuration example are here,
http://wiki.mikrotik.com/wiki/Manual:HT ... _Algorithm

Short diagram explaining Tocken Bucket algoritm,

Chupaka
Forum Guru
Posts: 8292
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

### Re: Queue bucket-size option explained

Indeed, looks like 'Limit-at larger than max-limit?' is always 'no'
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

strods
MikroTik Support
Posts: 1406
Joined: Wed Jul 16, 2014 7:22 am
Location: Riga, Latvia

### Re: Queue bucket-size option explained

Why do you want to set limit-at higher than max-limit?

Max limit - Max bandwidth client can use;
Limit at - Is the minimum bandwidth which should be available for client if there are multiple connections from different clients at the same time.

Chupaka
Forum Guru
Posts: 8292
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

### Re: Queue bucket-size option explained

But why is this case on the diagram then?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

darkbreaker
just joined
Posts: 3
Joined: Thu Sep 14, 2017 6:22 pm

### Re: Queue bucket-size option explained

Why do you want to set limit-at higher than max-limit?

Max limit - Max bandwidth client can use;
Limit at - Is the minimum bandwidth which should be available for client if there are multiple connections from different clients at the same time.
I dont ! My point is HUGE error in logic of the algorithm. But the irony is even better, since queues are behaving almost as digram shows. In my 10+ years experience with ROS, limit-at value never had definitive and predictable effect on queue beheviour. It seems that what ever I wanted to acomplish with queues, the best way was trial/error method, since documentation like this above is not of help. Sadly...

anav
Forum Guru
Posts: 2904
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada

### Re: Queue bucket-size option explained

Hi Dark breaker, imagine I cannot find clear basic descriptions of how to program simple queues, am not able to grasp Burst, through the available documentation and then I come across this thread TokenS. What is going to burst is my noggin LOL...... All to say is I echo your sentiments on the documentation being lacking. I know much of it is my lack of experience and knowledge but I can read..........
I'd rather manage rats than software. Follow my advice at your own risk! (Sob & mkx forced me to write that!)

blk2001
just joined
Posts: 6
Joined: Tue Mar 27, 2018 8:20 am

### Re: Queue bucket-size option explained

So i have a question here: how bucket size will affect on accuracy of guarantees (such as limit-at and priority) for flow control? Will a larger bucket size damage the guarantees for higher priority queue due to token buffering of lower priority queue? Consider this example:

There are two queues: one for VoIP which needs a constant rate 1M, second for others which has rate 0-9M, the total bandwidth is 10M (suppose upper ISP dosen't provide buffering or burst), here we only consider upload.

/queue tree