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 the ISP-facing egress interface and the LAN-side interface or bridge that carries download traffic:

/queue type
add name=cake-wan kind=cake cake-overhead-scheme=ethernet cake-rtt=100ms \
cake-diffserv=diffserv4 cake-wash=yes
/queue tree
add name=wan-upload parent=<wan-interface> queue=cake-wan max-limit=20M
add name=lan-download parent=<lan-interface-or-bridge> queue=cake-wan max-limit=100M

Replace <wan-interface> with the actual uplink that faces the ISP, and replace <lan-interface-or-bridge> with the LAN bridge or downstream interface that carries download traffic. Do not assume default names such as ether1 or bridge.

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-ecnyesUse 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 \
cake-overhead-scheme=ethernet \
cake-rtt=100ms \
cake-diffserv=diffserv4 \
cake-wash=yes

Apply it in a Queue Tree entry with max-limit set to your link speed and parent set to the interface that actually carries the shaped traffic:

/queue tree
add name=isp-upload parent=<wan-interface> 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).

On the verified RouterOS 7.15.3 CHR build, only cake-overhead-scheme=ethernet was accepted. The presets none, pppoe-ipoe, lte, and wireless were rejected during validation, so this guide documents the tested behavior rather than unverified variants.

ValueTypical Use
ethernetEthernet with 802.1Q tag (sets cake-overhead=38 cake-mpu=84)

If your access technology adds different framing overhead, verify the preset on your target RouterOS build before using it. On CHR 7.15.3, stay with the tested ethernet preset.

The cake-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 cake-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 cake-diffserv parameter.

ValueTinsDSCP Mapping
diffserv33Bulk (CS1), Best Effort, Voice (EF/CS5/CS6/CS7)
diffserv44Bulk (CS1), Best Effort (CS0), Video (AF/CS2/CS3), Voice (EF/CS5/CS6/CS7)
diffserv88Fine-grained; each DSCP class gets its own tin

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.

diffserv3 is a simpler three-tin scheme suited for routers where the video/gaming distinction is unnecessary.

diffserv8 provides maximum granularity for ISP or enterprise environments where fine-grained DSCP policies are already enforced end-to-end.

With cake-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 cake-wash=no on internal LAN queues where downstream devices need to see the DSCP values.

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

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

cake-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. Omit the parameter to use the default ACK handling.


A typical home router with 100 Mbps download / 20 Mbps upload using the verified CHR-safe overhead preset:

/queue type
add name=cake-home kind=cake \
cake-overhead-scheme=ethernet \
cake-rtt=50ms \
cake-diffserv=diffserv4 \
cake-wash=yes \
cake-ack-filter=filter
/queue tree
add name=wan-up parent=<wan-interface> queue=cake-home max-limit=19M
add name=lan-down parent=<lan-interface-or-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. On many home routers the download queue parent is the LAN bridge, but use the bridge or interface name that exists on your device.

Use a plain Ethernet baseline first, then validate any more specific overhead tuning on the target RouterOS build before deploying it broadly.

/queue type
add name=cake-vdsl kind=cake \
cake-overhead-scheme=ethernet \
cake-rtt=20ms \
cake-diffserv=diffserv4 \
cake-wash=yes
/queue tree
add name=subscriber-up parent=<subscriber-uplink> 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 cake-overhead-scheme 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
cake-overhead-schemeethernetVerified L2 overhead preset on RouterOS 7.15.3 CHR
cake-rttduration (e.g. 100ms)Expected RTT; tunes CoDel aggressiveness
cake-diffservdiffserv3, diffserv4, diffserv8Traffic classification and tin scheme
cake-washyes, noStrip DSCP markings on egress
cake-ack-filterfilter, noneTCP ACK filtering for asymmetric links
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-ecnyesEnable ECN marking instead of drop