HTB(8)
โจ HTB(8) โ Hierarchy Token Bucket โจ
๐ NAME
okay so the manual page is HTB, which stands for Hierarchy Token Bucket ๐
๐งพ SYNOPSIS
tc qdisc ... dev dev ( parent classid | root) [ handle major: ] htb [
default minor-id ] [ r2q divisor ] [ offload ]
tc class ... dev dev parent major:[minor] [ classid major:minor ] htb
rate rate [ ceil rate ] burst bytes [ cburst bytes ] [ prio priority ] [
quantum bytes ]
๐ซ DESCRIPTION
bestie, HTB lets you control the outbound bandwidth on a given link ๐ฆ It can pretend to be several slower links and send different kinds of traffic down different fake links. Either way, you have to decide how to split the physical link into simulated links, and how to pick which simulated link a given packet should use ๐ซถ
HTB shapes traffic using the Token Bucket Filter algorithm. The big slay here is that it doesn't care about interface characteristics, so it doesn't need to know the underlying bandwidth of the outgoing interface โจ
๐ SHAPING ALGORITHM
Shaping works exactly as documented in tc-tbf (8) ๐
๐๏ธ CLASSIFICATION
Inside one HTB instance, you can have a bunch of classes ๐ธ Each class holds another qdisc, which is tc-pfifo(8) by default.
When a packet gets enqueued, HTB starts at the root and uses a few methods to figure out which class should get the data ๐ง
Without any weird uncommon config options, it's honestly pretty easy. At each node we look for an instruction, then head to the class that instruction points to. If that class is a barren leaf-node (no children), the packet gets enqueued right there ๐ If it's not a leaf yet, we run the whole thing again starting from that node.
At each node we visit, these actions happen in order, until one of them sends us to another node or ends the process:
- (i) Consult the filters attached to the class. If they send us to a leafnode, we're done. Otherwise, restart.
- (ii) If none of the above returned an instruction, enqueue at this node.
This algorithm makes sure a packet always ends up somewhere, even while you're busy building your config ๐
๐ LINK SHARING ALGORITHM
FIXME ๐ (yes, this one is still a FIXME, no cap)
๐ QDISC
The root of an HTB qdisc class tree has these parameters:
parent major:minor | rootโ This one is mandatory ๐ญ It decides where the HTB instance lives: either at the root of an interface, or inside an existing class.handle major:โ Like every other qdisc, HTB can get a handle. It should be just a major number followed by a colon. It's optional, but super useful if you're going to generate classes inside this qdisc ๐default minor-idโ Unclassified traffic gets sent to the class with this minor-id ๐ซถr2q divisorโ The divisor used to calculate quantum values for classes. Classes divide their rate by this number. The default value is10โจoffloadโ Offloads the HTB algorithm to hardware. This needs driver and device support, so check that first ๐ฅ
๐ฆ CLASSES
Classes come with a whole host of parameters to configure how they operate ๐
parent major:minorโ Where this class sits in the hierarchy. If it's attached directly to a qdisc and not to another class, the minor can be left out. Mandatory ๐classid major:minorโ Like qdiscs, classes can be named. The major number has to match the major number of the qdisc they belong to. Optional, but you'll need it if this class is going to have children ๐prio priorityโ During the round-robin process, classes with the lowest priority field get tried for packets first ๐โโ๏ธrate rateโ The maximum rate this class and all its children are guaranteed. Mandatory ๐ceil rateโ The maximum rate a class can send at, if its parent has bandwidth to spare. It defaults to the configured rate, which implies no borrowing ๐ โโ๏ธburst bytesโ How many bytes can be burst at ceil speed, on top of the configured rate. It should be at least as high as the highest burst of all its children ๐ฅcburst bytesโ How many bytes can be burst at "infinite" speed, aka as fast as the interface can transmit them. For perfect evening out, it should be at most one average packet. It should also be at least as high as the highest cburst of all its children โญquantum bytesโ The number of bytes to serve from this class before the scheduler moves on to the next class. The default is the rate divided by the qdisc'sr2qparameter. If you specify this,r2qgets ignored ๐ง
โ ๏ธ NOTES
โ ๏ธ okay this part is important, bestie: due to Unix timing constraints, the maximum ceil rate is not infinite and may actually be pretty low ๐ญ
On Intel, there are 100 timer events per second. The maximum rate is the rate at which burst bytes get sent each timer tick. From that, you can calculate the minimum burst size for a specified rate. For i386, a 10mbit rate requires a 12 kilobyte burst, because 100*12kb*8 equals 10mbit ๐ค
๐ SEE ALSO
tc(8)- HTB website:
http://luxik.cdi.cz/~devik/qos/htb/
๐ฉโ๐ป AUTHOR
Martin Devera <devik@cdi.cz>. This manpage is maintained by bert hubert <ahu@ds9a.nl> ๐ซถ
bye bestie ๐ง iproute2 ยท 10 January 2002 ยท HTB(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