Fact-checked by Grok 2 weeks ago

Fair queuing

Fair queuing is a family of scheduling algorithms used in packet-switched computer networks to allocate equitably among multiple competing flows, ensuring that resources are shared proportionally and preventing any single flow from monopolizing the link capacity. Introduced as a congestion control mechanism for datagram networks, it approximates the ideal generalized processor sharing (GPS) model by serving packets in a manner that mimics bit-by-bit service across flows, thereby providing isolation, lower delays for moderate flows, and protection against misbehaving sources compared to traditional first-come-first-served queuing. The concept originated with John Nagle's 1985 suggestion in RFC 970 to use per-destination queues serviced in fashion to mitigate issues like the TCP and promote fairness in gateways with infinite storage assumptions. This idea was formalized and analyzed in 1989 by Demers, Keshav, and Shenker, who proposed a that emulates service through virtual time stamps on packets, demonstrating via simulations its advantages in allocation and delay bounds. A significant extension came in 1993 with Parekh and Gallager's development of weighted fair queuing (WFQ), or packet-by-packet GPS (PGPS), which incorporates weights to support in integrated networks while bounding delays independently of other flows' under admission control. Subsequent variants have addressed implementation challenges and scalability. Stochastic fair queuing (SFQ), introduced in 1990, uses hashing to approximate fairness with lower per-flow state overhead by randomly binning flows into a fixed number of queues and applying dequeuing. Deficit (DRR), proposed in 1995, simplifies WFQ by using a credit system to handle variable packet sizes without timestamps, achieving near-WFQ with reduced complexity suitable for hardware . These algorithms are widely deployed in routers and switches to enforce (QoS), supporting applications from to bulk data transfer by ensuring predictable and fairness across diverse traffic classes.

Overview

Definition and Motivation

Fair queuing refers to a class of scheduling algorithms employed in network devices, such as routers, to allocate equitably among competing . In packet-switched networks, a consists of a of packets sharing the same source-destination pair, and the link capacity R represents the total transmission rate available on the outgoing interface. These algorithms approximate an idealized bit-by-bit discipline, where is divided equally by servicing tiny portions of each in a cyclic manner, ensuring that no single monopolizes the resource. The primary motivation for arises from the limitations of traditional first-in-first-out () queuing, which uses a single for all incoming packets and services them in arrival order. suffers from , where a packet at the front of the delays all subsequent packets regardless of their flow, and it permits of low-rate flows by allowing high-rate or large-packet flows to dominate the link. This lack of flow isolation enables ill-behaved sources to capture an arbitrarily large share of , adversely affecting well-behaved and exacerbating . A classic example illustrates these issues: consider a router with a single queue handling two flows—a bulk sending large packets at a high rate and an interactive session sending small packets sporadically. The file transfer can occupy most of the link capacity R, causing excessive delays for telnet packets queued behind it, potentially rendering the interactive session unresponsive. Fair queuing mitigates this by maintaining separate queues per flow and servicing them proportionally, allowing the telnet flow to receive its fair share of without interference from the bulk transfer.

Basic Operation

Fair queuing operates by maintaining a separate for each distinct , typically identified by source-destination pairs or additional numbers, allowing packets from different conversations to be isolated and managed independently. This structure contrasts with traditional first-in-first-out () queuing, where a single misbehaving with large packets can dominate the and starve others of . The service process assigns a virtual finish time to each arriving packet, computed as the maximum of its virtual start time (the time when the is eligible to send) and the previous packet's finish time in the , plus the packet's transmission time scaled by the 's fair share (R/N for N equal-share flows). Packets are then served from the head of their 's in order of increasing virtual finish times, emulating bit-by-bit service across flows. This ensures that each receives a proportional share of regardless of packet sizes or arrival patterns. For the case of equal packet sizes, this process approximates , where each active flow receives approximately an equal share of the available , specifically R/N, where R is the and N is the number of active flows. This allocation promotes fairness by ensuring that no flow is unduly penalized or favored, leading to more predictable performance across diverse traffic types. To illustrate, consider a with two flows (A and B) sharing a 1 Mbps capacity, where packets are 1000 bits each. Flow A arrives with packets at times 0, 1, and 3 ms, while Flow B arrives with packets at 0.5 and 2 ms. The scheduler serves alternately:
  • At t=0: Serve A's first packet (0-1 ms).
  • At t=1: Serve B's first packet (1-2 ms).
  • At t=2: Serve A's second packet (2-3 ms).
  • At t=3: Serve B's second packet (3-4 ms), then A's third (4-5 ms).
Thus, each transmits roughly 500 kbps, balancing the shares despite uneven arrivals.

Historical Development

Origins in Networking

