tc-sfb
Emulate network packet loss or corruption
SYNOPSIS
tc qdisc add ... sfq [ perturb SECONDS ] [ quantum BYTES ] [ limit PACKETS ] [ divisor DIVISOR ] [ hash HASH_ALGORITHM ]
PARAMETERS
perturb SECONDS
Specifies the interval in seconds at which the hashing algorithm is reinitialized. Default is 10 seconds. Re-initialization helps in preventing persistent unfairness due to unlucky hashing assignments.
quantum BYTES
Specifies the maximum number of bytes a flow is allowed to dequeue at once. Default is the MTU of the interface.
limit PACKETS
Sets the maximum number of packets allowed in the SFQ queue. Default is 128.
divisor DIVISOR
Determines the number of buckets into which traffic is divided. Must be a power of 2. Higher divisor means more flows can be handled separately, but requires more memory. Default is calculated from MTU.
hash HASH_ALGORITHM
Specifies the hashing algorithm to use for flow identification. Possible values: default, sdbm, jenkins, or random. 'random' will use a different seed each 'perturb' interval. Using the 'random' algorithm makes flows use a different hash at different intervals which provides better fairness but can have a performance impact.
DESCRIPTION
tc-sfb is a traffic control qdisc (queueing discipline) in Linux used to implement Stochastic Fairness Queueing (SFQ).
SFQ is a classless queueing discipline that aims to provide fairness by dividing traffic into multiple FIFO queues, each associated with a different flow. It uses a hashing algorithm to distribute packets among these queues.
SFQ avoids starvation of low bandwidth flows by preventing a single flow from monopolizing the queue. It is designed to be lightweight and simple to configure, making it suitable for environments where strict QoS is not required but fairness is desired. It's often used as a basic fairness mechanism before more complex queueing disciplines like HTB or HFSC are applied. SFQ's stochastic nature means it doesn't guarantee perfect fairness, but it provides a reasonable level of fairness with relatively low overhead.
CAVEATS
SFQ is a classless qdisc. It does not provide any hierarchical queueing or shaping capabilities. It only provides fairness among flows. It is not suitable for complex QoS scenarios.
HASHING ALGORITHMS
The choice of hashing algorithm affects the distribution of flows among the queues. Different algorithms have different properties regarding collision resistance and performance. If you suspect the default hash function is leading to unfairness, experiment with different algorithms. 'random' offers better fairness but can have a slight performance overhead.
WHEN TO USE SFQ
SFQ is a good choice when you want a simple and lightweight way to provide some level of fairness among different network flows. It's particularly useful on interfaces where you don't want a single flow to saturate the bandwidth. Consider using more advanced queueing disciplines like HTB or HFSC if you need precise bandwidth control and prioritization.
SEE ALSO
tc(8), tc-htb(8), tc-hfsc(8), tc-fq_codel(8)