Where to put the mark for voice QoS

Hello All.

Looking the package flow:

I want to know what it’s the best chains to set the mangle mark. For what I’m seeing the best is prerouting due to since the packages get in to the router is the first chains for it. What do you think?

I’m seeing that the queue tree are on the chains input and postrouting bu If I set the mark on input there isn’t package count on it.

Input chain is only for traffic destined to Mikrotik device

I set the priority and marks in the postrouting chain, e.g. like this:

/ip firewall mangle
add action=set-priority chain=postrouting comment="From dscp high 3 bits" \
    new-priority=from-dscp-high-3-bits passthrough=yes
add action=mark-packet chain=postrouting comment="Priority 0" \
    new-packet-mark=prio0 passthrough=yes priority=0
add action=mark-packet chain=postrouting comment="Priority 1" \
    new-packet-mark=prio1 passthrough=yes priority=1
add action=mark-packet chain=postrouting comment="Priority 2" \
    new-packet-mark=prio2 passthrough=yes priority=2
add action=mark-packet chain=postrouting comment="Priority 3" \
    new-packet-mark=prio3 passthrough=yes priority=3
add action=mark-packet chain=postrouting comment="Priority 4" \
    new-packet-mark=prio4 passthrough=yes priority=4
add action=mark-packet chain=postrouting comment="Priority 5" \
    new-packet-mark=prio5 passthrough=yes priority=5
add action=mark-packet chain=postrouting comment="Priority 6" \
    new-packet-mark=prio6 passthrough=yes priority=6
add action=mark-packet chain=postrouting comment="Priority 7" \
    new-packet-mark=prio7 passthrough=yes priority=7

Then I use a queue tree to sort the traffic into 8 queues like this:

/queue tree
add limit-at=19M max-limit=19M name=\
    queue-vlan51 parent=ether1.vlan51 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p1 packet-mark=prio7 parent=\
    queue-vlan51 priority=1 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p2 packet-mark=prio6 parent=\
    queue-vlan51 priority=2 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p3 packet-mark=prio5 parent=\
    queue-vlan51 priority=3 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p4 packet-mark=prio4 parent=\
    queue-vlan51 priority=4 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p5 packet-mark=prio3 parent=\
    queue-vlan51 priority=5 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p6 packet-mark=prio0 parent=\
    queue-vlan51 priority=6 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p7 packet-mark=prio2 parent=\
    queue-vlan51 priority=7 queue=default
add limit-at=4M max-limit=18M name=queue-vlan51-p8 packet-mark=prio1 parent=\
    queue-vlan51 queue=default

(note the funny ordering of prio0/1/2 due to historical reasons)

When the traffic does not have appropriate DSCP values, I sometimes put some DSCP changing rules in the prerouting chain:

/ip firewall mangle
add action=change-dscp chain=prerouting comment="Low prio for SMB traffic" \
    dst-port=445 new-dscp=8 passthrough=yes protocol=tcp

(similar rules can be used to set e.g. new-dscp=46 for voice traffic)