How to guarantee and prioritize traffic?
Description
Queue trees can be used for more sophisticated applications where you need to
limit traffic for specific users, protocols, ports etc.
In this example we will show you:
- how to guarantee bandwidth to certain services and use the 'idle' bandwidth
- how to prioritize a service (POP3) among others (HTTP and
FTP)
You can see how we will share the traffic in the picture (the network
192.168.0.0/24 is masqueraded):

-
At first, mangle the HTTP, FTP and POP3 download
traffic. As our network 192.168.0.0/24 is masqueraded, we need to mark
the outgoing connection with mark-connection parameter: /ip firewall mangle
add in-interface=Local dst-address=:80 protocol=tcp action=passthrough
mark-connection=http-con comment="" disabled=no
add in-interface=Local dst-address=:110 protocol=tcp action=passthrough
mark-connection=pop3-con comment="" disabled=no
add in-interface=Local dst-address=:21 protocol=tcp action=passthrough
mark-connection=ftp-con comment="" disabled=no
and only then we can mark the downstream traffic with a flow mark: /ip firewall mangle
add protocol=tcp connection=http-con action=passthrough mark-flow=HTTP
comment="" disabled=no
add protocol=tcp connection=pop3-con action=passthrough mark-flow=POP3
comment="" disabled=no
add protocol=tcp connection=ftp-con action=passthrough mark-flow=FTP
comment="" disabled=no
-
When we have marked the packets with a flow-mark, we can use them to
build a queue tree.
Add a queue that will guarantee 80% of all available (512kbps) bandwidth,
which is 409,6kbps, for HTTP service and if there is more bandwidth available
(some services are idle), use it: /queue tree
add name="http-queue"
parent=Local flow=HTTP limit-at=409600 max-limit=512000
Add a queue that will guarantee 15% (76,8kbps) for FTP: /queue tree add name="ftp-queue"
parent=Local flow=FTP limit-at=76800 max-limit=512000
Now add a queue that will guarantee 5% (25,6kbps) of all available bandwidth
to POP3 service. Set the priority for this service to 7. It means
that this queue will have a higher priority than the previous ones (by default
the priority is 8) so it will be processed before http-queue and
ftp-queue: /queue tree
add name="pop3-queue"
parent=Local flow=POP3 limit-at=25600 max-limit=512000
priority=7
The benefit from higher priority is that POP3 traffic, as it will be
processed first, will have the smallest delay going through the router from all
services.
Using limit-at and max-limit parameters, you can control the
minimum guaranteed and maximum allowed bandwidth for a service. At first, the
limit-at data rate is achieved, then, if more bandwidth is available, it
is used by this service (up to 512kbps in this example).
Note: for a correct queue tree setup the amount of limit-at
values for queue tree leaves (queues which have no child-queues) must be equal
(or lower) to available bandwidth. In this case 25,6kbps + 76,8kbps + 409,6kbps
= 512kbps.
|