I created this script to automatically change users bandwith from 2Mbps to 64k via simple queues after they download/upload 20Megabytes of data on the internet.
:local traf;
/queue simple
:for i from=192 to=206 do={ :if ([/queue simple find target=("192.168.4." . $i . "/24")] != "") do={ :set $traf [get [find target=("192.168.4." . $i . "/24")] bytes]; :if ($traf > 20971520) do={ set [find target=("192.168.4." . $i . "/24")] max-limit= 32000/64000
}
}
}
I marked connection and packet for each user to create individual queues.
Then I added a scheduler to run script every 5 minutes.
Script get run with now error, but it does nothing.
Maybe is a queue issue?
Thanks
I think you want to apply each queue to each host, if that’s the case you shouldn’t use /24 with the target but /32:
:local traf;
/queue simple
:for i from=192 to=206 do={ :if ([/queue simple find target=("192.168.4." . $i . "/32")] != "") do={ :set $traf [get [find target=("192.168.4." . $i . "/32")] bytes]; :if ($traf > 20971520) do={ set [find target=("192.168.4." . $i . "/32")] max-limit= 32000/64000
}
}
}
Do I need to specify ip address for each client?
/queue simple print
3 name="device1" target=192.168.4.199/32 parent=none
packet-marks=device1_pck_mark priority=8/8
queue=default-small/default-small limit-at=0/0 max-limit=256k/2M
burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s
At the moment clients get address via DHCP, should I set to static? Or create an address list to set in target of simple queue?
anyway your code has no sense.
you ask to find a target alreay specified
what are you trying to achieve?
Every user connects to Ap and get Ip via DHCP.
Each of them got a default bandwith of 256k/2M.
If they download or upload e.g. 20Megabytes of data the script should search simple queues for that value and changes bandwith from 256k/2M to 32k/64k.
I hope I was clear
Then you need to use each IP as target of the simple queues.
regarding your problem, you can approach it in two ways:
- Yours: i.e. set a simple queue per each user, then penalty speed of those “hungry” users.
A better one: use queue tree and by using PCQ let the system auto-adjust for fair-share allocation of all available bandwidth. That way maybe if your most hungry users happen to be few, You just make sure that all users will get a fair share in a given moment, if most of yours users aren’t very demanding but sporadically, everything will blend rather well.
With simple queues it could happen that hungry users are limited per having download their 20Mb while the internet line is idling as the rest of users aren’t demanding it… why do not try to make as much as yours users as possible? You are going to pay the same to your ISP anyway…
how can I use ip address in target of simple queues if clients get ip via DHCP?
I have to make a list of ip addresses? Then set that list as target?
I assume you’re making static leases so that each customer gets the same ip, yes using lists for example.