The concept of fair queuing originated in the mid-1980s as a response to severe congestion problems in early networks, particularly during the era. John Nagle, in his 1984 RFC 896, first documented the phenomenon of congestion collapse, where bursty traffic from multiple sources overwhelmed shared links, leading to excessive retransmissions and dropping to near zero as gateways connected networks of differing bandwidths. This instability was exacerbated by the lack of mechanisms to isolate traffic , causing synchronized behavior among connections that amplified overload on gateways. Building on these observations, Nagle proposed an initial fair queuing approach in his 1985 RFC 970, advocating for at packet switches to achieve congestion avoidance. In this scheme, a single first-in-first-out () queue per outgoing link would be replaced with multiple s—one per source host—to ensure equitable sharing and prevent any single host from monopolizing the link due to bursty transmissions. Switches would service these queues in a fashion, dequeuing one packet from each non-empty queue in turn, while using "Source Quench" messages to signal hosts when queues exceeded a small threshold (e.g., two packets), thereby maintaining low and avoiding infinite storage buildup under overload. This per-source queuing idea laid the groundwork for isolating flows, reducing the risk of global synchronization where all connections simultaneously ramp up transmission rates and then back off, a problem Nagle anticipated in heterogeneous networks. By apportioning fairly among active sources, the approach aimed to stabilize networks against the collapse seen in interconnections, such as those between high-speed local networks and slower wide-area links.

Key Milestones and Publications

The foundational publication on fair queuing appeared in 1989 with the paper "Analysis and Simulation of a Fair Queuing Algorithm" by Alan Demers, Srinivasan Keshav, and , presented at ACM SIGCOMM. This work introduced byte-weighted fair queuing as a mechanism to ensure packet-level fairness in packet-switched networks by approximating bit-by-bit service through the use of virtual finishing times. Building on John Nagle's earlier conceptual suggestion of queuing in RFC 970, the paper provided both analytical models and results demonstrating improved allocation and reduced variance in delays compared to first-come-first-served queuing. Demers, Keshav, and Shenker played key roles in formalizing the core principles: the trio developed the virtual time mechanism to emulate idealized bit-by-bit without requiring packet transmission, addressing practical implementation challenges in gateways. Their contributions shifted focus from coarse-grained to fine-grained , influencing subsequent theoretical and practical developments. A significant extension came in 1993 with Abhay K. Parekh and Robert G. Gallager's paper on "A Generalized Sharing Approach to Flow Control in Networks," which introduced weighted fair queuing (WFQ) to support proportional bandwidth allocation among flows based on assigned weights, laying groundwork for . In the 1990s, fair queuing principles were integrated into broader (QoS) architectures, notably the (IntServ) framework outlined in RFC 1633, which used per-flow scheduling like weighted fair queuing to guarantee resource reservations for diverse traffic types. A practical , Stochastic Fair Queuing (SFQ), was proposed by Paul E. McKenney in 1990 to reduce per-flow state overhead by hashing flows into a fixed number of queues, achieving approximate fairness with lower computational cost suitable for high-speed routers. These milestones marked a transition from theoretical constructs to deployable mechanisms, enabling fair queuing implementations in networks for services like Available Bit Rate (ABR) and in routers for , thereby enhancing network stability and equity in shared infrastructures.

Theoretical Principles

Fairness Metrics

Fair queuing disciplines aim to allocate equitably among competing flows, with fairness serving as a core performance criterion. is defined as an allocation where the minimum rate received by any flow is maximized, ensuring that no flow can increase its rate without decreasing the rate of another flow that currently receives a lower rate. This concept ensures protection for low-bandwidth flows against domination by high-bandwidth ones, as discussed in early network studies such as Bertsekas and Gallager's work on data networks. Proportional fairness, in contrast, maximizes the product of the rates across all flows, balancing aggregate throughput with equitable shares and providing a logarithmic interpretation that favors flows based on their elastic demands. Quantitative metrics evaluate how closely a queuing discipline achieves these ideals. Jain's fairness index, a widely used measure, is computed as \left( \sum_{i=1}^{n} x_i \right)^2 / \left( n \sum_{i=1}^{n} x_i^2 \right), where x_i are the allocated rates to n flows and the index ranges from 0 (complete unfairness) to 1 (perfect equality). Another key metric is the deviation from idealized Generalized Processor Sharing (GPS), a fluid model where bandwidth is shared continuously in fixed proportions; packet-based approximations like fair queuing bound this deviation to ensure service delays remain within a small multiple of the GPS finish time, typically O(1) relative to packet transmission times. Challenges in achieving fairness arise from practical constraints, particularly variable packet sizes, which can distort shares since flows sending larger packets may receive disproportionate service in packetized systems approximating bit-level . Fair queuing addresses this through virtual time computations to emulate fluid fairness, but residual unfairness persists if packets arrive in bursts or sizes vary significantly, potentially leading to short-term imbalances. Flow isolation, another , requires strict separation of service guarantees to prevent one misbehaving flow from impacting others, which fair queuing enforces via per-flow queues but at the cost of increased overhead in high-flow scenarios. For example, consider a link with C shared by two s: one sending small packets of 100 bytes and another large packets of 1500 bytes. Without size , the large-packet could claim up to 15 times more than the small-packet per packet , yielding a Jain's of approximately 0.57 despite equal priorities, highlighting the need for byte-weighted adjustments to restore fairness. In weighted extensions, these metrics adapt to proportional shares, but unweighted cases prioritize equal division as the baseline ideal.

