//update queue if active user have one
if ($id = array_search($arr['user'], $qu)) {
$API->comm('/queue/simple/set', array (
".id" => $id,
"max-limit" => $rate,
"limit-at" => $rate
));
echo $arr['user'].' editied <br>';
//if active user don't have queue
}else{
$API-> comm('/queue/simple/add', array (
"name" => $arr['user'],
"max-limit" => $rate,
"limit-at" => $rate,
"target-addresses" => $arr['address']
));
echo $arr['user'].': '.$arr['address'].' added <br>';
}}
//if queue don't have active user
foreach($qu as $qid => $qname){
if(in_array($qname, $au) != 1){
$API->comm('/queue/simple/remove', array (
".id" => $qid
));
echo $qname.' removed <br>';
}
}
I cant convert it to RouterOS script
now can any one help me to do the same code in (Hotspot user profile)
1- on login script
calculate the speed as i did update existing queue and add queue for the new user who have login
2- on logout script
calculate the speed as i did delete the queue for the user who have logout and update the other queue
pls help me I tried a lot put i did not understand RouterOS script i’m good at php only
my script now run on a computer and its check every 2 minute and i know this is not good
I believe you’re approaching this the wrong way… what you want to achieve could be done without any kind of scripting.
Just make all your user queues a children of a single parent queue. The parent queue will contain the max speed (max-limit) that your ISP has given you, and then in further child queues, you can specify the max speed for each user. Once you have that set up, RouterOS will automatically reduce the speed of users to which it can’t deliver max speed. You can also guarantee minimum speeds by adjusting the limit-at values of all children upon registration of new users only.
You can always specify the max-limit of the children to unlimited if you want to allow full use of your ISP’s speed whenever possible.
This is what simple queues were designed for, and if you use them properly like that, you’ll significantly improve your network’s performance.
P.S. If you look at the rest of my posts, you’ll notice most of the time I deal with PHP issues and/or advise people to use PHP as a possible solution… so when even I say “don’t use PHP for that”, this should tell you how bad of an idea this is .
really so this will work and divide the speed equally between active users on the hotspot ???
there was a method on the wiki Equal bandwidth sharing and i think it use the way you say but the problem was when any one start to use IDM (internet download manger) he will get the hole speed of my network
The method I just described should work… it certainly does on my network (minus the hotspot, but the principle is the same anyway). The only “trick” is to make sure the speeds of your ISP are real, because RouterOS can’t just “make up” for the difference.
If your ISP says “you have guaranteed speed of X” as opposed to “you have max speed of X” (implied being “not guaranteed”), you should specify the guaranteed speed as the limit-at of the parent, and the max speed as the max-limit. To ensure flawless working, you should close down your network for a minute, go from a computer (that’s very close to the router or perhaps a computer in place of the router) to a site like speedtest.net, perform a test with a server that’s close by, and use the values you get from the test as your parent queue’s max-limit values. That way, even if your ISP is (let’s face it) lying to you, your network will be OK.