Community discussions

 
dnordenberg
just joined
Topic Author
Posts: 19
Joined: Wed Feb 24, 2016 8:00 pm

Queues and bandwidth sharing

Thu Jul 11, 2019 9:30 pm

Hi!

I have looked at queues to make bandwidth usage "fair" among a number of users. I looked at PCQ a bit and tried using https://wiki.mikrotik.com/wiki/Cable_setup guide but I don't think it fits my setup and what I want to do perfectly :(

First I have main router and on that I have a trunk port with 16 VLANs (16 different subnets, 192.168.101 to 116) that goes to a 24p VLAN switch. Then each of the 16 VLANs is assigned (and untagged) to a port which then goes out to a apartment. That is one apartment = one VLAN = one subnet in the router :)

Now I want to share the bandwidth fair and equal between the apartments.
In the best scenario if three computers in one apartment downloads, their speed would be trimmed to ~17mbit each and another user in another apartment then gets his speed trimmed to 50mbit. That is both apartments get ~50mbit each if the WAN is at 100mbit. If more apartments is using the WAN they should all be getting a equal slice of available bandwidth. Like if 10 apartments using the WAN and tries to download at high speeds they should get ~10mbit each.
What I really want to accomplish here is that people that uses high bandwidth should not be able to make for example streaming a movie a bad experience for a user in another apartment.
And I don't want to hard limit the bandwidth to 100/16=6,25mbit for each apartment :(

Is this possible to do?

Kind regards
David
 
HzMeister
Frequent Visitor
Frequent Visitor
Posts: 67
Joined: Sun Jan 28, 2018 9:48 pm

Re: Queues and bandwidth sharing

Thu Jul 11, 2019 10:07 pm

Yeah it's pretty easy to do.
Mark each subnet (with separate packet marks for upload and download) in mangle. You could mark connections before packet marking like a lot of guides recommend, but I don't since I've found it unnecessary and if you're not maxing out the cpu.
Ex:
/ip firewall mangle
add action=mark-packet chain=forward comment=subnet101-down dst-address=192.168.101.0/24 in-interface-list=WAN new-packet-mark=subnet101-down-pk passthrough=no
add action=mark-packet chain=forward comment=subnet101-up new-packet-mark=subnet101-up-pk out-interface-list=WAN passthrough=no src-address=192.168.101.0/24

Then set up a a queue tree with a parent upload and parent download. Parent max limits are set to 80-90% of the max limit you get on speed tests.
Then make child queues for each packet mark you made in mangle and put them under their respective parent queue. If all you want to do is distribute evenly across subnets, you don't need to touch anything else like priorities, burst, limit-at, etc. - just set the queue type for each child so that bandwidth is more fairly distributed within each subnet.
Ex:
/queue tree
add max-limit=90M name=parent-download parent=bridge
add max-limit=90M name=parent-upload parent=ether1
add name=subnet101-down packet-mark=subnet101-down-pk parent=parent-download queue=sfq
add name=subnet101-up packet-mark=subnet101-up-pk parent=parent-upload queue=sfq

Make mangle rules and child queues for each subnet as needed.

Who is online

Users browsing this forum: Google [Bot] and 61 guests