Community discussions

MikroTik App
 
KarmaHunter
just joined
Topic Author
Posts: 8
Joined: Tue Mar 20, 2018 8:29 pm

Simple Queues: slow down after x amount of Total Downloaded Bytes

Thu Aug 24, 2023 9:52 pm

Hello all.

I'm fairly new to Mikrotik and wondering if a solution to my problem can be achieved.

Situation:
1) People are given a static IP under DHCP server > Leases according to their router's MAC.
2) Simple Queues (no parent) is set up to each static IP and granted 10Mbps down/2Mbps up to each IP.
3) Simple queues is doing it's job well, limiting all IPs to their assigned Max Limits.

How can I limit the download speed of an individual static IP to 5Mbps if that IP under Simple Queues reaches over 500MB in Total Downloaded Bytes and then reset it back to their assigned 10Mbps at midnight?

Thanks in advance.
 
KarmaHunter
just joined
Topic Author
Posts: 8
Joined: Tue Mar 20, 2018 8:29 pm

Re: Simple Queues: slow down after x amount of Total Downloaded Bytes

Sat Aug 26, 2023 7:31 pm

So I took a script from the forum, analized it and modified it to my needs and couldn't make it work. Then, I found out why:

Under Simple Queues, EACH static IP queue type is using "default-small" under Advanced.

In Total > Total Queue Type, was using "default-small", but Total Statistics was all 0 "zeros". Once I changed the "Total Queue Type" to "default", Total Statistics started to come to life and "total-bytes" in the script worked. Sometimes we overlook the simplest things. I think it goes straight to "default-small" when adding simple queues.

Here's the working script:

/queue simple
:local totb;
:for r from= 2 to= 254 do= {
:if ([find target="192.168.1.".$r."/32"] != "") do= {
:set $totb [get [find target="192.168.1.".$r."/32"] total-bytes]
:if ($totb > 500000000) do= {
:log info ("Found heavy user 192.168.1.".$r)
:log info $totb
set max-limit= "1M/5M" [find target="192.168.1".$r."/32"]
} else={
:log info ("End of sweep")
}

As I mentioned in my previous post, I'm fairly new to rOS and surely a newbie for scripting but I'm proud to achieve a solution. I wanted a script to check only downloaded bytes originally but since my provider checks my total combined transfer, I reckon I should do the same in the script thus making it simpler.

Perhaps another newbie can benefit from this post and script :)

Thanks to all.

Who is online

Users browsing this forum: No registered users and 4 guests