Page 1 of 1

Day/Night Bandwidth Configure in User Manager

Posted: Thu Jan 16, 2014 9:23 am
by mmshasan
I'm using PPPoE with MkT User Manager and want to configure time based bandwidth (day/night). Here's what I did....

1. Created a Profile
2. Added two limitation based on time
a) 256k - 00:00:00 - 12:59:59
b) 512k - 13:00:00 - 23:59:59
3. Created an user and associated with above mentioned profile.

But it didn't work out. I had to disconnect and then reconnect the PPPoE to get 512k. Any idea why ?

Please help. Thanks in advance.

Re: Day/Night Bandwidth Configure in User Manager

Posted: Mon Feb 17, 2014 6:17 am
by rickfrey
Because the RADIUS token had already been validated. You might want to try using scheduler to script this process.

Re: Day/Night Bandwidth Configure in User Manager

Posted: Thu Feb 20, 2014 5:34 am
by aacable
COA messages are not supported by PPPoE at MikroTik RouterOS.
Only DM messages are supported for PPPoE.
(Change on the fly is supported in HOTSPOT however)

You can use following script and schedule it to run two times at 00:00:00 & 13:00:00
It will disconnect all active users and when they will reconnect, they will get new profile speed.
# Print local time for LOG record purposes / tracking
:local CurrentTime [/system clock get time];
:log warning "Script Start to Disconnect all active PPPoE Users for new profile speed at $CurrentTime. . ."
# Disconnect users using find command
/ppp active remove [find service="pppoe"]
:log warning "PPPoE Users disconnection script completed at  $CurrentTime. . ."
You can also use another work around for this purpose.
Create a script that runs at specific time and remove all active queues, and create new queues per ip with new bandwidth allocation, this way you dont have to disconnect users, and still be able to use new bandwidth plan.
Something like ...


OR
create a PCQ base queue and move it on TOP and disable it. now schedule a script that runs at specific timings and enable it, this way it will get preference and will distribute the assigned bandwidth.

Re: Day/Night Bandwidth Configure in User Manager

Posted: Thu Feb 20, 2014 6:18 am
by rickfrey
I like that Syed, thanks :D

Re: Day/Night Bandwidth Configure in User Manager

Posted: Mon May 26, 2014 3:40 pm
by dunga
I'm using PPPoE with MkT User Manager and want to configure time based bandwidth (day/night). Here's what I did....

1. Created a Profile
2. Added two limitation based on time
a) 256k - 00:00:00 - 12:59:59
b) 512k - 13:00:00 - 23:59:59
3. Created an user and associated with above mentioned profile.

But it didn't work out. I had to disconnect and then reconnect the PPPoE to get 512k. Any idea why ?

Please help. Thanks in advance.
Any idea on how to set this using hotspot.

I have a similar setup where, i want users/client to use 256k/256k from 7:00am - 12:59am
while 512k/512k from 01:00am - 06:00am.

Using user-manager.

Thanks for your help

Re: Day/Night Bandwidth Configure in User Manager

Posted: Tue Feb 24, 2015 9:29 pm
by 3l1t3p0is0n
how to give pppoe client on day 128k/384k and night on 128k/512k how can i do it i mean script i'm not using user manager

i mean script and scheduler

Re: Day/Night Bandwidth Configure in User Manager

Posted: Fri Feb 27, 2015 5:07 pm
by Aveline
Thanks for support!

Re: Day/Night Bandwidth Configure in User Manager

Posted: Thu Apr 16, 2015 12:50 pm
by stlony
Hi :)
I was having a problem for such tasks with (PPOE/Hotspot/User manager) but I had created a very useful script to pass this problem. my case was deferent than yours so I will not post my exact script but I will mention the general idea for it.

by executing conditional [IF] command in the script to select whether first order (in Day time) or second order (in Night time) from the script will be run, depending on the current hour.

then changing all the users in the Queues list to the speed 128k/384k if it Day or change them all it to 128k/512k night and run this script every minute for example. this will applied without even disconnecting the users. (applied with dynamic and static queues entries)

by this way you don't need to make two profiles in Usermanger just one speed and the script will complete the job.

Re: Day/Night Bandwidth Configure in User Manager

Posted: Mon Apr 20, 2015 5:31 pm
by hossain2004a
Hi :)
I was having a problem for such tasks with (PPOE/Hotspot/User manager) but I had created a very useful script to pass this problem. my case was deferent than yours so I will not post my exact script but I will mention the general idea for it.

by executing conditional [IF] command in the script to select whether first order (in Day time) or second order (in Night time) from the script will be run, depending on the current hour.

