I’m just trying to implement Queue Tree to prioritize traffic. Everything is ok except that I can’t mark connection based on TOS, for example I would like to mark all video traffic and put that traffic to low priority in the tree.
When I packet sniff incoming traffic I see that it has 0 value in TOS:
I added firewall mange to catch this kind of traffic but it can’t see it:
When your goal is to priority traffic in a couple of different categories, it is best to first evaluate the typical TOS values observed in the traffic and when it is not to your liking, adjust it (e.g from 0 to some other value).
Then, copy the TOS to the priority field of the packets using:
This will copy the highest 3 bits of the TOS (DSCP) into the priority, giving 8 different priority classes to work with, usually more than enough.
Now, you can set some packet marks from this:
Note the “strange order” of the last 3 lines, that is because the top 3 bits of TOS are defined in that strange way to
allow priorities 1 and 2 to be “below normal” where normal was defined as 0. Due to an oversight in the original
TOS definition one could only specify priorities higher than normal.
(what we really need from MikroTik is a function to set priority from DSCP in a way that reflects the common usage
of DSCP code points. But often the above method is good enough. DSCP “assured forwarding” code points can
sometimes be problematic)
So, actually I can just replace my queue tree with yours and forget about classifying things with their names and protocols, right? btw, Is it required to set bandwidth limits?
I tested the mangle priorities, prio0 is active when I watch movie, but I wonder which priority is “responsible” for ping packets for example? Because all I see now is that only prio0 and prio6 are showing bytes and packets.
Yes, I use those queue trees on many routers. You need to set the limit-at and max-limit at top level to some 5% less than the actual upload speed of your line, and the max-limit of each priority to maybe 80-90% of that. It depends on the local situation: when you have only cooperating users, these settings are OK, when you have people who like to exploit the system to their advantage, you want to set a lower max-limit for the high priorities (prio3-7).
The limit-at for the 8 queues is not that important, you can set it to 1/4 of the speed.
Now your next issue is “first evaluate the typical TOS values observed in the traffic and when it is not to your liking, adjust it”.
You need to check what different TOS values are seen in your system for the different protocols you use (e.g. use TORCH and enable the DSCP item).
When they are not to your liking, you can match the protocols or addresses and adjust the TOS values. That would be done ABOVE the mangle rules shown.
It is a good idea to use connection marking to mark the connections you want to change, and then change TOS based on these connection markings.
That way you are sure the marking works in both directions.
Example:
Here, some traffic is matched (similar to what you did above) and a connection mark
is put on it, and then the traffic with that connection mark, but with TOS/DSCP 0, is
changed to another TOS/DSCP.
That is then fed into the 8-queue solution shown above.
In this case, cs1 is lowest priority, cs2 is one step higher, the next level is the default (DSCP 0),
and cs3 is again a priority level above that (prio3).
Devices that know they need a higher priority (like VoIP phones), will set a DSCP like 46
which will map to prio5.
someone on this forum mentioned that the DSCP traffic prioritization can’t work for incoming traffic but only for outgoing. Is that true? Maybe this is why I see ZERO value in TOS field in the packet sniffer?
Problem is that there is no value in TOS for me to “convert” it into priority values.
Well, queuing only works for outgoing traffic. You cannot tell the other side to sort traffic according to priority.
There used to be some ISPs that always set TOS to 0 on all packets because they did not want to be involved in an arms race for ever higher priority requested by some users. But that is becoming less common because of the heavy use of VoIP that requires a bit of priority over background traffic.
Still, you cannot tell others (youtube, file transfer services) what TOS they should use on their traffic.
So yes, TOS/DSCP based traffic priority is for outgoing traffic. For better handling of incoming traffic you can only ask your ISP to implement some things like fair queue or more modern queueing systems.
Even when you can identify the traffic, you still cannot shape the incoming traffic.
There are some tricks to control incoming TCP traffic by shaping the outgoing ACK traffic, but it still depends on the behavior of the ISP side.