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