then changing all the users in the Queues list to the speed 128k/384k if it Day or change them all it to 128k/512k night and run this script every minute for example. this will applied without even disconnecting the users. (applied with dynamic and static queues entries)

by this way you don't need to make two profiles in Usermanger just one speed and the script will complete the job.
Can ya share your script??? 8)

Re: Day/Night Bandwidth Configure in User Manager

Posted: Wed Apr 29, 2015 3:53 pm
by stlony
Hi :)
I was having a problem for such tasks with (PPOE/Hotspot/User manager) but I had created a very useful script to pass this problem. my case was deferent than yours so I will not post my exact script but I will mention the general idea for it.

by executing conditional [IF] command in the script to select whether first order (in Day time) or second order (in Night time) from the script will be run, depending on the current hour.

then changing all the users in the Queues list to the speed 128k/384k if it Day or change them all it to 128k/512k night and run this script every minute for example. this will applied without even disconnecting the users. (applied with dynamic and static queues entries)

by this way you don't need to make two profiles in Usermanger just one speed and the script will complete the job.
Can ya share your script??? 8)

Sure Hossain you welcome

before I post my script here is my case to help anyone understanding what going on this long script :D

- I am working with usermanager broadband I have two profiles there 620kb & 615kb (it is just a names to deferent type of paid users). I give every user comment in his user manger account (like: 620kb@wi-fi.com)
- users connect with me by PPPOE and PPTP (for android users) so the script deals with the two type
- This script put all user queues in one parent queue and gives to every user queues the priority he deserve depending on how many MB he used during each day, starting from 12 AM (all queues are dynamic). (To give them a kind of Fair Using Policy)

for example:
less than 200MB then his queue priority will be 1
from 200MB to 400MB his queue priority will be 2

and so on until he reach to priority 8 his speed will be dropped from 680kb to 400kb

Then it reset the user manager counters and reverse any limited users speed from 400kb to 680kb at 12 AM every day depending on a condition in the script which is "date changed" (and this to always start the reset process even if its time passed while the server is off for any reason)

I schedule run this script every 30 seconds it working perfectly since 4 months as I remember.

Finally here it is.
# Putting All Users Queues in Main Parent
/queue simple
:foreach i in=[find] do={
:if ([/queue simple get $i name] !="Cache-Pass-Fast") do={
:if ([/queue simple get $i name] !="Total_Parent") do={
:if ([/queue simple get $i name] !="hs-<hotspot1>") do={
:if ([/queue simple get $i parent] ="none") do={
/queue simple set $i parent=Total_Parent}
}}}}