Weighted Generalizations

Weighted fair queuing (WFQ) generalizes the basic fair queuing mechanism by assigning weights \phi_i to individual flows or classes of traffic, enabling proportional allocation of such that flow i receives a share of \frac{\phi_i}{\sum_j \phi_j} of the total capacity R. This approach builds on the equal-weight case of basic fair queuing, where all flows receive identical shares, but allows for differentiated service based on predefined priorities. The ideal theoretical model for WFQ is Generalized Processor Sharing (GPS), a fluid approximation that serves traffic bit-by-bit in a weighted round-robin fashion. In GPS, the service rate for flow i is given by g_i = R \cdot \frac{\phi_i}{\sum_j \phi_j}, where R is the server's total service rate and the sum is over all active flows. This fluid model assumes infinitely divisible packets, providing a benchmark for analyzing packet-based approximations and ensuring worst-case guarantees on throughput and delay independent of other flows' behavior. By supporting variable weights, WFQ enables (QoS) differentiation, such as allocating higher shares to latency-sensitive traffic like voice over less urgent data flows, thereby prioritizing real-time applications in networks. This weighted allocation promotes efficient resource utilization while protecting well-behaved flows from misbehaving ones, a key advantage in congested environments.

Core Algorithms

Virtual Time Scheduling

Virtual time scheduling serves as a foundational mechanism in fair queuing to emulate the idealized generalized () discipline using discrete packet transmissions. In this approach, virtual time, denoted as V(t), functions as a that decouples the progression of service allocation from physical , advancing only during periods when the server is actively transmitting data. This clock tracks the cumulative service provided to backlogged flows in a manner that mirrors the fluid, bit-by-bit service of GPS, ensuring that the scheduler can approximate proportional bandwidth without requiring packet . The primary goal of virtual time is to determine the hypothetical completion times for packets under GPS, allowing the packet-by-packet generalized processor (PGPS) to select packets for transmission in an order that closely follows this ideal fluid model. Each i maintains a virtual start time S_i and finish time F_i for its packets, where the start time is set to the maximum of the previous packet's finish time or the current virtual time at arrival, and the finish time reflects the service duration proportional to the 's weight. The scheduler then selects the packet from the with the smallest virtual finish time, thereby preserving fairness by serving flows in the sequence they would complete under GPS. This mechanism ensures that no receives out of proportion to its allocated share during contention. A critical aspect of virtual time management is its handling of server idle periods, during which V(t) remains frozen to avoid artificially advancing service credits for non-busy flows. When the server resumes operation, virtual time continues from its last value, adjusted based on the weights of currently backlogged flows, which prevents unfair penalization of flows that were idle due to external factors like network variability. This freezing behavior maintains the integrity of the GPS emulation across discontinuous transmission periods. Virtual time thus underpins finish time computations in fair queuing by providing a consistent reference for timestamping packets.

Finish Time Computation

In fair queuing, the service order of packets is determined by computing a virtual finish time for each packet, which emulates the completion time that packet would have in an idealized fluid-based generalized processor sharing . This computation applies the current virtual time to assign timestamps that preserve fairness across flows while respecting per-flow packet ordering. For the p-th packet of flow i arriving at time t_p with length L_p, the virtual finish time F_p^i is given by F_p^i = \max\left( F_{p-1}^i, V(t_p) \right) + \frac{L_p}{\phi_i R}, where F_{p-1}^i is the virtual finish time of the previous packet from the same flow (with F_0^i = 0), V(t_p) is the system virtual time at arrival (advancing based on the weighted service to backlogged flows), \phi_i is the allocated weight for flow i (summing to 1 across all flows), and R is the link capacity. This formula incorporates virtual time as input to simulate proportional service allocation. In the unweighted case, where all active flows receive equal shares (\phi_i = 1/N for N flows), the simplifies to reflect uniform division, often expressed as F_p = \max(S_p, F_{\text{previous}}) + L_p / R with S_p = \max(t_p, F_{\text{previous}}) under the approximation that time closely tracks real arrival time during busy periods. The original unweighted uses F_i^\alpha = \max(F_{i-1}^\alpha, R(t_i^\alpha)) + P_i^\alpha, where R(t) is the virtual time (rounds completed) and P_i^\alpha is the packet size in normalized time units. To dequeue the next packet, the scheduler selects the head-of-line packet across all with the smallest virtual finish time, ensuring the emulated fluid order is approximated in the packet system. The use of \max(F_{p-1}^i, V(t_p)) handles bursts by preventing a flow from advancing its subsequent packets in time until the prior packet's slot elapses, thus avoiding any flow from disproportionately jumping ahead during high-rate periods.

