Skip to content

CAKE and FQ-CoDel

CAKE (Common Applications Kept Enhanced) and FQ-CoDel (Fair Queuing Controlled Delay) are modern Active Queue Management (AQM) algorithms designed to eliminate bufferbloat — the condition where oversized buffers cause high and variable latency under load.

Traditional queue types like PFIFO fill their buffers completely before dropping packets, which causes latency to spike from milliseconds to hundreds of milliseconds during congestion. AQM algorithms instead drop or mark packets proactively based on queuing delay, keeping buffers shallow and latency predictable.

Both algorithms are available in RouterOS 7.1 and later as kind=fq-codel and kind=cake. CAKE is the recommended choice for most deployments — it is built on FQ-CoDel and adds integrated shaping, overhead compensation, and diffserv prioritization.

Apply CAKE to a WAN interface upload queue and a LAN bridge download queue:

/queue type
add name=cake-wan kind=cake overhead-compensation=ethernet rtt=100ms \
flow=diffserv4 wash=yes
/queue tree
add name=wan-upload parent=ether1 queue=cake-wan max-limit=20M
add name=lan-download parent=bridge queue=cake-wan max-limit=100M

Adjust max-limit to 90–95% of your subscribed bandwidth so CAKE controls the bottleneck queue at your router rather than letting it form inside the ISP’s CPE.


FQ-CoDel combines two mechanisms: Fair Queuing (FQ) hashes flows into separate sub-queues so that a bulk download cannot starve a VoIP call. CoDel monitors the time each packet spends waiting and begins dropping once that delay exceeds a target, signalling TCP senders to slow down before buffers are fully occupied.

/queue type
add name=fq-codel-wan kind=fq-codel \
fq-codel-target=5ms \
fq-codel-interval=100ms \
fq-codel-quantum=1514 \
fq-codel-limit=1024 \
fq-codel-ecn=no
ParameterDefaultDescription
fq-codel-target5msMaximum acceptable queuing delay. CoDel begins dropping when a packet waits longer than this value. Lower values reduce latency at the cost of slightly more drops.
fq-codel-interval100msMeasurement window. CoDel only drops once target has been exceeded continuously for one interval. Prevents over-reaction to short bursts.
fq-codel-quantum1514Bytes of credit given to each flow per scheduling round. Matches standard Ethernet MTU so each flow gets one full packet per turn.
fq-codel-limit1024Total packet limit across all sub-queues. Packets beyond this are tail-dropped.
fq-codel-ecnnoUse ECN marking instead of dropping when supported by both endpoints. Reduces retransmits on ECN-capable paths.

FQ-CoDel is the lighter option: it reduces bufferbloat and provides flow fairness but does not include integrated shaping or overhead compensation. Use it when:

  • You only need AQM without shaping (rate limiting handled separately by HTB or Simple Queue)
  • The router hardware is constrained and the added CPU cost of CAKE matters
  • You want a simpler baseline before tuning CAKE parameters

CAKE builds on FQ-CoDel and adds three capabilities that make standalone deployment practical:

  1. Integrated shaper — native rate limiting avoids double-queuing when combined with HTB or Simple Queue
  2. Overhead compensation — accounts for L2 framing bytes so the shaper rate matches what actually crosses the wire
  3. Diffserv tins — classifies traffic into priority buckets based on DSCP markings
/queue type
add name=cake-type kind=cake \
overhead-compensation=ethernet \
rtt=100ms \
flow=diffserv4 \
wash=yes \
ack-filter=default

Apply it in a Queue Tree entry with max-limit set to your link speed:

/queue tree
add name=isp-upload parent=ether1 queue=cake-type max-limit=20M

CAKE shapes traffic based on a bandwidth budget. If the shaper does not account for encapsulation headers, it either over-shapes (wastes bandwidth) or under-shapes (lets too much through, defeating AQM).

Set overhead-compensation to match your WAN connection type:

