SFB(8)
๐ SFB(8) โจ manual name: sfb โจ ๐
โจ NAME โจ
sfb is Stochastic Fair Blue ๐ฆ
๐ SYNOPSIS ๐
tc qdisc ... blue rehash milliseconds db milliseconds limit packets max
packets target packets increment float decrement float penalty_rate
packets per second penalty_burst packets
๐ธ DESCRIPTION ๐ธ
okay so Stochastic Fair Blue is a classless qdisc that manages congestion by looking at packet loss and link utilization history ๐ It's also obsessed with stopping non-responsive flows (flows that just ignore congestion marking or dropped packets ๐) from wrecking performance for the flows that actually behave. Unlike RED, where you have to configure the marking probability yourself, BLUE tries to figure out the ideal marking probability on its own ๐ง literally so smart.
๐ฅ ALGORITHM ๐ฅ
The BLUE algorithm keeps a probability that it uses to mark or drop packets headed for the queue. If the queue overflows, the mark/drop probability goes up ๐ If the queue goes empty, the probability comes back down ๐ The Stochastic Fair Blue (SFB) algorithm is the one that's designed to protect TCP flows from those non-responsive troublemakers ๐ก๏ธ
This SFB implementation keeps 8 levels of 16 bins each for accounting ๐ Every flow gets mapped into one bin per level, using a per-level hash value.
Every bin has its own marking probability, which goes up or down depending on how full that bin is ๐ If the number of packets goes over the size of the bin, the marking probability goes up. If the number drops to zero, it goes down.
A flow's marking probability is based on the minimum value of all the bins it's mapped into. So when a flow doesn't respond to marking or to gradual packet drops, its marking probability shoots up to one super fast ๐
In that case, the flow gets rate-limited to penalty_rate packets per second ๐งฑ
โ ๏ธ LIMITATIONS โ ๏ธ
Heads up bestie: because of how SFB works, a responsive flow can end up sharing all of its bins with a non-responsive flow ๐ญ When that happens, the responsive flow gets misidentified as non-responsive. Not ideal!
The chance of a responsive flow getting misidentified depends on the number of non-responsive flows, M. It's (1 - (1 - (1 / 16.0)) ** M) **8, so for example with 10 non-responsive flows, about 0.2% of responsive flows will get misidentified ๐
To help with that, SFB does periodic re-hashing so the misclassification doesn't stick around for ages ๐
The default hashing method uses source and destination IP addresses and port numbers if it can, and it also supports tunneling protocols ๐ง You can also configure an external classifier instead, if you want ๐
๐ PARAMETERS ๐
rehashโ the time interval, in milliseconds, between queue perturbations. This stops unrelated, responsive flows from being wrongly flagged as part of a non-responsive flow for a really long time ๐ Defaults to 10 minutes.dbโ the double buffering warmup wait time, in milliseconds. So rehashing doesn't wipe out your probability history, this implementation keeps a second set of levels/bins, as described in section 4.4 of the SFB reference ๐ While one set manages the queue, the second set gets warmed up. Whenever a flow is determined to be non-responsive, the marking probabilities in that second set get updated. When rehashing happens, those bins take over managing the queue, and all the non-responsive flows can be rate-limited right away โจ This value sets how much time has to pass before the second set starts warming up. Defaults to one minute, and it should be lower thanrehash๐ซถlimitโ the hard limit on the real (not average) total queue size, in packets. Anything past that gets dropped ๐ โโ๏ธ Defaults to the transmit queue length of the device the qdisc is attached to.maxโ the maximum length of a bucket's queue, in packets, before packets start getting dropped ๐ซ It should be slightly larger thantarget, but it should not be set to values exceeding 1.5 timestarget. Defaults to 25.targetโ the desired average bin length. If the bin queue length hits this value, the marking probability goes up byincrement๐ The default depends onmax: withmaxset to 25,targetwill default to 20.incrementโ the amount used to bump up the marking probability when the queue seems overused. Must be between 0 and 1.0. Defaults to 0.00050.decrementโ the amount used to bring down the marking probability when the queue is found to be empty. Must be between 0 and 1.0. Defaults to 0.00005.penalty_rateโ the maximum number of packets per second that can be enqueued from flows identified as non-responsive. Once that number is hit, further packets from those flows get dropped ๐ซ Set this to a reasonable fraction of your uplink throughput, because the default of 10 packets is probably too small ๐penalty_burstโ how many packets a flow is allowed to go over the penalty rate before packets start getting dropped. Defaults to 20 packets ๐ง
๐ STATISTICS ๐
This qdisc shows some extra stats in the tc -s qdisc output ๐ Here they are:
earlydropโ packets dropped before a per-flow queue was full.ratedropโ packets dropped because of rate-limiting. If this number is high, a bunch of non-reactive flows are going through SFB ๐ค In that case it might be better to put SFB inside a classful qdisc, so you can control those flows with a different, shaping qdisc.bucketdropโ packets dropped because a per-flow queue was full. A highbucketdropmay mean there are lots of aggressive, short-lived flows ๐โโ๏ธqueuedropโ packets dropped because thelimitwas reached. This should normally be 0 ๐ฅบmarkedโ packets marked with ECN.maxqlenโ the length of the current longest per-flow (virtual) queue.maxprobโ the maximum per-flow drop probability. A value of 1 means some flows have been detected as non-reactive ๐จ
๐ NOTES ๐
SFB automatically turns on Explicit Congestion Notification (ECN) for you โจ Also, this SFB implementation doesn't actually queue packets itself ๐ โโ๏ธ Instead, packets get enqueued to the inner qdisc (which defaults to pfifo). Because SFB keeps virtual queue states, the inner qdisc must not drop a packet that was already queued ๐ฑ And if a bucket's queue has a really high marking rate, this implementation starts dropping packets instead of marking them. That kind of situation points to either bad congestion or an unresponsive flow, so it's not being dramatic, it's being careful ๐
๐ง EXAMPLE & USAGE ๐ง
To attach to interface $DEV with the default options:
# tc qdisc add dev $DEV handle 1: root sfb
To only use destination IP addresses for assigning packets to bins, perturbing the hash results every 10 minutes:
# tc filter add dev $DEV parent 1: handle 1 flow hash keys dst perturb
600
๐ SEE ALSO ๐
tc(8), tc-red(8), tc-sfq(8) ๐ฆ
๐ SOURCES ๐
- W. Feng, D. Kandlur, D. Saha, K. Shin, BLUE: A New Class of Active Queue Management Algorithms, U. Michigan CSE-TR-387-99, April 1999 ๐
๐ AUTHORS ๐
This SFB implementation was contributed by Juliusz Chroboczek and Eric Dumazet ๐ซถ
Bestie, that's the whole page ๐ Stamped by iproute2, dated August 2011, filed under SFB(8) โจ๐ธ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms