mikrotik queue tree - Per connection queuing.

One of the cool feature on Mikrotik queuing is Per Connection Queuing . we can equally distribute the bandwidth among Number of users.[1]
This setup explores the per connection queuing in the congestion situation and how to utilize the priority queuing features.


[Please note Mikrotik Queue lowest priority value have highest priority eg: queue priority 7 traffic gets highest preference over queue priority 8  ]
In this test setup 192.168.92.50 and 51 given 512Kbps per connection queuing(PCQ) Priority 6 . 192.168.52 and 54 placed under 256Kbps PCQ (Priority 8) and further youtube users given 384Kbps irrespective to the queue they are currently placed ( FIFO) .


1) Bridge setup - " Don't forget to enable the bridge firewall :) "
/interface bridge
add admin-mac=00:00:00:00:00:00 ageing-time=5m arp=enabled auto-mac=yes comment="" disabled=no forward-delay=15s l2mtu=1522 \
max-message-age=20s mtu=1500 name=br_traffic_shaper priority=0x8000 protocol-mode=none transmit-hold-count=6

/interface bridge port
add bridge=br_traffic_shaper comment="" disabled=no edge=auto external-fdb=auto horizon=none interface=ether1 path-cost=10 point-to-point=auto \
priority=0x80
add bridge=br_traffic_shaper comment="" disabled=no edge=auto external-fdb=auto horizon=none interface=ether2 path-cost=10 point-to-point=auto \
priority=0x80
/interface bridge settings
set use-ip-firewall=yes use-ip-firewall-for-pppoe=no use-ip-firewall-for-vlan=no


Place an address list to define the 512Kbps users:
/ip firewall address-list
add address=192.168.92.50 comment="" disabled=no list=specical
add address=192.168.92.54 comment="" disabled=no list=specical


all others are placed in 256Kbps through marking the whole subnet (/29). Make sure the passthrough. Youtube traffic simply matched through content of the packet . It will match the whole session traffic.
/ip firewall mangle
add action=mark-connection chain=prerouting comment="" content=youtube disabled=no  \
new-connection-mark=youtube passthrough=yes
add action=mark-packet chain=prerouting comment="" connection-mark=youtube disabled=no new-packet-mark=youtube-packet passthrough=no
add action=mark-connection chain=prerouting comment="" disabled=no new-connection-mark=special passthrough=yes src-address-list=specical
add action=mark-packet chain=prerouting comment="" connection-mark=special disabled=no new-packet-mark=special_pkt passthrough=no
add action=mark-connection chain=prerouting comment="" disabled=no dst-address=192.168.92.48/29 new-connection-mark=all_conn \
passthrough=yes
add action=mark-packet chain=prerouting comment="" connection-mark=all_conn disabled=no new-packet-mark=all_pkt \
passthrough=yes


3) Define the queue type ,
/queue type
add kind=pcq name=256K_Users pcq-classifier=dst-address pcq-limit=50 pcq-rate=256000 pcq-total-limit=2000
add kind=pcq name=512K_Users pcq-classifier=dst-address pcq-limit=50 pcq-rate=512000 pcq-total-limit=2000


4) Define the Parent queue:
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=1024k max-limit=1024k name=Test_Parent_Dwn parent=ether1 \
priority=8
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=1024k max-limit=1024k name=Test_Parent_Up parent=ether2 \
priority=8


4) Define the sub queue tree based on the marking:
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=1024k name=256K_U packet-mark=all_pkt parent=\
Test_Parent_Dwn priority=8 queue=256K_Users
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=512k name=go packet-mark=special_pkt parent=\
Test_Parent_Dwn priority=6 queue=512K_Users
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=384k name=youtube packet-mark=youtube-packet parent=\
Test_Parent_Dwn priority=2 queue=default


we can see if all the users download in this situation ( except youtube) the total bandwidth goes 1.5Mbps but since the max-limit for 512K users 512Kbps they will equally share the bandwidth 256Kbps but if one user not downloading other user will get 512Kbps full.
but if the max limit is 768Kbps both users will devide the bandwidth equally but at the same time 256Kbps user will get 128kbps each.

In this scenario (max-limit 512kbps & 384 for youtube) when 4 usrs downloading & one user goes to youtube he will get 384Kbps and remaining bandwidth 640Kbps will be available for other users.
since 512Kbps goes to priority 6 users so only 128Kbps allocated for 256k users except youtube ( There is a dependency on the packet mark order in our setup highest order )

if the subqueues (which have the highest priority - Lower number) max-limit total > Total bandwidth
loweset priority queues will starve (0 kbps will be allocated) . Do some math before allocating bandwidth & priority.

[1] Manual:Queues - PCQ - http://wiki.mikrotik.com/wiki/Manual:Queues_-_PCQ

Comments

Anonymous said…
HI

how can you give priority to msn messenger on mikrotik. that way it doesn't slow down or lag.

Thank you
Hi,
This can be done but have to analyze the traffic from the MSN messenger. Let me check this Saturday and update on this. Hope you are requesting on the video
Anonymous said…
New to mikrotik and not a fan of codes. But I need to know the process of how to set up a queue. Either simple or a queue tree.
I want this queue to have the following behaviour on my network.

1. Give fair bandwidth usage to all users currently on network (Users can vary at times...this is a cafe wifi hotspot connection). "We are Currently using a 260kbps (kilobyte per sec) connection."

2. Give priority connection of 65kbps to specific computers (I dont know how mikrotik marks computers. Maybe using MAC addresses). This will be used to give admin computers priority connection.

3. Give Skype users a connection of at least 20kbps. Not lower! (Not sure if this would be enough for a clear call, but we can always change the values later to meet our needs)

Please I just need the scripts or strings to input into my mikrotik winbox.

Would be extemely grateful if this can be done as it would give us an easier time installing more base stations.

Thanks, Joe.

Popular posts from this blog

PPTP Server as Cisco for Mikrotik Client

l2tpv3 configuration reference

proxy arp