Limit different bandwidth in day and night for different users
First of all: Please do have patience for a few days until this is finished, my time is limited, like yours. You have been warned.
Limit Different Bandwidth In Day and Night.
There was an example earlier, about different bandwidth allowed for users at different times.
Let's say you have corporate users / institutions / government. People that arrive at 07.00 and leave the office 18.00 at most. You reserve them 1 mbit/s all the time. Most of your home users are using maximum bandwidth after 15.00 and up to 01.00 hours. So, you decide you may "lend" some of the bandwidth of the users that are not working, while they are not... How ?
You can of course add 2 ( two ) queues for each limit you want to put, but you can also put a single queue, and modify it's limits from a script. Might just be simpler. Why ? You keep the limits for different type of users in a single place.
Ok. Now, for this to work, first of all sync your clock. Or you might get strange results and complains. :)
1. Premises: You are using simple queues to limit the traffic. ( it can be adapted to queue tree, by modifying limits in the queue types.... but that's another story )
You have 2 types of users:
- 512k/512k at day, 2M/2M at night
- 1M/1M at day, 4M/4M at night
How do we do it?
- Put simple queues with established limits, and distinctive name for each category of users. ( eg. ""Vasile_CAT1"", ""Vasile2_CAT2"", etc. [CAT1, CAT2 will be the category identifiers]
- Establish limits for each category: CAT1, CAT2, etc., we will modify this from the 2 scripts that handle everything.
- Put the script to run from the scheduler every 24 hours, and modify limits for day/night, reg. each category of users. The script for the "day" starts 06.00 hours, and ends 18.00 hours, when the script for the "night" starts, enabling the night modifications.
Detailed explanations follow
Setup NTP Client
If this is not done and your clock is out of sync, you might get strange results.
/system ntp client set enabled=yes mode=unicast primary-ntp=213.239.154.12 secondary-ntp=213.249.66.35
( You can put primary-ntp and secondary-npt to be resolved to whatever 0.europe.pool.ntp.org and 1.europe.pool.ntp.org is pointing to. Please replace "europe" with your continent, for further improvement on response times and proximity. See ntp.org for further information )
Setup four queues ( for this example only. you can setup as many as you like, it does not matter )
/queue simple
add comment="George of the jungle" direction=both disabled=no dst-address=192.168.4.15/32 \
max-limit=512000/512000 name="George_CAT1" parent=none priority=8 \
queue=default-small/default-small
add comment="Robinson" direction=both disabled=no dst-address=192.168.4.16/32 \
max-limit=512000/512000 name="Robinson_CAT1" parent=none priority=8 \
queue=default-small/default-small
add comment="Crusoe" direction=both disabled=no dst-address=192.168.4.17/32 \
max-limit=512000/512000 name="Crusoe_CAT2" parent=none priority=8 \
queue=default-small/default-small
add comment="Momma" direction=both disabled=no dst-address=192.168.4.16/32 \
max-limit=512000/512000 name="Momma_CAT3" parent=none priority=8 \
queue=default-small/default-small