LinuxCommandLibrary

tc-drr

Configure traffic shaping using Deficit Round Robin

SYNOPSIS

tc qdisc add dev <DEV> { root | parent <HANDLE> } drr [ quantum <BYTES> ] [ default <CLASSID> ]

PARAMETERS

quantum <BYTES>
    Specifies the amount of bytes a flow or class is allowed to transmit in one round. This value influences the granularity of fairness. A larger quantum can lead to higher throughput but potentially less fairness over very short time scales for small packets. The default value is typically the interface's MTU.

default <CLASSID>
    Defines the default class to which packets are sent if they do not match any explicit filter or class. This is important for ensuring that all traffic is handled, even if not specifically classified. If no default class is specified, traffic that doesn't match any filter might be dropped.

DESCRIPTION

The tc-drr command, more accurately, refers to the Deficit Round Robin (DRR) queuing discipline (qdisc) used with the Linux traffic control utility (tc). DRR is an algorithm designed to provide fair bandwidth allocation among multiple flows or classes of traffic.

Unlike Strict Priority (SP) queuing, DRR aims to give each class a 'fair' share of the bandwidth, preventing a single busy flow from monopolizing the network link. It achieves this by maintaining a 'deficit counter' for each class. When it's a class's turn, it can transmit packets up to its quantum (a specified byte limit) plus any accumulated deficit. If a packet exceeds the remaining deficit, it's transmitted in the next round, and the deficit counter is updated.

This mechanism ensures that even large packets don't cause starvation for other classes, as they are effectively handled over multiple rounds. tc-drr is particularly useful in environments where fair sharing of bandwidth is crucial, such as between different applications, users, or services. It's a foundational component for building robust Quality of Service (QoS) policies on Linux systems.

CAVEATS

DRR is a fair queuing algorithm; it does not provide strict priority. While it aims for fairness, a class might still experience some delay if other classes are very busy, especially if its quantum is small relative to its packets.

Effective use of DRR often requires proper classification of traffic into different classes using tc filters. Without filters, all traffic might flow into a single default class, negating the benefits of DRR.

The `quantum` value needs careful tuning based on network characteristics (MTU, typical packet sizes) and desired fairness granularity. An inappropriately small quantum can lead to increased CPU overhead due to more frequent scheduling decisions.

HOW DEFICIT WORKS

In DRR, each active class maintains a 'deficit counter', initialized to zero. In each round, when it's a class's turn, its 'quantum' is added to its deficit counter. The class can then send packets as long as the packet size is less than or equal to its current deficit. After sending a packet, the deficit counter is reduced by the packet size. If a packet is too large, it's held until the next round, and the deficit counter is not decremented for that packet, allowing it to accumulate more 'credit'. This mechanism ensures fairness even with varying packet sizes, preventing large packets from consuming more than their fair share in a single turn.

INTEGRATION WITH TC HIERARCHY

DRR is a classful queuing discipline, meaning it can have child classes. This allows for complex hierarchical QoS setups. You can attach different qdiscs (e.g., HTB, PRIO, FQ-CoDel) as children to DRR classes, enabling fine-grained control over how traffic within each DRR class is further managed and prioritized. For example, you might use DRR to fairly distribute bandwidth among three departments, and within one department's class, use HTB to prioritize specific applications.

HISTORY

The concept of Deficit Round Robin was introduced by M. Shreedhar and George Varghese in 1995 as an improvement over traditional Round Robin scheduling, specifically to address the issue of variable packet sizes. It was designed to provide fair service for variable-sized packets without requiring a complicated sorting of packets by finish times (as in WFQ).

Its implementation in the Linux kernel's `tc` framework has been a long-standing feature, contributing to Linux's capabilities as a robust network router and firewall, enabling detailed Quality of Service (QoS) management since the early days of advanced traffic control in the kernel. DRR is a well-established and widely used algorithm in network devices.

SEE ALSO

tc(8), tc-classid(7), tc-filters(8), tc-htb(8), tc-prio(8), tc-fq_codel(8)

Copied to clipboard