ValueOverhead AddedTypical Use
none0 bytesRaw Ethernet, testing
ethernet18 bytesEthernet with 802.1Q tag
pppoe~8 bytesPPPoE over Ethernet
ltevariableLTE/cellular uplink
wirelessvariableWi-Fi uplink

Using the wrong preset causes systematic shaping error. A PPPoE connection with overhead-compensation=none will allow ~0.5% more traffic than configured at 100 Mbps — enough to push congestion back into the ISP’s queue and undo the bufferbloat fix.

The rtt parameter tells CAKE the expected round-trip time on this path. CAKE uses it to tune how aggressively CoDel responds to emerging congestion — a shorter RTT requires faster intervention.

ValueTypical Scenario
10msLAN or metro fibre
50msGood residential fibre/DOCSIS
100msTypical residential DSL/cable
200ms300msLong-haul DSL
600msSatellite internet

Set rtt close to the actual idle RTT on the shaped path. Measure with ping to a nearby target before adding the queue:

/tool ping address=8.8.8.8 count=10

A misconfigured RTT does not break CAKE, but the right value improves responsiveness during congestion onset.

CAKE can classify traffic into tins — separate sub-queues with different priority and latency targets — using DSCP markings already in packet headers. Configure the tin scheme with the flow parameter.

ValueTinsDSCP Mapping
best-effort1All traffic equal; DSCP ignored
diffserv44Bulk (CS1), Best Effort (CS0), Video (AF/CS2/CS3), Voice (EF/CS5/CS6/CS7)
diffserv88Fine-grained; each DSCP class gets its own tin
flowsIgnores DSCP entirely; pure per-flow fairness

best-effort is the safe default when you do not control DSCP markings on your network or traffic arrives from an untrusted upstream. All flows receive equal treatment.

diffserv4 is the recommended starting point for home routers and small offices. It automatically elevates VoIP (EF), depresses background transfers (CS1), and keeps gaming and video in distinct tins without any mangle rules.

flows disables tins and focuses entirely on fairness between individual flows. Use it in multi-user scenarios where DSCP markings are absent or untrusted.

With wash=yes, CAKE strips DSCP markings from packets as they leave the queue. This prevents internally-set priority marks from leaking to downstream networks, which is generally correct on an outbound WAN queue.

Set wash=no on internal LAN queues where downstream devices need to see the DSCP values.

The ack-filter parameter reduces TCP ACK storms on asymmetric links where upload is much slower than download:

ValueBehaviour
defaultStandard ACK handling
filterDrop redundant/late ACKs to free upload capacity
noneDisable ACK filtering

ack-filter=filter helps on ADSL or DOCSIS links where 5–20 Mbps upload must carry ACKs for a 100+ Mbps download stream. It is not needed on symmetric fibre links.


A typical home router with 100 Mbps download / 20 Mbps upload over PPPoE:

/queue type
add name=cake-home kind=cake \
overhead-compensation=pppoe \
rtt=50ms \
flow=diffserv4 \
wash=yes \
ack-filter=filter
/queue tree
add name=wan-up parent=ether1 queue=cake-home max-limit=19M
add name=lan-down parent=bridge queue=cake-home max-limit=95M

Set max-limit to 95% of the subscribed rate. This ensures CAKE holds the bottleneck queue rather than the ISP’s equipment.

ISP aggregation routers typically add 44 bytes of overhead per packet on VDSL2 PTM links (PPPoE + Ethernet + ATM cell padding). Specify this as a raw byte count:

/queue type
add name=cake-vdsl kind=cake \
overhead-compensation=pppoe \
rtt=20ms \
flow=diffserv4 \
wash=yes
/queue tree
add name=subscriber-up parent=ether1 queue=cake-vdsl max-limit=18M

For precise per-subscriber shaping in ISP environments, pair CAKE with PCQ or use separate Queue Tree entries per subscriber marked with mangle packet marks.

If you already have HTB queue trees for rate limiting, add FQ-CoDel on top for AQM without rebuilding the shaper:

/queue type
add name=fq-codel-aqm kind=fq-codel fq-codel-target=5ms fq-codel-interval=100ms
/queue tree
add name=bulk-class parent=wan-shaper packet-mark=bulk-traffic \
queue=fq-codel-aqm max-limit=50M priority=8
add name=interactive-class parent=wan-shaper packet-mark=interactive \
queue=fq-codel-aqm max-limit=50M priority=1

CAKEFQ-CoDel
Integrated shapingYesNo
Overhead compensationYesNo
Diffserv prioritizationYes (tins)No
Per-flow fairnessYesYes
AQM (delay-based drops)Yes (CoDel)Yes (CoDel)
Configuration complexityLow–MediumLow
CPU usageMediumLow

Use CAKE when it is the only queue on a WAN interface — it replaces both the shaper and the AQM in a single queue type. Use FQ-CoDel when you already have shaping in place and only want to add AQM, or on resource-constrained hardware.


Both CAKE and FQ-CoDel are bypassed by FastTrack connections. FastTracked packets skip the firewall and queue processing path entirely, so they are never submitted to the AQM.

Disable FastTrack on interfaces where you apply CAKE/FQ-CoDel, or explicitly exclude target traffic from FastTrack with a mangle rule:

/ip firewall mangle
add chain=forward action=mark-connection new-connection-mark=no-fasttrack \
passthrough=yes comment="Exclude LAN from FastTrack for CAKE"
/ip firewall filter
add chain=forward connection-mark=no-fasttrack action=fasttrack-connection \
disabled=yes

The simplest approach is to disable the default FastTrack rule when CAKE is deployed:

/ip firewall filter
set [find comment="defconf: fasttrack"] disabled=yes

Check queue statistics to verify CAKE is active and shaping traffic:

/queue tree print stats

Key fields to watch:

FieldMeaning
bytesTotal bytes processed — confirms traffic is flowing through the queue
packetsTotal packet count
droppedPackets dropped by AQM — low steady-state drops are normal and healthy
queued-bytesCurrent bytes buffered — should stay low under CAKE

Under bufferbloat conditions, dropped will be non-zero but latency will remain stable. A high queued-bytes with no drops indicates the queue is not controlling the bottleneck (check max-limit and FastTrack).


Latency does not improve after adding CAKE

  1. Verify the interface is carrying traffic: queue tree print stats should show incrementing bytes.
  2. Check max-limit is below your ISP link speed. If it equals or exceeds the ISP rate, the bottleneck queue is still inside the ISP’s equipment.
  3. Confirm FastTrack is disabled for the shaped flows.
  4. Run a bufferbloat test (e.g., DSLReports Speed Test) before and after to compare latency under load.

Speed test shows lower throughput than expected

  1. Check overhead-compensation matches your connection type. An incorrect overhead preset under-shapes.
  2. Set max-limit to 90–95% of the subscribed rate, not 100%.
  3. Verify the queue tree parent points to the correct interface.

CAKE queue shows 0 bytes / packets

  1. Traffic may not be reaching the queue. Check that the parent interface or packet mark is correct.
  2. Confirm that max-limit is set — a queue tree entry with no max-limit does not shape traffic.

ParameterValuesDescription
overhead-compensationnone, ethernet, pppoe, lte, wirelessL2 overhead preset for accurate bandwidth accounting
rttduration (e.g. 100ms)Expected RTT; tunes CoDel aggressiveness
flowbest-effort, diffserv4, diffserv8, flowsTraffic classification and tin scheme
washyes, noStrip DSCP markings on egress
ack-filterdefault, filter, noneTCP ACK filtering for asymmetric links
unlimitedyes, noDisable rate limiting (AQM only mode)
ParameterDefaultDescription
fq-codel-target5msTarget queuing delay before drops start
fq-codel-interval100msMeasurement window for delay evaluation
fq-codel-quantum1514Per-flow scheduling quantum in bytes
fq-codel-limit1024Maximum queue depth in packets
fq-codel-ecnnoEnable ECN marking instead of drop