Byte-Weighted Fair Queuing

In packet-based fair queuing, treating each packet equally regardless of size leads to unfair allocation in terms of bytes transmitted, as flows with smaller packets receive disproportionately more service opportunities and thus higher throughput. Byte-weighted fair queuing resolves this by emulating a bit-by-bit (or byte-by-byte) service discipline, ensuring that each flow receives an equal share of bytes over time rather than equal shares of packets. This adaptation promotes fairness at the of data volume, preventing short-packet flows from monopolizing at the expense of those with larger packets. The core of the algorithm involves computing a virtual finish time for each arriving packet to determine the transmission . Upon arrival, a packet's virtual start time S is set to the maximum of the current virtual time and the finish time of the previous packet from the same . The virtual finish time F is then calculated as F = S + \frac{L}{R}, where L is the packet length in bytes and R is the flow's fair share (typically the divided by the number of active flows). Packets are dequeued and transmitted in increasing of their virtual finish times, approximating the idealized model of generalized processor sharing where service is allocated proportionally to bytes. This mechanism ensures that the byte throughput remains balanced across flows, even with varying packet sizes. Implementation relies on a (such as a ) to efficiently select the packet with the minimum virtual finish time for transmission. Each packet arrival, departure, or flow update requires insertions or deletions in the queue, yielding an overall complexity of O(\log N) per packet operation, where N is the number of active flows. This logarithmic overhead is practical for typical network routers, balancing fairness with computational efficiency. For illustration, consider two flows sharing a link with of 1250 bytes per unit time with equal shares, so each gets R = 625 bytes per unit time. Flow 1 sends 400-byte packets, while Flow 2 sends 1000-byte packets. The first packet of Flow 1 finishes virtually at time 0.64 units ($400 / 625), followed by Flow 2's at 1.6 units ($1000 / 625). Subsequent packets from Flow 1 (finishing at 1.28, 1.92, etc.) interleave, allowing Flow 1 more transmissions to equalize byte service, resulting in both flows transmitting approximately 625 bytes per unit time on average.

Variant Algorithms

Weighted Fair Queuing

Weighted Fair Queuing (WFQ) extends the principles of byte-weighted Fair Queuing by incorporating configurable weights for each flow, enabling differentiated allocation to support (QoS) requirements in packet-switched networks. In the unweighted byte-weighted Fair Queuing, all flows receive equal shares of , but WFQ assigns a weight \phi_i to each flow i, proportional to its desired share, allowing higher-priority flows to receive a larger portion of the link capacity R. This generalization maintains the of an fluid-rate scheduler while handling discrete packets, ensuring that the virtual time advances based on the weighted fluid rate \phi_i / \sum \phi_j for active flows. The core of WFQ involves computing a virtual finish time for each arriving packet to determine scheduling order. Upon arrival of a packet p of L_p from i, the virtual time V at the packet's start is the maximum of the current system virtual time and the finish time of the previous packet in the same flow. The virtual time increment for the packet is then calculated as \Delta V = L_p / (\phi_i \cdot R), and the packet's virtual finish time is F_p = V + \Delta V. Packets are dequeued in increasing order of their virtual finish times, approximating the service that would be provided under a weighted model. This mechanism ensures that is allocated according to weights even under varying loads. WFQ provides strong guarantees on performance and fairness, including worst-case delay bounds that are within one maximum packet transmission time of those under Generalized Processor Sharing (GPS), offering O(1) relative delay independent of the number of N. Additionally, it achieves flow isolation by bounding the impact of any misbehaving on others, preventing one from monopolizing resources and ensuring that compliant flows receive their entitled shares. These properties make WFQ effective for protecting latency-sensitive traffic from bursty or adversarial sources. WFQ forms the basis for practical implementations in and has been standardized as a foundational QoS mechanism. Cisco Systems adopted WFQ in their routers starting in the mid-1990s, integrating it with flow-based classification for efficient congestion management. The (IETF) has referenced WFQ principles in recommendations for and architectures, such as in RFC 2205 for and subsequent QoS frameworks.

Deficit Round Robin

