Bandwidth Management Fast-Track ! No theory, Just coding …
Requirement:
We want to restrict client with 128 kbps. BUT also want to prioritize it based on traffic type.
Example …
Client-A IP = 101.11.14.1 (zaib-desktop)
Bandwidth Allowed = 128k Total
Priority 1 = ICMP Traffic
Priority 2 = HTTPS Traffic
Priority 3 = HTTP Traffic
Priority 4 = All Other Traffic
Marking traffic from Client-A in MANGLE
First Mark User Traffic in Mangle Section.
/ip firewall mangle # Mark HTTP 80Traffic Connections/Packets add action=mark-connection chain=forward comment="Zaib-Desktop - Mark HTTP Port 80" dst-port=80 new-connection-mark=Zaib_Desktop_http_80_Conn protocol=tcp src-address=101.11.14.1 add action=mark-packet chain=forward connection-mark=Zaib_Desktop_http_80_Conn new-packet-mark=Zaib_Desktop_http_80_pkts passthrough=no # Mark HTTPS 443 Traffic Connections/Packets add action=mark-connection chain=forward comment="Zaib-Desktop - Mark HTTPS Port 443" dst-port=443 new-connection-mark=Zaib_Desktop_https_443_Conn protocol=tcp src-address=101.11.14.1 add action=mark-packet chain=forward connection-mark=Zaib_Desktop_https_443_Conn new-packet-mark=Zaib_Desktop_httsp_443_pkts passthrough=no add action=mark-connection chain=forward comment="Zaib Desktop - ICMP" new-connection-mark=Zaib_Desktop_ICMP_Conn protocol=icmp src-address=101.11.14.1 # Mark ICMP TRAFFIC Connections/Packets add action=mark-connection chain=forward comment="Zaib Desktop - ICMP" new-connection-mark=Zaib_Desktop_ICMP_Conn protocol=icmp src-address=101.11.14.1 add action=mark-packet chain=forward connection-mark=Zaib_Desktop_ICMP_Conn new-packet-mark=Zaib_Desktop_ICMP_Pkts passthrough=no # Mark ALL OTHER Traffic Connections/Packets add action=mark-connection chain=forward comment="Zaib Desktop - All Other Traffic" connection-mark=no-mark new-connection-mark=Zaib_Desktop_All_Other_Traffic src-address=101.11.14.1 add action=mark-packet chain=forward connection-mark=Zaib_Desktop_All_Other_Traffic new-packet-mark=Zaib_Desktop_All_Other_Pkts passthrough=no
Creating QUEUE TREE to restrict and Prioritize traffic for above marked packets
Now we we will create Parent Queue Tree to restrict 128k then other child queues to prioritize his traffic base on marked packets
# Mark QUEUE TREE /queue tree add limit-at=128k max-limit=128k name="Zaib Dekstop - 128k" parent=global queue=default # 1st Priority to ICMP Traffic from above 128k Parent Queue add name="PRIO 1 - ICMP" packet-mark=Zaib_Desktop_ICMP_Pkts parent="Zaib Dekstop - 128k" queue=default priority=1 # 2nd Priority to HTTPS 443 Traffic from 128k Parent Queue add name="PRIO 2 - HTTPS" packet-mark=Zaib_Desktop_httsp_443_pkts parent="Zaib Dekstop - 128k" queue=default priority=2 # 3rd Priority to HTTP Port 80 Traffic from 128k Parent Queue add name="PRIO 3 - HTTP" packet-mark=Zaib_Desktop_http_80_pkts parent="Zaib Dekstop - 128k" queue=default priority=3 # 4th Priority to All Other Traffic from 128k Parent Queue add name="PRIO 4 - All Other Traffic" packet-mark=Zaib_Desktop_All_Other_Pkts parent="Zaib Dekstop - 128k" queue=default priority=8
RESULT # 1
When ICMP have low priority over other protocols
BEFORE ICMP PRIORITY
RESULT # 2
When ICMP have high priority over others
*** A F T E R ***
Regard’s
Syed Jahanzaib
But how to do it for multiple clients or whole subnet, does it will create queues dynamic or queue tree will work.
Thanks
LikeLike
Comment by UmmarHussain — March 4, 2016 @ 2:42 PM
using PCQ base queues to distribute per IP basis.
LikeLiked by 1 person
Comment by Syed Jahanzaib / Pinochio~:) — March 4, 2016 @ 4:30 PM
Any example as extension of this post :p
LikeLike
Comment by UmmarHussain — March 4, 2016 @ 5:07 PM
Would as an example, my network is 10.0.0.0/18 , as would the application ?
LikeLike
Comment by Martinelli Souza — March 4, 2016 @ 6:15 PM
A.salam Sir kiya ap muja ipv6 server configure ka tarika bata sagta han mana ptcl ki smart tv line li ha wo direct pc ma to chal rahi ha but jub mikrotik sa pptp ya pppoe output dailer sa pc ma connect kar ta hn to smart tv nahi chal ta baki net chalta ah
________________________________
LikeLike
Comment by BILAL OWAIS — March 4, 2016 @ 6:40 PM
Hi Syed sir… I have Google peering,Akamai and caching server especially for p2p traffic. I want to give an example so i can get proper solution from you. Suppose i have total 500mb ILL,500mb google+akamai and Local cache server, If i want to give Total 100mb traffic in which 50mb will be ILL,25mb Google peering and 25 mb Local cache. How can i do it?
LikeLike
Comment by Santosh — March 8, 2016 @ 6:12 AM
selamun aleykum zaib
What is a router OS version ?
As there is some trouble in coding
Example:add action=mark-packet chain=forward connection-mark=Zaib_Desktop_https_443_Conn new-packet-mark=Zaib_Desktop_httsp_443_pkts passthrough=no add action=mark-connection chain=forward comment=”Zaib Desktop – ICMP” new-connection-mark=Zaib_Desktop_ICMP_Conn protocol=icmp src-address=101.11.14.1
I did not create it
and I does not seem to have an impact on the upload section
Thank you
LikeLike
Comment by abdullah ihsan — March 23, 2016 @ 6:05 PM
hi Syed i’m use ADSL upload & download it different. how to separate download and upload in queue-tree ?
thank you
LikeLike
Comment by Freshy Krueger — June 18, 2016 @ 1:56 PM
Assalaam o Alekom…..!
Sir……….im using this method without hotspot (Limit user traffic using PCQ (also useful for Hotspot Bypassed MAC address)
how to use this method with my using method?
Allah AAp Ko Jaza E Khair Dey……….
LikeLike
Comment by Salman Qureshi — December 13, 2016 @ 3:09 AM