0

Set Simple Queue Burst Rates

by Jim Bouse 30. September 2012 19:56

I have a Mikrotik router as my bandwidth limiter for my ISP.  I use Simple Queues for each IP to assign them to a speed.  I recently decided to be nice and add bursting to the plans.  I decided that the customers would get 2X their purchased speed for 16 seconds (a standard time window).  Since I had about 100 IPs and Simple Queues, I defanately did not want to manually add bursting to my Simple Queues.  I wrote the following script.  It will loop through all your simple queues and add the 2X burst amount.

You can download the .txt here in case the formatting gets screwed up. - setSimpleQueueBurst.txt (1.46 kb)

:local rate
:local inboundrate
:local outboundrate
:local inboundburstrate
:local outboundburstrate
:local inboundburstthreshold
:local outboundburstthreshold
:local ip
 
/queue simple
:foreach i in=[find] do={
  :set ip [get $i target-addresses]
  :set rate [get $i max-limit]
  :set inboundrate [:pick $rate ([:find $rate "/"]+1) 999 ]
  :if ([:find [:tostr $inboundrate] "k" ] > 0) do={
    :set inboundrate ([:pick $inboundrate 0 [:find [:tostr $inboundrate] "k" ]]*1000)
  }
  :if ([:find [:tostr $inboundrate] "M" ] > 0) do={
    :set inboundrate ([:pick $inboundrate 0 [:find [:tostr $inboundrate] "M" ]]*1000000)
  }
  :set outboundrate [:pick $rate 0 ([:find $rate "/"]+1)]
  :if ([:find [:tostr $outboundrate] "k" ] > 0) do={
    :set outboundrate ([:pick $outboundrate 0 [:find [:tostr $outboundrate] "k" ]]*1000)
  }
  :if ([:find [:tostr $outboundrate] "M" ] > 0) do={
    :set outboundrate ([:pick $outboundrate 0 [:find [:tostr $outboundrate] "M" ]]*1000000)
  }
  :set inboundburstrate ($inboundrate*2)
  :set outboundburstrate ($outboundrate*2)
  :set outboundburstthreshold ($outboundrate*2)
  :set inboundburstthreshold ($inboundrate*2)
  :set inboundrate ($inboundrate/5)
  :set outboundrate ($outboundrate/5)
  
  set $i limit-at="$outboundrate/$inboundrate" burst-time="16s/16s" burst-threshold="$outboundburstthreshold/$inboundburstthreshold" burst-limit="$outboundburstrate/$inboundburstrate"
  :put "Set $ip simple queue burst."
 
}

Tags: , ,

Mikrotik | WISP

Powered by BlogEngine.NET 2.5.0.6
Original Design by Laptop Geek, Adapted by onesoft