Queueing and QoS on MikroTik RouterOS v7
Queueing and Quality of Service (QoS) are essential tools in network traffic management, helping to prioritize critical traffic, prevent congestion, and ensure efficient use of available bandwidth. By implementing queueing mechanisms, you can prioritize critical services, ensure fair bandwidth distribution, prevent network congestion, and enhance overall network performance. MikroTik RouterOS v7 offers various methods for implementing QoS and queueing, allowing administrators to control traffic flow and ensure optimal network performance.
This explanation covers the basics of queueing, QoS concepts, and the methods used in MikroTik RouterOS v7 to implement these functions.
1. Key Concepts of QoS and Queueing
1.1 Quality of Service (QoS)
QoS is a set of techniques that prioritize certain types of traffic over others to guarantee performance (e.g., lower latency, minimal jitter, or reliable throughput) for specific applications or services. This is especially important in environments with limited bandwidth or where multiple types of traffic (e.g., VoIP, video streaming, web browsing) coexist.
1.2 Queueing
Queueing is the process of managing and scheduling data packets that are waiting to be sent over the network. Packets are stored in queues, and queueing algorithms determine how and when the packets are transmitted based on their assigned priority.
In RouterOS, queues are used to:
- Control bandwidth usage (rate limiting or shaping)
- Prioritize specific types of traffic
- Avoid congestion and buffer bloat
- Allocate bandwidth based on service or user requirements
In MikroTik RouterOS v7, there are several types of queues available, each serving different purposes for traffic shaping, bandwidth management, and Quality of Service (QoS). These queues help manage how traffic is handled, prioritized, and limited. Below are the primary types of queues in RouterOS v7:
1. Default Queue Types
These are the default queue types available in MikroTik RouterOS v7, which are used when creating simple queues or queue trees.
1.1. FIFO (First In, First Out)
- FIFO is the simplest type of queue where packets are processed in the order they arrive without any prioritization or differentiation. It doesn’t offer any QoS capabilities and treats all traffic equally.
- Use Case: It’s ideal for low-load situations where no prioritization is required, and all traffic should be treated equally.
1.2. SFQ (Stochastic Fair Queue)
- SFQ is a fair queueing algorithm that tries to distribute bandwidth evenly across all active flows. It doesn’t strictly limit bandwidth but aims to give each flow a fair share.
- Use Case: SFQ is useful for general-purpose fairness across multiple users or streams, ensuring no single flow dominates the available bandwidth.
1.3. RED (Random Early Detection)
- RED is a congestion avoidance algorithm. It starts dropping packets before the queue becomes full to reduce the chance of congestion and prevent packet bursts. It works by dropping packets randomly when the queue is nearly full.
- Use Case: RED is commonly used to prevent congestion and buffer bloat in networks that handle bursty traffic, such as HTTP requests or large file downloads.
1.4. FIFO with Droptail
- This is a variation of FIFO where, instead of processing packets in the order they arrive and leaving others in the queue, it simply drops packets if the queue reaches its limit.
- Use Case: It’s useful in scenarios where there is no prioritization, and excess traffic should be dropped if the network link is congested.
2. Simple Queues
Simple queues are used for straightforward bandwidth management. You can assign them to specific IPs, subnets, or interfaces and set maximum and minimum bandwidth limits.
2.1. Simple Queue
- Simple queues are the most basic method to limit and prioritize traffic for individual users or devices. You can set up rate limits for individual IP addresses, subnets, or even entire interfaces.
- Use Case: For limiting bandwidth for specific users, subnets, or devices, or applying basic QoS to prioritize certain services like video streaming or web browsing.
3. Queue Tree
Queue trees allow for more advanced traffic shaping and hierarchical bandwidth management. They work in combination with packet marks from firewall mangle rules, allowing you to control traffic per service or user group.
3.1. Parent/Child Queue Tree
- A parent/child queue structure allows for complex hierarchical bandwidth allocation. You can define a parent queue that controls the total bandwidth available to a set of sub-queues, which can represent different users, services, or traffic types.
- Use Case: Useful for detailed bandwidth management, such as allocating a total of 100 Mbps to your LAN and then dividing that bandwidth between VoIP, web traffic, and file downloads.
4. PCQ (Per Connection Queue)
PCQ is a special type of queue used to automatically distribute bandwidth among many clients or flows. It simplifies bandwidth distribution across multiple users or devices by ensuring fairness in bandwidth allocation.
4.1. PCQ - Per Connection Queue
- PCQ divides available bandwidth evenly between all active connections or users. It is a type of queue that dynamically adjusts based on the number of active connections, ensuring that each user or flow gets an equal share of bandwidth.
- Use Case: PCQ is ideal for environments with many users, such as public Wi-Fi networks, cafes, or businesses where you want to automatically ensure fair bandwidth distribution without manually assigning limits to each user.
- PCQ Classifiers:
src-address
: Ensures fairness by allocating bandwidth per source IP address (upload).dst-address
: Allocates bandwidth per destination IP address (download).
5. FIFO Variants (Default-Small, Default-Large)
MikroTik also includes default queue types optimized for different traffic loads. These are useful for most standard applications where advanced queueing is not necessary but where simple FIFO-based management can help.
5.1. Default-Small
- Default-Small is a pre-configured FIFO queue with small buffer sizes. It processes packets in the order they arrive and is generally used in scenarios with low latency requirements.
- Use Case: Used for low-latency environments like VoIP, where quick processing of small packets is critical.
5.2. Default-Large
- Default-Large is a pre-configured FIFO queue with larger buffer sizes, typically used for environments with larger packet sizes and higher bandwidth demands.
- Use Case: Suitable for high-bandwidth applications like video streaming or large file transfers.
6. RED with ECN (Explicit Congestion Notification)
RED with ECN is similar to traditional RED but adds support for ECN, which helps endpoints detect network congestion and adjust transmission rates before packet loss occurs.
6.1. RED with ECN
- RED with ECN notifies both the sender and receiver about congestion before the network reaches its limits. This allows for better control of congestion in TCP streams and can prevent congestion collapse.
- Use Case: Useful for handling traffic on high-latency links, such as satellite connections, where avoiding packet loss due to congestion is critical.
7. Burst Queues
Burst queues allow a user or device to temporarily exceed their bandwidth limit. This is useful for applications like web browsing, where short bursts of high-speed traffic improve performance, but sustained high throughput is undesirable.
7.1. Burst in Simple Queues
- Burst queues allow for bandwidth to exceed the set limit for a short period, depending on available bandwidth and predefined thresholds. After the burst period ends, the bandwidth returns to the original limit.
- Use Case: Useful for applications such as web browsing, where users benefit from temporary increases in speed for loading pages faster without exceeding long-term bandwidth limits.
Conclusion
MikroTik RouterOS v7 provides a wide range of queue types to manage traffic effectively. Whether you're looking for simple rate-limiting (Simple Queues), advanced traffic shaping (Queue Trees), fair bandwidth allocation (PCQ), or specific congestion control methods (RED), RouterOS has the flexibility to handle most network traffic management needs.
- Simple Queues: Best for straightforward rate-limiting per user or device.
- Queue Trees: Best for more advanced, hierarchical traffic shaping and prioritization.
- PCQ: Ideal for environments with many users where automatic, fair bandwidth allocation is required.
- RED/SFQ: Best for congestion avoidance and fairness in bandwidth allocation.
These tools allow for detailed and efficient bandwidth management, traffic prioritization, and QoS implementation.