TC(8)
๐ NAME ๐
okay so the manual page for tc (the traffic control tool) has a whole section on this one: drr - deficit round robin scheduler ๐
๐ง SYNOPSIS ๐ง
tc qdisc ... add drr [ quantum bytes ]
๐ DESCRIPTION ๐
okay bestie, the Deficit Round Robin Scheduler is a classful queuing discipline ๐ and it's giving a more flexible upgrade to Stochastic Fairness Queuing (SFQ) โจ
unlike SFQ, there are no built-in queues ๐ you have to add your own classes and then set up filters so packets get sorted into them. this is lowkey super useful if you want, say, RED qdiscs with different settings for specific traffic ๐ฆ also, there is no default class. if a packet can't be classified, it gets dropped ๐
๐ ALGORITHM ๐
every class gets its own deficit counter, and it starts out equal to quantum ๐ซถ
DRR keeps an (internal) active list of classes whose qdiscs are non-empty, and this list is what drives dequeuing ๐ฅ a packet gets dequeued from the class sitting at the head of the list if the packet size is smaller than or equal to the deficit counter. if the counter is too small, it gets bumped up by quantum and the scheduler moves on to the next class in the active list. the way that it just keeps cycling, no cap, iconic ๐
๐ PARAMETERS ๐
quantumโ the number of bytes a flow is allowed to dequeue before the scheduler moves on to the next class ๐ it defaults to the MTU of the interface, and the minimum value is1โจ
๐ฆ EXAMPLE & USAGE ๐ฆ
okay so to attach to device eth0 and use the interface MTU as the quantum:
# tc qdisc add dev eth0 handle 1 root drr
next up, adding two classes ๐ธ
# tc class add dev eth0 parent 1: classid 1:1 drr
# tc class add dev eth0 parent 1: classid 1:2 drr
you also need to add at least one filter to classify packets, otherwise nothing gets sorted ๐
# tc filter add dev eth0 protocol .. classid 1:1
bestie, real talk: like SFQ, DRR is only useful when it owns the queue ๐จ it's a pure scheduler and does not delay packets. attaching non-work-conserving qdiscs liketbfto it does not make sense, because other qdiscs in the active list will also go inactive until the dequeue operation succeeds. to make sure it owns the queue, embed DRR within another qdisc likeHTBorHFSC๐
if you want to mimic SFQ behavior, you can assign packets to the attached classes using the flow filter ๐ง
tc qdisc add dev .. drr
for i in .. 1024;do
tc class add dev .. classid $handle:$(print %x $i)
tc qdisc add dev .. fifo limit 16
done
tc filter add .. protocol ip .. $handle flow hash keys
src,dst,proto,proto-src,proto-dst divisor 1024 perturb 10
๐ SOURCE ๐
- M. Shreedhar and George Varghese "Efficient Fair Queuing using Deficit Round Robin", Proc. SIGCOMM 95. ๐ซถ
๐ NOTES ๐
heads up, this implementation does not drop packets from the longest queue on overrun ๐ญ that's because limits get handled by the individual child qdiscs instead โจ
๐ SEE ALSO ๐
tc(8), tc-htb(8), tc-sfq(8) ๐
๐ AUTHOR ๐
sched_drr was written by Patrick McHardy, who is absolutely iconic ๐
bestie, that's the whole thing! ๐ this page is from iproute2, dated January 2010, and it's the TC(8) manual ๐ stay fair, stay fast, and keep those queues flowing ๐ ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2.2 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms