HTB + fq_codel + CAKE: Detailed Queueing Behavior in LibreQoS
This page is the canonical queueing deep-dive companion to LibreQoS Backend Architecture.
It explains:
Why LibreQoS layers
HTBwith leaf qdiscs (fq_codelorCAKE)How
fq_codelworks in practiceHow
CAKEworks in practiceWhen to choose
fq_codelvsCAKEOperator troubleshooting and observability patterns
1) Why These Three Components Exist Together
In production LibreQoS:
HTBprovides hierarchical rate policy (rate,ceil, borrow, hierarchy)fq_codelorCAKEprovides per-flow queue service and AQM behavior inside each shaped envelope
This split is intentional:
Policy problem: “How much can this class send?” ->
HTBQueueing problem: “Which packet should send next while controlling latency?” ->
fq_codel/CAKE
2) Runtime Placement in LibreQoS
Conceptually, packets pass through:
mqrootHTBhierarchyleaf qdisc per shaped class (
CAKEby default,fq_codeloptional)
Operationally, this is commonly:
mq root -> per-CPU HTB parents -> per-circuit HTB classes -> leaf qdisc (cake diffserv4 or fq_codel)
Each HTB class has a child qdisc attachment point. If no explicit leaf qdisc is attached, behavior falls back to kernel default queueing for that class.
Practical LibreQoS behavior model:
Default behavior uses
HTB+cake diffserv4for shaped circuits.TreeGuard can dynamically switch circuit directions between
cake diffserv4andfq_codelbased on low-load/RTT guardrails.In LibreQoS v2.0, TreeGuard is enabled by default and operators should review its enrollment and guardrails if they want fixed/manual SQM behavior.
See TreeGuard for configuration and rollout details.
3) HTB Summary for AQM Users
3.1 Core HTB mechanics
Tokens are consumed by packet bytes and refill over time.
ratedefines guaranteed service.ceildefines borrowable maximum when parent capacity exists.Children borrow only from ancestor spare capacity.
Sibling contention is affected by
prio, scheduler behavior, and class proportions.
3.2 Key HTB controls
rate,ceilprioburst,cburstquantum,r2qdefaultclass minor ID (Linux HTB concept; see LibreQoS behavior note below)
3.3 Why this matters for fq_codel and CAKE
fq_codel and CAKE do not replace HTB’s hierarchy and class-rate policy. They shape queue service inside the class envelope HTB allows.
3.4 Undefined traffic behavior in LibreQoS
LibreQoS behavior is explicit here:
traffic not mapped to a shaped circuit is passed through
LibreQoS does not direct undefined traffic into HTB
defaultclassesHTB
defaultclass behavior still exists in Linuxtc, but it is not how LibreQoS handles undefined traffic
Operationally, this means troubleshooting undefined traffic starts with classification/mapping validation, not with HTB default-class tuning.
3.5 Compact HTB skeleton (reference pattern)
Illustrative Linux HTB+leaf pattern:
tc qdisc add dev <ifname> root handle 1: htb default 30
tc class add dev <ifname> parent 1: classid 1:1 htb rate 1gbit ceil 1gbit
tc class add dev <ifname> parent 1:1 classid 1:10 htb rate 700mbit ceil 1gbit prio 1
tc class add dev <ifname> parent 1:1 classid 1:20 htb rate 300mbit ceil 1gbit prio 2
tc class add dev <ifname> parent 1:1 classid 1:30 htb rate 10mbit ceil 1gbit prio 7
tc qdisc add dev <ifname> parent 1:10 cake diffserv4
tc qdisc add dev <ifname> parent 1:20 fq_codel
tc qdisc add dev <ifname> parent 1:30 cake diffserv4
tc filter add dev <ifname> protocol ip parent 1:0 prio 1 u32 match ip src <A>/32 flowid 1:10
tc filter add dev <ifname> protocol ip parent 1:0 prio 2 u32 match ip src <B>/32 flowid 1:20
In LibreQoS, queue/class commands are generated automatically and undefined traffic is passed through rather than sent to an HTB default class.
4) fq_codel Deep Dive
4.1 What fq_codel is
fq_codel combines:
stochastic flow queueing (hashed queues)
DRR-style fair scheduling across queues
CoDel AQM per queue
Core references:
tc-fq_codel(8)RFC 8290 (Flow Queue CoDel)
4.2 Scheduler behavior and sparse-flow benefit
FQ-CoDel maintains “new” and “old” active queue lists. Newly active queues are prioritized over persistent backlogged queues, which naturally benefits sparse/interactive traffic.
It also uses byte-credit (quantum) scheduling so fairness is byte-oriented, not packet-count oriented.
4.3 Flow hashing model
By default, packets are classified using a 5-tuple hash into a configurable number of buckets (flows). Hash collisions are possible and are a known tradeoff of stochastic queueing.
4.4 fq_codel parameters that operators actually tune
tc-fq_codel(8) parameters worth knowing:
limit PACKETS: hard queue packet cap (default10240)memory_limit BYTES: memory cap (default32MB), lower of limit and memory cap is enforcedflows NUMBER: hash buckets (default1024, set at creation time)target TIME: acceptable minimum persistent delay (default5ms)interval TIME: CoDel control window, generally order of worst RTT through bottleneck (default100ms)quantum BYTES: DRR deficit quantum (default1514)ecn/noecn: ECN on/off (ecnis default in fq_codel)ce_threshold TIME: shallow ECN marking threshold for DCTCP-style usece_threshold_selector VALUE/MASK: apply CE threshold only to selected trafficdrop_batch: max drop batch when limits exceed (default64)
4.5 fq_codel observability (tc -s qdisc show)
Common counters/fields to inspect:
dropped,overlimits,requeuesdrop_overlimitnew_flow_countecn_marknew_flows_len,old_flows_lenbacklog
Interpretation pattern:
Verify queue pressure exists (
backlog,requeues,overlimits)Check whether AQM signaling is engaged (
ecn_mark,dropped)Correlate
new_flows_len/old_flows_lenwith traffic mix (sparse vs bulk)
5) CAKE Deep Dive
5.1 CAKE architecture
CAKE integrates multiple layers in one qdisc:
deficit-mode shaper
priority queue (tins)
flow isolation (
DRR++)AQM (
COBALT, combining CoDel + BLUE)packet management and overhead compensation
Core references:
tc-cake(8)Bufferbloat CAKE and CakeTechnical pages
Piece of CAKE paper (
cake.pdf)
5.2 Shaped vs unshaped operation
When bandwidth is set, CAKE’s shaper and its derived tuning drive tin thresholds and timing behavior.
Without shaping (unlimited), CAKE still provides queue service and AQM logic, but tin and service behavior are no longer operating against a fixed shaped bottleneck target.
5.3 Flow isolation modes
CAKE supports multiple fairness modes:
flowblind(no flow isolation)flows(5-tuple flow fairness)srchost,dsthost,hostsdual-srchost,dual-dsthosttriple-isolate(default intc-cake(8))
Operational note:
triple-isolateis a safe general default when you need both per-flow and host fairness controls.
5.4 NAT awareness
nat/nonat controls whether CAKE performs NAT lookup before applying flow isolation.
Why it matters:
Without
nat, fairness sees post-NAT addresses only.With
nat, fairness can better represent internal hosts behind NAT (when NAT is on the same box/path).
5.5 DiffServ modes and tins
Main priority presets:
besteffort(single tin, no priority queue)diffserv3diffserv4diffserv8precedence(legacy, discouraged in modern deployments)
tc-cake(8) currently documents diffserv3 as default, while LibreQoS typically uses cake diffserv4 as operator-facing default policy.
5.6 LibreQoS diffserv4 DSCP mapping
LibreQoS commonly runs CAKE with diffserv4. Practical class mapping:
Latency Sensitive:
CS7,CS6,EF,VA,CS5,CS4Streaming Media:
AF4x,AF3x,CS3,AF2x,TOS4,CS2,TOS1Best Effort:
CS0,AF1x,TOS2, and unrecognized codepointsBackground Traffic:
CS1
Known codepoints in common operator use:
CS1(Least Effort)CS0(Best Effort)TOS1(Max Reliability / LLT “Lo”)TOS2(Max Throughput)TOS4(Min Delay)TOS5(LLT “La”)AF1xAF2xAF3xAF4xCS2CS3CS4CS5CS6CS7VAEF
RFC 4594-style traffic-class framing (high-level):
Network Control:
CS6,CS7Telephony:
EF,VASignaling:
CS5Multimedia Conferencing:
AF4xRealtime Interactive:
CS4Multimedia Streaming:
AF3xBroadcast Video:
CS3Low Latency Data:
AF2x,TOS4Ops/Admin/Management:
CS2,TOS1Standard Service:
CS0and unrecognized codepointsHigh Throughput Data:
AF1x,TOS2Low Priority Data:
CS1
fq_codel note:
fq_codelhas no CAKE tin model and no CAKE-style DSCP class scheduler.DSCP marking can still be used by external classification/policy, but not via CAKE
diffserv4tin behavior.In LibreQoS, DSCP priority behavior described above applies when CAKE with
diffserv4is selected.
5.7 Overhead and framing compensation
CAKE can account for link-layer overhead/framing using:
overhead Nmpu Natm,ptm,noatmshortcut keywords (
ethernet,docsis, etc.)rawandconservative
Operator rule:
If overhead/framing is wrong, shaping accuracy is wrong. Validate with realistic traffic tests.
5.8 GSO handling (split-gso)
By default, CAKE splits GSO superpackets to reduce latency impact on competing flows, especially at lower rates.
At very high link rates (e.g. >10 Gbps), no-split-gso can improve peak throughput, but may trade away latency smoothness.
5.9 ACK filtering
CAKE supports:
ack-filterack-filter-aggressiveno-ack-filter(default)
Best use case is asymmetric links where upstream ACK load limits downstream goodput. Apply conservatively and validate with application traffic, not only synthetic tests.
5.10 Ingress mode and autorate
ingress mode changes accounting and tuning for downlink shaping realities (including counting dropped packets as already-transited data).
autorate-ingress can estimate capacity from arriving traffic and is primarily useful on highly variable links (for example some cellular paths). It cannot estimate bottlenecks downstream of where CAKE is attached.
5.11 CAKE observability (tc -s qdisc show)
Useful fields commonly present:
top-level:
dropped,overlimits,backlog,memory used,capacity estimateper tin:
thresh,target,intervaldelay telemetry:
pk_delay,av_delay,sp_delayhashing:
way_inds,way_miss,way_colssignaling:
drops,marksACK filtering:
ack_dropqueue activity:
sp_flows,bk_flows,un_flows,max_len,quantum
Interpretation pattern:
check if tins and thresholds match intended policy
inspect delay EWMAs by tin
correlate
drops/markswith user-visible latency and throughputmonitor hash-collision indicators (
way_cols) under peak concurrency
6) LibreQoS Policy Framing: CAKE vs fq_codel
For LibreQoS operators, start with platform behavior first:
Default operation is
cake diffserv4in HTB class leaves.TreeGuard (upcoming feature) can move selected circuit directions to
fq_codelduring sustained low-load conditions and back tocakeas utilization/guardrail pressure rises.Manual per-circuit
sqmoverrides still provide explicit operator control.
Use this matrix for tradeoff context:
Dimension |
|
|
|---|---|---|
Configuration complexity |
Lower |
Higher (more integrated features) |
Resource footprint at scale |
Often lower |
Often higher |
Integrated shaping features |
No (needs parent shaper like HTB) |
Yes (deficit-mode shaper built in) |
DiffServ/tin behavior |
Basic/indirect |
Strong native tin model |
Host isolation modes |
Not CAKE-style host modes |
Rich host/flow isolation modes |
Overhead compensation |
Limited |
Rich built-in overhead/framing controls |
Asymmetric-link ACK optimizations |
None |
ACK filtering modes available |
Best fit |
Large queue count with tight resources |
Mixed traffic where policy richness and smoothness matter |
7) LibreQoS Operator Notes
From maintainer testing and deployment feedback:
fq_codelhas no intrinsic rate limiting; it relies on HTB for rate policy.fq_codelandCAKEboth keep per-flow state tables, so RAM/hash behavior matters at high queue counts.CAKEand HTB are viable down to very low and asymmetric rates in LibreQoS deployments.A top-level “sandwich” limiter pattern using HTB+fq_codel is a practical deployment option in some environments.
Some dashboard traffic views can reflect pre-drop context; interpret counters with drop/mark semantics together.
“Only hard saturation benefits from AQM” is too narrow; AQM and fair queueing can improve latency when managed queues are under burst/contended pressure, even before interface-wide utilization is fully pegged.
Older shared/default-bucket discussion patterns reinforce that queue dynamics, not only “link fully pegged” moments, drive AQM value; in current LibreQoS, undefined traffic is pass-through, so apply this principle to managed HTB leaf queues.
8) Practical Observability Workflow
Start with:
tc -s qdisc show dev <ifname>
tc -s class show dev <ifname>
Then:
confirm HTB classes exist where expected
confirm leaf qdisc type (
cakevsfq_codel) per classinspect class and qdisc counters together
verify directionality (
ingress/egress) matches the problem being diagnosedcorrelate with user-visible latency/throughput, not counters alone
9) Common Misunderstandings
“
fq_codelorCAKEreplaces HTB”False for LibreQoS hierarchy operation; HTB remains the policy envelope.
“Undefined traffic goes to an HTB default queue in LibreQoS”
False; LibreQoS passes undefined traffic through.
“Only hard saturation events benefit from AQM”
“Leaf qdisc tuning can fix broken hierarchy/class mapping”
False; mapping/hierarchy errors must be corrected first.
“
fq_codelcan rate-limit on its own”False; use HTB (or another shaper) for explicit rate policy.
10) HTB HOWTO Context (Historical, Still Useful)
Classic HTB HOWTO material remains useful for operator mental models when translated to modern LibreQoS:
classify traffic
schedule queue service
shape at the bottleneck (or immediately upstream)
define explicit class intent with
rate/ceil
Modern translation notes:
confirm behavior with
tc -scounters, not assumptions about package defaultskeep classifier order intentional (specific rules before broader matches)
include explicit catch-all handling in manual
tcdeploymentsin LibreQoS specifically, undefined traffic is pass-through unless mapped into shaped hierarchy