tc-sfb
Emulate network packet loss or corruption
SYNOPSIS
tc qdisc add dev DEV root | parent CLASSID [handle MAJOR:] sfb [OPTIONS]
tc qdisc change dev DEV root | parent CLASSID [handle MAJOR:] sfb [OPTIONS]
tc qdisc replace dev DEV root | parent CLASSID [handle MAJOR:] sfb [OPTIONS]
tc qdisc show dev DEV sfb
PARAMETERS
limit PACKETS
Sets the maximum queue length for the entire SFB qdisc, specified in packets. The default is 2048 packets.
max_depth PACKETS
Defines the maximum queue depth for each individual hash bucket (cell) within SFB, in packets. The default is 128 packets.
target TIME
Specifies the desired target queueing delay that SFB aims to maintain, in milliseconds (e.g., '5ms'). The default is 5ms.
min_toks BYTES
Sets the minimum token bucket size for a cell, in bytes. This is part of the rate estimation mechanism. The default is 1000 bytes.
max_toks BYTES
Sets the maximum token bucket size for a cell, in bytes. The default is 2000 bytes.
scell_log LOG
Specifies the logarithmic base-2 size for the number of cells (hash buckets) SFB will use. For example, 'scell_log 7' means 2^7 = 128 cells. The default is 7.
p_log LOG
Defines a logarithmic base-2 value used in the probability calculation for dropping or marking packets when congestion is detected. The default is 11.
e_log LOG
Defines a logarithmic base-2 value used in the exponent calculation, influencing the aggressiveness of packet drops. The default is 11.
sfb_dont_log
A flag that disables SFB's internal logging. This can be useful during debugging or to slightly reduce overhead in production environments.
DESCRIPTION
The tc-sfb command configures the Stochastic Fair Blue (SFB) queuing discipline, an advanced Active Queue Management (AQM) mechanism for Linux Traffic Control. SFB is designed to prevent network congestion by proactively dropping or marking packets before queues become full. Unlike simpler mechanisms that treat all traffic uniformly, SFB maintains multiple internal 'cells' or 'bins' organized within a hash table. Each cell monitors the queueing behavior of a subset of network flows. When congestion is detected within a specific cell (i.e., its queue depth or rate exceeds a threshold), SFB probabilistically drops or marks packets belonging to flows mapped to that cell. This per-cell monitoring helps in isolating the impact of congested or misbehaving flows, preventing them from negatively affecting other, well-behaved flows. It is a more sophisticated variant of Random Early Detection (RED) and incorporates concepts from the Blue algorithm, aiming for improved fairness and responsiveness to network congestion.
CAVEATS
tc-sfb is considered a more experimental queuing discipline compared to widely adopted ones like FQ-CoDel or HTB. Its effectiveness heavily depends on proper tuning of its numerous parameters, which can be complex and network-specific. While designed for fairness and congestion avoidance, it might introduce higher CPU overhead due to its per-cell state management and hashing operations, especially on systems handling a very large number of concurrent flows. It is primarily suitable for active queue management (AQM) and congestion prevention rather than strict bandwidth guarantees or hard prioritization.
HOW SFB ACHIEVES FAIRNESS
SFB uses a hash function to map incoming packets to one of many internal 'cells' or 'bins' (determined by the scell_log parameter). Each cell effectively manages a small sub-queue and maintains its own state (e.g., queue depth, token bucket usage). By monitoring and reacting to congestion at the granularity of these cells, SFB can identify and penalize flows (or groups of flows) that are contributing disproportionately to congestion without affecting other, well-behaved flows that map to different cells. This isolation is key to its fairness properties and its ability to prevent a single 'rogue' flow from monopolizing bandwidth.
CONGESTION DETECTION AND PACKET MARKING/DROPPING
For each cell, SFB tracks its current queue depth and the rate of traffic passing through it using token buckets. When a cell's queue depth exceeds its configured threshold (max_depth) or its rate indicates congestion, SFB calculates a dropping probability based on the severity of congestion and its configured p_log and e_log parameters. Packets are then probabilistically dropped or, if supported, marked with Explicit Congestion Notification (ECN) to signal congestion to endpoints. This allows endpoints to proactively reduce their transmission rate, helping to mitigate congestion before it leads to severe packet loss.
HISTORY
Stochastic Fair Blue (SFB) emerged as an advanced queuing discipline aiming to overcome limitations of earlier active queue management (AQM) algorithms like Random Early Detection (RED). While RED improved upon simple tail-drop by proactively dropping packets, it struggled with fairness among different flows and could be sensitive to bursty traffic. SFB incorporates concepts from the 'Blue' algorithm, which dynamically adjusts congestion thresholds, and introduces a stochastic element via hashing to map flows to distinct queue 'cells'. This design allows for more granular congestion control, isolating misbehaving flows and enhancing fairness, making it a notable evolution in network queue management strategies.
SEE ALSO
tc(8), tc-qdisc(8), tc-red(8), tc-fq_codel(8), tc-htb(8), tc-prio(8)