Deficit Round Robin (DRR) is a packet scheduling algorithm designed as an efficient approximation to (WFQ), providing near-optimal fairness with significantly reduced computational overhead. It was proposed by M. Shreedhar and G. Varghese in specifically for in high-speed routers, addressing the challenges of variable packet sizes in fair bandwidth allocation among multiple flows. In DRR, each flow maintains a dedicated queue along with two key parameters: a fixed quantum (a credit amount, typically set to a multiple of the maximum packet size, such as 500 bytes) and a deficit counter initialized to zero. The algorithm operates in a round-robin fashion, cycling through all active (non-empty) queues using a simple pointer. For a selected flow, the quantum is added to its current deficit counter. The scheduler then dequeues and transmits packets from that queue sequentially, subtracting each packet's size from the deficit counter after transmission, until either the counter reaches zero or below (in which case any negative remainder carries over as the deficit for the next round) or the queue becomes empty. This carry-over mechanism ensures that unused credits from small packets are preserved for future rounds, preventing starvation of flows with smaller packets. A primary advantage of DRR is its constant-time O(1) complexity per packet, achieved through the straightforward traversal without the need for per-flow or priority queues. Unlike WFQ, which requires O(log N) operations for maintenance and across N flows, DRR eliminates these by leveraging the counter to handle variable packet lengths directly in a cyclic manner. Regarding fairness, DRR approximates the ideal fluid-model fairness of WFQ within a bound proportional to the maximum packet size, ensuring that no flow receives more or less than its entitled share by more than one packet's worth over time, which is sufficient for most network applications.

Modern Applications

Quality of Service in Networks

Fair queuing plays a central role in (QoS) mechanisms within networks, particularly through its integration with (DiffServ), where it enables per-class queuing to allocate bandwidth equitably among traffic classes such as expedited forwarding for low-latency needs and assured forwarding for controlled delays. In DiffServ architectures, fair queuing variants like Weighted Fair Queuing (WFQ) schedule packets based on class weights, ensuring that higher-priority classes receive proportional service without starving lower-priority ones, thus maintaining end-to-end QoS guarantees across domains. This integration addresses the limitations of simpler queuing by providing isolation between aggregated flows, which is essential for scalable QoS deployment in core routers. Stochastic Fair Queuing (SFQ), an approximation of fair queuing, further enhances isolation in routers by hashing packet s into a fixed number of queues (typically to 128) using identifiers like source and destination addresses and ports, thereby approximating per- fairness without maintaining state for every individual . SFQ ensures that short-lived or low- s are not overwhelmed by long-lived high- ones, promoting statistical fairness in environments with thousands of concurrent connections. The IETF's 2309 highlights the value of such per- scheduling approaches, including fair queuing, for mitigating and achieving approximate allocation in routers, recommending their use alongside to preserve . One key benefit of fair queuing in QoS is its ability to prevent TCP greediness, where flows with shorter round-trip times or aggressive retransmissions could otherwise monopolize link capacity, starving other connections; by enforcing proportional sharing, it protects responsive traffic from unresponsive or misbehaving flows. This isolation is particularly vital for supporting real-time applications like (VoIP), as fair queuing assigns dedicated or weighted queues to latency-sensitive UDP-based VoIP packets, minimizing and delay variations even when coexisting with bulk data transfers. In modern IP routers, extensions like Flow Queuing with Controlled Delay (FQ-CoDel) combine fair queuing with to combat , delivering low latency for interactive while maintaining fairness; FQ-CoDel hashes flows into queues and applies drop policies per queue, reducing queueing delays to under 5 ms for typical links even under load.

Cloud Computing and 5G

In environments, fair queuing principles are applied to ensure equitable among virtual machines (), mitigating issues such as resource monopolization by individual tenants. For instance, measurement-based fair queuing (MBFQ) allocates proportionally to VMs based on observed usage, allowing a VM to achieve its allocated share within three scheduling intervals while reclaiming idle bandwidth in five periods. This approach addresses noisy neighbor problems by dynamically adjusting shares without requiring precise a priori of patterns. Similarly, in container orchestration platforms like , schedulers such as Apache YuniKorn implement hierarchical fair sharing, which draws from fair queuing to balance CPU, memory, and GPU resources across pods, preventing any single workload from dominating cluster capacity during AI and tasks. In networks, weighted fair queuing (WFQ) variants support multi-slice radio access networks (RAN) by dynamically allocating resources among diverse services like enhanced mobile broadband (eMBB) and ultra-reliable low-latency communications (URLLC). Dynamic weighted fair queuing (DWFQ) in multi-slice setups ensures fairness across virtual operators by adjusting weights based on slice priorities, maintaining isolation while optimizing throughput for eMBB traffic and latency for URLLC. specifications from Release 16 onward incorporate scheduling mechanisms akin to WFQ for network slicing, as studied in frameworks that guarantee minimum data rates and fairness levels in coexistence scenarios. These adaptations enable efficient handling of heterogeneous traffic in sliced architectures, with open-source implementations using WFQ queues to prioritize eMBB and URLLC flows via . Recent advancements post-2020 integrate to optimize WFQ for adaptive weight assignment in dynamic environments. For example, deep reinforcement learning-based WFQ (WFQ continual-DRL) dynamically tunes queue weights in response to varying demands, improving fairness and throughput in and contexts compared to static methods. In active (AQM), FQ-CoDel combines fair queuing with controlled delay to combat , reducing latency under mixed traffic loads in New Radio (NR) scenarios in simulations compliant with 7928 guidelines. These developments address gaps in disaggregated RAN and by employing ML-driven AQM to manage buffers across centralized and distributed units, enhancing performance in low-latency edge applications without exacerbating congestion.

