Mastering Traffic Prioritization in MikroTik: A Deep Dive into TOS and DSCP Standards

Implementing Type of Service (TOS) and Differentiated Services Code Point (DSCP) based QoS become invaluable when trying to prioritize important traffic. These mechanisms allow network administrators to classify and prioritize network traffic, ensuring that critical services like Voice over IP (VoIP) and streaming are given precedence over less time-sensitive data. This blog post explores the technical intricacies of TOS and DSCP, their application within MikroTik RouterOS, and provides practical examples of how to utilize these standards to optimize network performance.

Understanding TOS and DSCP Standards

Type of Service (TOS)

The TOS field is an 8-bit field in the IPv4 header, originally designed to allow packets to be classified for Quality of Service (QoS) purposes. It specifies how an upper-layer protocol requires a lower-layer protocol to handle its packets. This field has been redefined by the DSCP for more granular traffic classification.

Differentiated Services Code Point (DSCP)

DSCP, a successor to TOS, is part of the IP header that specifies the priority level of each packet. It uses the first 6 bits of the 8-bit differentiated services field to allow for 64 different classifications of traffic. DSCP enables packet forwarding based on the type of service requested, which is particularly useful for prioritizing real-time applications such as VoIP and streaming media.

TOS and DSCP in MikroTik RouterOS

MikroTik RouterOS provides support for traffic prioritization using both TOS and DSCP standards. Implementing these standards can significantly enhance network performance, particularly for real-time applications.

Configuring DSCP in MikroTik

MikroTik RouterOS allows for the manipulation and prioritization of traffic based on DSCP values through its mangle facility in the firewall. Here's an example of how to mark packets for a VoIP service with a specific DSCP value and then prioritize them:

  1. Marking VoIP Traffic:
/ip firewall mangle
add action=mark-packet chain=forward protocol=udp dscp=46 new-packet-mark=voip-packets passthrough=no

This rule marks UDP packets with a DSCP value of 46 (which is typically used for EF – Expedited Forwarding for VoIP traffic) as voip-packets.

  1. Prioritizing Marked Traffic:
/queue tree
add name="VoIP Priority" parent=global-out packet-mark=voip-packets priority=1

This creates a queue that gives highest priority to packets marked as voip-packets, ensuring they are forwarded with precedence.

Default TOS Values for Real-Time Protocols

The following table lists some default TOS/DSCP values commonly associated with real-time protocols like SIP, which can be prioritized in MikroTik RouterOS for enhanced QoS:

ProtocolDSCP (Decimal)DSCP (Binary)Description
SIP24011000Signaling for VoIP
RTP46101110Real-time audio/video streams

Prioritizing traffic based on these default values simplifies network QoS configuration, as it eliminates the need to maintain extensive lists of IP addresses or ports for different services. By focusing on the DSCP values, MikroTik routers can efficiently prioritize packets across the network, enhancing the performance of real-time applications.

DSCP gives you an easy win for QoS

Understanding and utilizing TOS and DSCP standards are fundamental for network administrators looking to optimize traffic flow and prioritize critical services in their networks. MikroTik RouterOS provides powerful tools for implementing these standards, offering the ability to significantly improve the quality of service for real-time applications. By strategically configuring traffic prioritization based on DSCP values, administrators can ensure that essential data packets are delivered timely and reliably, maintaining optimal network performance and user satisfaction.

Was this page helpful?