:global Prior
:global UserNa
/tool user-manager user
:foreach i in=[find] do={

# Getting 615kb Profile Users Usage During the day
:if ([/tool user-manager user get $i email] ="615kb@wi-fi.com") do={

# Getting Users Less Than 200MB In Day
:if ([/tool user-manager user get $i download-used] <209715200) do={ :set Prior 1/1
:set UserNa [/tool user-manager user get $i name] ;
}

# Getting Users More Than 200MB Less Than 400MB In Day
:if ([/tool user-manager user get $i download-used] >209715200) do={ 
:if ([/tool user-manager user get $i download-used] <419430400) do={ :set Prior 2/2
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 400MB Less Than 600MB In Day
:if ([/tool user-manager user get $i download-used] >419430400) do={ 
:if ([/tool user-manager user get $i download-used] <629145600) do={ :set Prior 3/3
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 600MB Less Than 800MB In Day
:if ([/tool user-manager user get $i download-used] >629145600) do={ 
:if ([/tool user-manager user get $i download-used] <838860800) do={ :set Prior 4/4
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 800MB Less Than 1000MB In Day
:if ([/tool user-manager user get $i download-used] >838860800) do={ 
:if ([/tool user-manager user get $i download-used] <1048576000) do={ :set Prior 5/5
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 1000MB Less Than 1200MB In Day
:if ([/tool user-manager user get $i download-used] >1048576000) do={ 
:if ([/tool user-manager user get $i download-used] <1258291200) do={ :set Prior 6/6
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 1200MB Less Than 1400MB In Day
:if ([/tool user-manager user get $i download-used] >1258291200) do={ 
:if ([/tool user-manager user get $i download-used] <1468006400) do={ :set Prior 7/7
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 1400MB Less Than 1600MB In Day
:if ([/tool user-manager user get $i download-used] >1468006400) do={ 
:if ([/tool user-manager user get $i download-used] <1677721600) do={ :set Prior 8/8
:set UserNa [/tool user-manager user get $i name] ;
}}
}


# Getting 620kb Profile Users Usage During the day
:if ([/tool user-manager user get $i email] ="620kb@wi-fi.com") do={

# Getting Users Less Than 300MB In Day
:if ([/tool user-manager user get $i download-used] <314572800) do={ :set Prior 1/1
:set UserNa [/tool user-manager user get $i name] ;
}

# Getting Users More Than 300MB Less Than 600MB In Day
:if ([/tool user-manager user get $i download-used] >314572800) do={ 
:if ([/tool user-manager user get $i download-used] <629145600) do={ :set Prior 2/2
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 600MB Less Than 900MB In Day
:if ([/tool user-manager user get $i download-used] >629145600) do={ 
:if ([/tool user-manager user get $i download-used] <943718400) do={ :set Prior 3/3
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 900MB Less Than 1200MB In Day
:if ([/tool user-manager user get $i download-used] >943718400) do={ 
:if ([/tool user-manager user get $i download-used] <1258291200) do={ :set Prior 4/4
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 1200MB Less Than 1500MB In Day
:if ([/tool user-manager user get $i download-used] >1258291200) do={ 
:if ([/tool user-manager user get $i download-used] <1572864000) do={ :set Prior 5/5
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 1500MB Less Than 1800MB In Day
:if ([/tool user-manager user get $i download-used] >1572864000) do={ 
:if ([/tool user-manager user get $i download-used] <1887436800) do={ :set Prior 6/6
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 1800MB Less Than 2100MB In Day
:if ([/tool user-manager user get $i download-used] >1887436800) do={ 
:if ([/tool user-manager user get $i download-used] <2202009600) do={ :set Prior 7/7
:set UserNa [/tool user-manager user get $i name] ;
}}

# Getting Users More Than 2100MB Less Than 2400MB In Day
:if ([/tool user-manager user get $i download-used] >2202009600) do={ 
:if ([/tool user-manager user get $i download-used] <2516582400) do={ :set Prior 8/8
:set UserNa [/tool user-manager user get $i name] ;
}}
}


/queue simple
:foreach i in=[find] do={
:global QueueName
:global DelCharc
:global PureName
:global NetName
:set QueueName [/queue simple get $i name]
:set DelCharc [:pick $QueueName 0 7]

# In ppoe Connections Type
:if ($DelCharc ="<pppoe-") do={
:set PureName [:pick $QueueName 7 80]

:if ([:pick $PureName 0 4] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 5] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 6] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 7] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 8] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 9] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 10] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 11] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 12] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 13] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 14] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 15] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 16] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 17] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 18] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 19] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 20] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 21] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
}

# In pptp Connections Type
:set PureName [:pick $QueueName 6 80]

:if ([:pick $PureName 0 4] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 5] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 6] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 7] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 8] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 9] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 10] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 11] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 12] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 13] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 14] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 15] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 16] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 17] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 18] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 19] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 20] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
:if ([:pick $PureName 0 21] = $UserNa) do={ 
:if ([/queue simple get $i priority] != $Prior) do={ /queue simple set $i priority= $Prior}}
}}

# Down Priority 8 users to 400k Speed Limit
/queue simple
:foreach i in=[find] do={
:if ([/queue simple get $i parent] = "Total_Parent") do={
:if ([/queue simple get $i priority] = "8/8") do={ /queue simple set $i limit-at=2M/400k
/queue simple set $i max-limit=2M/400k}}}


# Safe Mode Starting the Resetting Users Counters
:global currentdate
:global saveddate
:set currentdate [/system clock get date]
:set saveddate [/file get RaduisResetLast.txt contents]
:if ($currentdate!=$saveddate) do={
/tool user-manager user
:foreach i in=[find] do={
/tool user-manager user reset-counters $i}

# Reset Limited users speed to normal Speed
/queue simple
:foreach i in=[find] do={
:if ([/queue simple get $i limit-at] = "2M/400k") do={ /queue simple set $i max-limit=2M/680k
/queue simple set $i limit-at=2M/680k}}

# For Resetting Users Counters Starter
:global scriptname
:global lasttimestrarted
:global lastdatestrarted
/system script
:foreach i in=[find] do={
:set scriptname [get $i name]
:if ($scriptname="Fair_Usage_Policy") do={ 
:set lasttimestrarted [get $i last-started]
:set lastdatestrarted [:pick $lasttimestrarted 0 11]
/file set RaduisResetLast.txt content="$lastdatestrarted"}
}
:log info "Users Counters had been reseted"}
to make it easier on the post owner what really help him in his case is this part
/queue simple
:foreach i in=[find] do={
:if ([/queue simple get $i limit-at] = "2M/400k") do={ /queue simple set $i max-limit=2M/680k
/queue simple set $i limit-at=2M/680k}}
This how I can change the speed for users without even disconnect them (while the Queues entries is dynamic too)

If anyone find it helpful don't forget to support this reply as a positive reply