Implementation Aspects

Pseudocode and Examples

Fair queuing algorithms can be implemented using a per-flow queue structure, where each packet is assigned a finish time upon enqueuing, and the scheduler selects the packet with the minimum finish time for dequeuing. This approach approximates the bit-by-bit round-robin service discipline described by Demers, Keshav, and Shenker. For simplicity, assume the link capacity C is normalized to 1 (e.g., service times equal packet sizes in bytes), virtual time V starts at 0, and there is one queue per flow. Packets are enqueued with finish time F = \max(V, F_{\text{last}}) + S, where S is the packet size and F_{\text{last}} is the finish time of the previous packet in that flow (0 initially). Upon dequeuing, the server advances V to the finish time of the selected packet. If the server is idle when a packet arrives, set V to the current real time (also normalized). The following pseudocode outlines the core operations for byte-weighted fair queuing (equal weights across flows):
Initialize:
- V = 0  // current virtual time
- For each flow f: queue_f = empty, F_last_f = 0
- Use a global priority queue (min-heap) keyed by finish time F to hold all packets across flows

Enqueue(packet p for flow f, arrival time t, size S):
    if server idle and t > V:
        V = t  // update virtual time on idle periods
    F = max(V, F_last_f) + S
    insert p into queue_f with tag F
    insert (F, p, f) into global priority queue
    F_last_f = F

Dequeue():
    if global priority queue empty:
        idle
    else:
        extract min (F_min, p, f) from global priority queue
        remove p from queue_f
        V = F_min  // advance virtual time
        transmit p
        if queue_f not empty:
            // next packet in flow f will use updated F_last_f
This implementation selects the eligible packet with the smallest finish time in O(\log N) time per operation, where N is the number of packets, using a priority queue. For the weighted extension, as introduced by and Gallager, with flow weights \phi_f (where higher \phi_f implies higher share), the finish time computation adjusts the service allocation proportionally: F = \max(V, F_{\text{last}_f}) + S / \phi_f. The virtual time V advances such that active flows receive bandwidth shares proportional to their weights. This ensures flows receive bandwidth shares \phi_f / \sum \phi_f of the link capacity. To illustrate, consider a step-by-step of three flows (A, B, C) with equal weights and link capacity 1. Flow A sends packets of sizes 1, 2 (at t=0), then 3 (at t=3). Flow B sends size 4 (at t=0). Flow C sends size 1 (at t=1). Virtual time V=0 initially.
  • t=0: Enqueue A's first packet (size 1): F_{A1} = \max(0,0) + 1 = 1. Enqueue A's second (size 2): F_{A2} = \max(0,1) + 2 = 3. Enqueue B's (size 4): F_B = \max(0,0) + 4 = 4.
  • Dequeue: Select min F=1 (A1), set V=1.
  • t=1: Enqueue C's (size 1): F_C = \max(1,0) + 1 = 2.
  • Dequeue: Select min F=2 (C), set V=2.
  • Dequeue: Select min F=3 (A2), set V=3.
  • t=3: Enqueue A's third (size 3): F_{A3} = \max(3,3) + 3 = 6.
  • Dequeue: Select min F=4 (B), set V=4.
  • Dequeue: Select F=6 (A3), set V=6.
This example demonstrates how fair queuing interleaves service across flows based on virtual finish times, protecting moderate flows from large ones and approximating equal shares over time.

Performance and Complexity

