QoS for VOIP in Mikrotik
Prerequisities: Your VOIP SW/HW can set the DSCP/TOS field in the IP packet in such a way that:
- SIP signaling messages will be marked by DSCP=0x68 (=104)
- RTP voice audio data will be marked by DSCP=0xB8 (=184)
These are the default values for SPA-XXXX VOIP gateways, but also SW clients should be able to make these settings. E.g., in XLite, just divide these values by 4 (DSCP for SIP=26, for RTP=46)
If your central internet gateway router handles/restores the DSCP-marked packets correctly, then implementing QoS for VOIP packets at your Mikrotik routers is easy - see the following script:
/ip firewall mangle add chain=prerouting tos=104 action=mark-packet new-packet-mark=voip-sip passthrough=yes add chain=prerouting tos=184 action=mark-packet new-packet-mark=voip-rtp passthrough=yes
/queue simple name="VOIP-SIP" interface=all packet-marks=voip-sip priority=1 name="VOIP-RTP" interface=all packet-marks=voip-rtp priority=0
Note that the default pfifo queueing discipline, used on ethernet interfaces in Linux and Mikrotik, prioritize the DSCP marks automatically, so theoretically, if the central internet gateway restores the DSCP marks on incoming packets from VOIP providers, everything could work OK even without any QoS settings on the router.
But if you already do some QoS (e.g. using HTB in Linux or "queues" on Mikrotik)on your routers, you should add also these 2 queues dedicated to VOIP.