tc-prio
Configure traffic control packet prioritization
SYNOPSIS
tc qdisc add dev DEV root | parent CLASSID prio [bands NUMBER] [priomap A B C ...] [handle X:]
tc qdisc change dev DEV root | parent CLASSID prio [bands NUMBER] [priomap A B C ...]
PARAMETERS
dev DEV
Specifies the network device (e.g., eth0) to which the qdisc is attached.
root
Attaches the prio qdisc as the root qdisc for the specified device.
parent CLASSID
Attaches the prio qdisc as a child of an existing qdisc or class specified by CLASSID.
bands NUMBER
Specifies the number of priority bands (internal queues) to create. The default is 3 bands (0, 1, 2).
priomap A B C ...
Defines a mapping from internal Linux priorities (0-15) to specific prio bands. It requires 16 space-separated integers, where each integer indicates the band for the corresponding internal priority. For example, 'priomap 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2' maps internal priorities 0, 1, 2 to bands 0, 1, 2 respectively, and all higher internal priorities to band 2. The default is '0 1 2 3 4 5 6 7 7 7 7 7 7 7 7 7' (mapping internal priorities 0-7 to bands 0-7, and 8-15 to band 7), but if only 3 bands are present, priorities > 2 will be mapped to band 2.
handle X:
Assigns a unique handle to the prio qdisc, allowing it to be referenced by other tc commands or child qdiscs. The format is 'major:minor' or just 'major:' if minor is 0.
DESCRIPTION
The prio queuing discipline (qdisc) is a simple yet powerful traffic control mechanism in Linux that provides strict priority queuing. It operates by maintaining multiple internal queues, known as 'bands'. By default, it creates three bands (0, 1, and 2), with band 0 having the highest priority and band 2 the lowest.
Packets are directed into these bands based on their internal priority, which can be set by various classifiers, most commonly using tc filters like u32 or fwmark. Without explicit filters, all traffic defaults to the highest priority band (band 0).
The prio qdisc serves packets from the highest priority band (band 0) until it is empty, then moves to the next highest priority band (band 1), and so on. This strict priority ensures that high-priority traffic, such as interactive SSH sessions or VoIP, gets preferential treatment over lower-priority traffic like bulk data transfers or file downloads, preventing latency and ensuring responsiveness.
Each band can have its own child qdisc attached, allowing for more complex traffic shaping within each priority level. For instance, band 0 might use fq_codel for low-latency interactive traffic, while band 1 might use tbf for rate-limiting bulk traffic.
CAVEATS
The prio qdisc itself does not classify packets. Without tc filters (e.g., u32, fw), all traffic will default to the highest priority band (band 0). This effectively turns prio into a simple FIFO qdisc if no filters are applied.
As a strict priority qdisc, lower priority bands can experience 'starvation' if there's a continuous stream of traffic in higher priority bands. It is crucial to manage traffic appropriately to avoid this, potentially by attaching bandwidth-limited child qdiscs to higher priority bands or by using other qdiscs like HTB for more flexible sharing.
PACKET CLASSIFICATION
For prio to function effectively, packets must be classified and assigned an internal priority or explicitly directed to a specific band. This is typically achieved using tc filters. For example, a u32 filter can match packets based on IP addresses, ports, or protocol types and then use the 'set_tc_index' or 'classid' action to direct them to a specific band. Alternatively, the 'fw' filter can use firewall marks set by iptables to classify packets.
CHILD QDISCS ON BANDS
Each band of the prio qdisc (e.g., prio:0, prio:1) can have a separate child qdisc attached to it. This allows for very flexible and powerful configurations. For instance, band 0 (highest priority) might have a fq_codel qdisc for interactive traffic, ensuring low latency, while band 1 might have a tbf (Token Bucket Filter) qdisc to rate-limit bulk downloads, and band 2 might simply use a default sfq for fairness among remaining traffic.
HISTORY
The prio qdisc is one of the fundamental and earliest queuing disciplines implemented in the Linux kernel's traffic control subsystem. Its design is based on the traditional concept of strict priority queuing, making it a cornerstone for basic QoS implementations. It has been a standard part of the iproute2 suite (which includes the tc command) for a long time, providing a simple, efficient way to prioritize network traffic based on administrator-defined rules.
SEE ALSO
tc(8), tc-qdisc(8), tc-filter(8), tc-u32(8), tc-fw(8)