Fair queuing algorithms exhibit varying computational complexities depending on their implementation. Weighted Fair Queuing (WFQ) typically requires O(log N) time per packet operation, where N is the number of active flows, primarily due to the use of a (such as a ) for packets by their virtual finish times. In contrast, Deficit Round Robin (DRR) achieves O(1) per packet through a simple traversal of queues, augmented by a deficit counter to handle variable packet sizes without . Performance metrics for fair queuing emphasize guarantees on fairness and . Fairness is typically bounded such that the difference in service received by any two deviates by at most the maximum packet size from their entitled shares, ensuring proportional allocation even under bursty . For , WFQ provides a worst-case delay bound that approximates the idealized Generalized Processor Sharing (GPS) scheduler, specifically within one maximum packet transmission time of the GPS delay, which for a flow with ρ_i and burstiness constraints remains independent of the total number of flows N. Scalability trade-offs arise with high flow counts, as WFQ's O(log N) operations become prohibitive in routers handling thousands of concurrent flows, leading to increased processing overhead. To mitigate this, approximations like (SFQ) employ hashing to map flows to a fixed number of bins, reducing complexity to O(1) while preserving fairness in expectation, though with a small probability of minor inaccuracies. Optimizations for fair queuing include hardware accelerations in Application-Specific Integrated Circuits () and Field-Programmable Gate Arrays (FPGAs), which enable high-throughput implementations suitable for modern networks. For instance, dedicated WFQ architectures in can process packets at rates up to 50 Gb/s (as of 2011) by parallelizing queue management and timestamp computations. Recent FPGA implementations, such as those for multi-tenant cloud and networks as of 2025, support scalable fair scheduling at 100 Gb/s and beyond, facilitating low-latency QoS enforcement in programmable switches.

