I have a hotspot that uses Queue trees. Users are allowed to reach 3Mbps up/down.
I am trying to create a script that monitors the all active users and their bytes-out i.e downloaded bytes for each active user.
If any user exceeds 1GB, the script should:
1: Extract the IP address of that user
2: Create a simple queue and throttle that user to 512kbps for 24hrs.
3: After 24hrs, the speed is restored to the normal 3Mbps.
So far i have this:
:global mytraffic
:for i from=1 to=254 do={
:set mytraffic ([ip hotspot active get [find address =(“172.16.0”.$i)]]->“bytes-out”)
:if ($mytraffic >1000000000) do={
:set [/queue simple
I am stuck at this point.
I would really appreciate it if someone could guide me beyond this point. I am still learning how to write scripts on the Mikrotik platform.
Thanks for replying Jarda…I am trying to implement a kind of Fair Usage Policy (FUP) using this script…
I am trying to learn how to script and I thought this would be a nice project to assist me in doing so as well as learn from others.
A silly question that might also sort of help you go in the right direction…
Isn’t having a single simple queue stop the queue tree entirely? Can’t you add something akin to a “profile” in the queue tree, and then switch the address lists when the user’s time comes? I haven’t used queue trees, so I’m not sure exactly how this would go though… With simple queues, there’s “packet mark” matches.
Whether you’re using simple queues or a queue tree, you’re defining rules that say “if a packet matches this, enter it in this queue, and any packets in that queue small be sent/received at the specified rate”.
What I’m saying is that you add an additional such rule… Which would initially not affect a single person (if done right).
Then, using other means (e.g. the firewall) at the right time for that particular user, change the particular user, so that it fits the new rule, but doesn’t fit the old one. That way, that new user would have their new speeds.
Exactly how do you do the queue tree I don’t know though.