PRIO(8)
๐ PRIO(8) โ Priority qdisc ๐
โจ NAME โจ
okay so the manual name is PRIO - Priority qdisc ๐ง that's the whole vibe
๐ SYNOPSIS ๐
tc qdisc ... dev dev ( parent classid | root) [ handle major: ] prio [
bands bands ] [ priomap band band band... ] [ estimator interval
timeconstant ]
๐ธ DESCRIPTION ๐ธ
okay so the PRIO qdisc is a simple classful queueing discipline ๐ it holds an arbitrary number of classes, each with a different priority. the classes get dequeued in numerical descending order of priority, so the highest priority goes first. PRIO is a scheduler and it never delays packets ๐ซถ that makes it a work-conserving qdisc, though the qdiscs sitting inside the classes might not be.
this is so useful for lowering latency when you don't need to slow traffic down ๐ฆ
๐ฆ ALGORITHM ๐ฆ
when you make one with tc qdisc add, a fixed number of bands gets created. each band is a class ๐ you can't add classes with tc qdisc add though. instead you specify the number of bands on the command line when you attach PRIO to its root.
when it's dequeueing, band 0 gets tried first. only if it didn't deliver a packet does PRIO try band 1, and then onwards. so the most reliability-hungry packets should go to band 0, minimum delay to band 1, and the rest to band 2 ๐
the PRIO qdisc itself has minor number 0, so band 0 is actually major:1, band 1 is major:2, and so on. for major, swap in the major number that got assigned to the qdisc on tc qdisc add with the handle parameter โจ
๐ง CLASSIFICATION ๐ง
there are three ways PRIO can decide which band a packet lands in ๐
From userspace
- a process with sufficient privileges can encode the destination class directly with
SO_PRIORITY, seesocket(7).
With a tc filter
- a tc filter attached to the root qdisc can point traffic directly to a class.
With the priomap
- this one is based on the packet priority, which is derived from the Type of Service assigned to the packet.
only the priomap is specific to this qdisc ๐
๐ QDISC PARAMETERS ๐
bandsโ the number of bands ๐ if you change it from the default of3, you have to update the priomap as well, no skipping that step bestie.priomapโ this maps the priority of a packet to a class โจ the priority can be set straight from userspace, or derived from the Type of Service of the packet. it's decided by the TOS octet of the packet, which looks like this:
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| | | |
|PRECEDENCE | TOS |MBZ|
| | | |
+---+---+---+---+---+---+---+---+
the four TOS bits (the 'TOS field') are defined as:
Binary Decimal Meaning
-----------------------------------------
1000 8 Minimize delay (md)
0100 4 Maximize throughput (mt)
0010 2 Maximize reliability (mr)
0001 1 Minimize monetary cost (mmc)
0000 0 Normal Service
real talk about the math ๐ค there's 1 bit sitting to the right of those four bits, so the actual value of the TOS field is double the value of the TOS bits. tcpdump -v -v shows you the value of the entire TOS field, not just the four bits. it's the value you see in the first column of this table:
TOS Bits Means Linux Priority Band
------------------------------------------------------------
0x0 0 Normal Service 0 Best Effort 1
0x2 1 Minimize Monetary Cost 0 Best Effort 1
0x4 2 Maximize Reliability 0 Best Effort 1
0x6 3 mmc+mr 0 Best Effort 1
0x8 4 Maximize Throughput 2 Bulk 2
0xa 5 mmc+mt 2 Bulk 2
0xc 6 mr+mt 2 Bulk 2
0xe 7 mmc+mr+mt 2 Bulk 2
0x10 8 Minimize Delay 6 Interactive 0
0x12 9 mmc+md 6 Interactive 0
0x14 10 mr+md 6 Interactive 0
0x16 11 mmc+mr+md 6 Interactive 0
0x18 12 mt+md 4 Int. Bulk 1
0x1a 13 mmc+mt+md 4 Int. Bulk 1
0x1c 14 mr+mt+md 4 Int. Bulk 1
0x1e 15 mmc+mr+mt+md 4 Int. Bulk 1
the second column is the value of the relevant four TOS bits, followed by what they translate to. for example, 15 means a packet wanting Minimal Monetary Cost, Maximum Reliability, Maximum Throughput AND Minimum Delay. chaotic, I love it ๐
the fourth column shows how the Linux kernel interprets the TOS bits, meaning which Priority they get mapped to ๐
the last column is the result of the default priomap. on the command line, the default priomap looks like this:
1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
so priority 4, for example, gets mapped to band number 1. the priomap also lets you list higher priorities (> 7) that don't match any TOS mapping, but get set by other means ๐
this table from RFC 1349 (go read it for more details ๐) explains how applications might very well set their TOS bits:
TELNET 1000 (minimize delay)
FTP
Control 1000 (minimize delay)
Data 0100 (maximize throughput)
TFTP 1000 (minimize delay)
SMTP
Command phase 1000 (minimize delay)
DATA phase 0100 (maximize throughput)
Domain Name Service
UDP Query 1000 (minimize delay)
TCP Query 0000
Zone Transfer 0100 (maximize throughput)
NNTP 0001 (minimize monetary cost)
ICMP
Errors 0000
Requests 0000 (mostly)
Responses <same as request> (mostly)
๐ซง CLASSES ๐ซง
PRIO classes can't be configured any further ๐ โโ๏ธ they get automatically created the moment the PRIO qdisc is attached. each class can hold yet another qdisc though, so you can layer it up ๐ฐ
๐จ BUGS ๐จ
โ ๏ธ big amounts of traffic in the lower bands can starve the higher bands. you can prevent that by attaching a shaper, for example tc-tbf(8), to these bands so they can't dominate the link. don't let the lower bands hog everything, bestie ๐ญ
๐ AUTHORS ๐
Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>, and J Hadi Salim <hadi@cyberus.ca>. this manpage is maintained by bert hubert <ahu@ds9a.nl> ๐ซถ
๐ okay that's the whole page, periodt ๐ source is iproute2, last updated 16 December 2001, and this was a Linux manual page. love you, mwah ๐๐ฆ
๐ฆ 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