References

  1. [1]
    RFC 7806: On Queuing, Marking, and Dropping
    ### Extracted Sections on Fair Queuing
  2. [2]
    Analysis and simulation of a fair queueing algorithm
    Analysis and simulation of a fair queueing algorithm. Authors: A. Demers ... Computer Networks (LCN)10.1109/LCN65610.2025.11146365(1-7)Online publication ...
  3. [3]
    RFC 970 - On Packet Switches With Infinite Storage - IETF Datatracker
    This effect will happen sooner with fair queuing than with first in, first out queuing, because the badly- behaved host will only obtain a share of the ...
  4. [4]
    A generalized processor sharing approach to flow control in ...
    A generalized processor sharing approach to flow control in integrated services networks: the single-node case. Abstract: The problem of allocating ...
  5. [5]
    Efficient fair queueing using deficit round robin - ACM Digital Library
    Fair queuing is a technique that allows each flow passing through a network ... Demers, S. Keshav, and S. Shenker. Analysis and simulation of a fair ...
  6. [6]
    Analysis and simulation of a fair queueing algorithm
    that fair queueing provides several important advantages over the usual first-come-first-serve queueing algorithm: fair allocation of bandwidth, lower delay for ...
  7. [7]
    6.2 Queuing Disciplines - Computer Networks: A Systems Approach
    Fair queuing (FQ) is an algorithm that has been designed to address this problem. The idea of FQ is to maintain a separate queue for each flow currently being ...
  8. [8]
    23 Queuing and Scheduling - An Introduction to Computer Networks
    In this (special) case – sometimes called Nagle fair queuing, and proposed in RFC 970 – the router simply services the per-class subqueues in round-robin ...
  9. [9]
    RFC 896 - Congestion Control in IP/TCP Internetworks
    This memo discusses some aspects of congestion control in IP/TCP Internetworks. It is intended to stimulate thought and further discussion of this topic.Missing: early | Show results with:early
  10. [10]
    Analysis and simulation of a fair queueing algorithm
    Analysis and simulation of a fair queueing algorithm. We discuss gateway ... View or Download as a PDF file. PDF. eReader. View online with eReader ...
  11. [11]
    Stochastic fairness queueing | IEEE Conference Publication
    Abstract: A class of algorithms called stochastic fairness queuing is presented. The algorithms are probabilistic variants of fairness queuing.
  12. [12]
  13. [13]
    [PDF] Priority service and max-min fairness - Electrical Engineering
    In Section III, we provide the definition of a max-min fair rate allocation and introduce a fairness criteria for a price-based bandwidth allocation schemes. In ...
  14. [14]
    [PDF] shadow prices, proportional fairness and stability
    In a network with a single bottleneck resource max±min fairness implies an equal share of the resource for each flow through it. Mazumdar et al14 have pointed ...
  15. [15]
    [PDF] A Quantitative Measure of Fairness and Discrimination for Resource ...
    Sep 26, 1984 · The fairness index always lies between 0 and 1. This boundedness aids intuitive understanding of the fairness index. For example, a distribution ...Missing: queuing | Show results with:queuing
  16. [16]
    [PDF] Analysis and Simulation of a Fair Queueing Algorithm
    Fair queueing maintains separate queues for each source, serviced round-robin, preventing sources from arbitrarily increasing their bandwidth or delay of ...
  17. [17]
    [PDF] A Generalized Processor Sharing Approach to Flow Control in ...
    Sci., M.I.T., Feb. 1992. A, K, Parekh and R. G. Gallager, “A genersdized processor sharing approach to flow'control-'Tbe.
  18. [18]
    [PDF] Fair Queueing: Demers, Keshav, Shenker [Demers89a]
    want to have smart routers to control congestion. • routers can enforce fair allocation of bandwidth. • why? – can prevent malicious users from hurting ...
  19. [19]
    [PDF] Analysis and Simulation of a Fair Queueing Algorithm
    Analysis and Simulation of a Fair Queueing Algorithm. Alan Demers. Srinivasan Keshav . Scott Shenker. Xerox PARC. 3333 Coyote Hill Road. Palo Alto, CA 94304.
  20. [20]
    WF/sup 2/Q: worst-case fair weighted fair queueing - IEEE Xplore
    In particular, it has been proven that the delay bound provided by WFQ is within one packet transmission time of that provided by GPS. We show that ...
  21. [21]
    Chapter: Configuring Weighted Fair Queueing - Cisco
    Jan 30, 2008 · This module describes the tasks for configuring flow-based weighted fair queueing (WFQ), distributed WFQ (DWFQ), and class-based WFQ (CBWFQ) ...
  22. [22]
    RFC 4594 - Configuration Guidelines for DiffServ Service Classes
    In a rate-based queuing system, such as Weighted Fair Queuing (WFQ) or Weighted Round Robin (WRR), the delay that a packet in any given queue will ...
  23. [23]
  24. [24]
    [PDF] Stochastic fairness queueing - Duke Computer Science
    Fairness queuing has recently been proposed as an effective way to insulate users of large computer communication data- gram networks from congestion caused ...
  25. [25]
    RFC 2309 - Recommendations on Queue Management and ...
    This memo presents two recommendations to the Internet community concerning measures to improve and preserve Internet performance.Missing: SFQ | Show results with:SFQ
  26. [26]
    [PDF] The Role of End-to-End Congestion Control in Networks with ...
    Increasingly, however, network operators are deploying fair queuing and other forms of router-based enforcement mechanisms to prevent greedy or misbehaving.<|control11|><|separator|>
  27. [27]
    Quality of Service for Voice over IP - Cisco
    Apr 13, 2001 · The most flexible queueing method that satisfies VoIP requirements is LLQ. LLQ uses the MQC configuration method to provide priority to certain ...
  28. [28]
    Measurement Based Fair Queuing for Allocating Bandwidth to ...
    We show that MBFQ allows a VM to obtain its allocated bandwidth in X scheduling intervals, and that idle bandwidth is reclaimed within Y periods. An ...
  29. [29]
    Sorting Policies - Apache YuniKorn
    A parent queue will always use the fair policy to sort the child queues. The ... All other resource types have consistent naming between YuniKorn and Kubernetes.
  30. [30]
    Resource allocation scheme for eMBB and uRLLC coexistence in ...
    Apr 16, 2023 · An optimal resource allocation scheme is proposed with two scenarios including a guaranteed fairness level and minimum data rate among eMBB users.
  31. [31]
    [PDF] Realization of 5G Network Slicing Using Open Source Softwares
    Dec 7, 2020 · OpenFlow commands are used to create Queues to the corresponding ports, and Weighted Fair Queue (WFQ) is used ... both eMBB and URLLC ...
  32. [32]
    Optimizing Weighted Fair Queuing with Deep Reinforcement ... - MDPI
    In communication networks, WFQ is a crucial scheduling discipline used to ensure fairness and QoS. Using a weight-based bandwidth allocation approach, WFQ ...<|control11|><|separator|>
  33. [33]
    Study of 5G NR Network Against Mixed Traffic - IEEE Xplore
    It evaluates the performance of various AQM algorithms like CoDel, FQ-CoDel, COBALT, PIE, and FQ-PIE in a 5G New Radio network scenario based on RFC 7928.
  34. [34]
    (PDF) Active Queue Management in Disaggregated 5G and Beyond ...
    May 24, 2024 · Using CN²F, we implement different network scenarios, including Edge Computing (EC), Cloud Computing (CC), and Radio Access Network (RAN) ...
  35. [35]
    [PDF] Efficient Fair Queuing using Deficit Round Robin
    Fair Queuing: Demers,. Keshav and. Shenker devised an ideal algorithm called bit–by–bit round robin. – (BR) which solves the flaw in Nagle's solution. In the.
  36. [36]
    [PDF] Efficient Fair Queuing using Deficit Round Robin - cs.wisc.edu
    Abstract. Fair queuing is a technique that allows each flow passing through a network device to have a fair share of network resources.
  37. [37]
    [PDF] WF2Q: Worst-case Fair Weighted Fair Queueing - Purdue Engineering
    In this paper, we will show that, contrary to popular belief, there could be large discrepancies be- tween the services provided by the packet WFQ sys- tem and ...