tc-pfifo_fast
Prioritize network traffic using multiple FIFO queues
SYNOPSIS
tc qdisc add dev DEV root pfifo_fast [ limit PACKETS ]
tc qdisc change dev DEV root pfifo_fast [ limit PACKETS ]
PARAMETERS
dev DEV
Specifies the network device (e.g., `eth0`, `ens33`) to which the `pfifo_fast` queuing discipline will be attached.
root
Indicates that `pfifo_fast` should be installed as the main (root) queuing discipline for the specified device. `pfifo_fast` is a classless qdisc and cannot contain other qdiscs.
limit PACKETS
Sets the maximum number of packets that the `pfifo_fast` qdisc can hold across all its bands. If this option is omitted, the default limit is typically 1000 packets.
DESCRIPTION
The `pfifo_fast` (Priority First-In, First-Out) queuing discipline is the default qdisc for many Linux network interfaces. It implements a basic but effective priority-based queuing mechanism. It divides incoming packets into three distinct bands (priorities): band 0 (highest priority), band 1 (medium priority), and band 2 (lowest priority).
Packets are assigned to these bands primarily based on their IP precedence bits found in the Type of Service (ToS) field of the IP header, or, if ToS is not utilized, based on the `SO_PRIORITY` socket option set by applications. The `pfifo_fast` discipline always dequeues packets from the highest priority band that is not empty. It only proceeds to dequeue from band 1 when band 0 is empty, and similarly to band 2 only when both band 0 and band 1 are empty. Within each individual band, packets are processed in a strict FIFO manner.
This mechanism ensures that high-priority traffic (e.g., interactive SSH sessions, DNS queries) receives preferential treatment over lower-priority traffic (e.g., bulk data transfers), providing a rudimentary level of Quality of Service (QoS) without complex configuration. It is valued for its simplicity and low overhead.
CAVEATS
- `pfifo_fast` is a classless qdisc, meaning it cannot host or classify traffic into child qdiscs.
- It provides a very basic level of QoS based on fixed IP precedence or socket priority mappings and does not support advanced traffic shaping, rate limiting, or more granular classification rules.
- The mapping of IP precedence bits to priority bands is fixed and cannot be reconfigured by the user.
- While it prioritizes traffic, heavy constant high-priority traffic can starve low-priority traffic, and it doesn't inherently prevent bufferbloat as effectively as modern qdiscs like FQ-CoDel or CAKE.
PRIORITY BANDS AND PACKET CLASSIFICATION
`pfifo_fast` internally manages three priority bands:
- Band 0: Highest priority.
- Band 1: Medium priority.
- Band 2: Lowest priority.
- IP Precedence (ToS): Packets with IP precedence bits 0x00 (`Normal Service`, `Interactive`) are mapped to Band 0. Packets with precedence 0x20 (`Expedited Forwarding`, `Background`) are mapped to Band 1. Packets with precedence 0x40 (`Default`, `Best Effort`) and above (up to 0xE0) are mapped to Band 2.
- SO_PRIORITY: If the ToS field is zero, the `SO_PRIORITY` socket option (set by an application using `setsockopt`) can be used to assign a packet to a specific band. For example, a `SO_PRIORITY` value of 0 will typically map to Band 0, 1 to Band 1, and so on.
HISTORY
`pfifo_fast` has served as the default queuing discipline in Linux for many years due to its simplicity, low overhead, and reasonable performance for general-purpose network traffic. Its design predates many modern congestion control algorithms and bufferbloat mitigation techniques. While it remains a fundamental component of Linux networking, newer, more advanced queuing disciplines like `fq_codel` and `cake` are often adopted as defaults in modern Linux distributions to provide better performance under congestion, lower latency, and more robust fairness guarantees. Despite this, `pfifo_fast` is still widely used and understood for its straightforward operation.