CAKE and FQ-CoDel
CAKE and FQ-CoDel
Section titled “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.
Quick Start
Section titled “Quick Start”Apply CAKE to the ISP-facing egress interface and the LAN-side interface or bridge that carries download traffic:
/queue typeadd name=cake-wan kind=cake cake-overhead-scheme=ethernet cake-rtt=100ms \ cake-diffserv=diffserv4 cake-wash=yes
/queue treeadd name=wan-upload parent=<wan-interface> queue=cake-wan max-limit=20Madd name=lan-download parent=<lan-interface-or-bridge> queue=cake-wan max-limit=100MReplace <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
Section titled “FQ-CoDel”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.
Creating an FQ-CoDel Queue Type
Section titled “Creating an FQ-CoDel Queue Type”/queue typeadd 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=noFQ-CoDel Parameters
Section titled “FQ-CoDel Parameters”| Parameter | Default | Description |
|---|---|---|
fq-codel-target | 5ms | Maximum 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-interval | 100ms | Measurement window. CoDel only drops once target has been exceeded continuously for one interval. Prevents over-reaction to short bursts. |
fq-codel-quantum | 1514 | Bytes of credit given to each flow per scheduling round. Matches standard Ethernet MTU so each flow gets one full packet per turn. |
fq-codel-limit | 1024 | Total packet limit across all sub-queues. Packets beyond this are tail-dropped. |
fq-codel-ecn | yes | Use ECN marking instead of dropping when supported by both endpoints. Reduces retransmits on ECN-capable paths. |
When to Use FQ-CoDel
Section titled “When to Use FQ-CoDel”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:
- Integrated shaper — native rate limiting avoids double-queuing when combined with HTB or Simple Queue
- Overhead compensation — accounts for L2 framing bytes so the shaper rate matches what actually crosses the wire
- Diffserv tins — classifies traffic into priority buckets based on DSCP markings
Creating a CAKE Queue Type
Section titled “Creating a CAKE Queue Type”/queue typeadd name=cake-type kind=cake \ cake-overhead-scheme=ethernet \ cake-rtt=100ms \ cake-diffserv=diffserv4 \ cake-wash=yesApply 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 treeadd name=isp-upload parent=<wan-interface> queue=cake-type max-limit=20MOverhead Compensation
Section titled “Overhead Compensation”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.
| Value | Typical Use |
|---|---|
ethernet | Ethernet 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.
RTT Estimation
Section titled “RTT Estimation”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.
| Value | Typical Scenario |
|---|---|
10ms | LAN or metro fibre |
50ms | Good residential fibre/DOCSIS |
100ms | Typical residential DSL/cable |
200ms–300ms | Long-haul DSL |
600ms | Satellite 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=10A misconfigured RTT does not break CAKE, but the right value improves responsiveness during congestion onset.
Diffserv Tins
Section titled “Diffserv Tins”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.
| Value | Tins | DSCP Mapping |
|---|---|---|
diffserv3 | 3 | Bulk (CS1), Best Effort, Voice (EF/CS5/CS6/CS7) |
diffserv4 | 4 | Bulk (CS1), Best Effort (CS0), Video (AF/CS2/CS3), Voice (EF/CS5/CS6/CS7) |
diffserv8 | 8 | Fine-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.
The cake-wash Parameter
Section titled “The cake-wash Parameter”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.
ACK Filtering
Section titled “ACK Filtering”The cake-ack-filter parameter reduces TCP ACK storms on asymmetric links where upload is much
slower than download:
| Value | Behaviour |
|---|---|
filter | Drop redundant/late ACKs to free upload capacity |
none | Disable 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.
Practical Examples
Section titled “Practical Examples”Home Router — Cable or DSL
Section titled “Home Router — Cable or DSL”A typical home router with 100 Mbps download / 20 Mbps upload using the verified CHR-safe overhead preset:
/queue typeadd name=cake-home kind=cake \ cake-overhead-scheme=ethernet \ cake-rtt=50ms \ cake-diffserv=diffserv4 \ cake-wash=yes \ cake-ack-filter=filter
/queue treeadd name=wan-up parent=<wan-interface> queue=cake-home max-limit=19Madd name=lan-down parent=<lan-interface-or-bridge> queue=cake-home max-limit=95MSet 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.
ISP Edge — Verified CHR Baseline
Section titled “ISP Edge — Verified CHR Baseline”Use a plain Ethernet baseline first, then validate any more specific overhead tuning on the target RouterOS build before deploying it broadly.
/queue typeadd name=cake-vdsl kind=cake \ cake-overhead-scheme=ethernet \ cake-rtt=20ms \ cake-diffserv=diffserv4 \ cake-wash=yes
/queue treeadd name=subscriber-up parent=<subscriber-uplink> queue=cake-vdsl max-limit=18MFor precise per-subscriber shaping in ISP environments, pair CAKE with PCQ or use separate Queue Tree entries per subscriber marked with mangle packet marks.
FQ-CoDel with Existing HTB Shaper
Section titled “FQ-CoDel with Existing HTB Shaper”If you already have HTB queue trees for rate limiting, add FQ-CoDel on top for AQM without rebuilding the shaper:
/queue typeadd name=fq-codel-aqm kind=fq-codel fq-codel-target=5ms fq-codel-interval=100ms
/queue treeadd name=bulk-class parent=wan-shaper packet-mark=bulk-traffic \ queue=fq-codel-aqm max-limit=50M priority=8add name=interactive-class parent=wan-shaper packet-mark=interactive \ queue=fq-codel-aqm max-limit=50M priority=1Choosing Between CAKE and FQ-CoDel
Section titled “Choosing Between CAKE and FQ-CoDel”| CAKE | FQ-CoDel | |
|---|---|---|
| Integrated shaping | Yes | No |
| Overhead compensation | Yes | No |
| Diffserv prioritization | Yes (tins) | No |
| Per-flow fairness | Yes | Yes |
| AQM (delay-based drops) | Yes (CoDel) | Yes (CoDel) |
| Configuration complexity | Low–Medium | Low |
| CPU usage | Medium | Low |
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.
FastTrack Interaction
Section titled “FastTrack Interaction”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 mangleadd chain=forward action=mark-connection new-connection-mark=no-fasttrack \ passthrough=yes comment="Exclude LAN from FastTrack for CAKE"
/ip firewall filteradd chain=forward connection-mark=no-fasttrack action=fasttrack-connection \ disabled=yesThe simplest approach is to disable the default FastTrack rule when CAKE is deployed:
/ip firewall filterset [find comment="defconf: fasttrack"] disabled=yesMonitoring
Section titled “Monitoring”Check queue statistics to verify CAKE is active and shaping traffic:
/queue tree print statsKey fields to watch:
| Field | Meaning |
|---|---|
bytes | Total bytes processed — confirms traffic is flowing through the queue |
packets | Total packet count |
dropped | Packets dropped by AQM — low steady-state drops are normal and healthy |
queued-bytes | Current 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).
Troubleshooting
Section titled “Troubleshooting”Latency does not improve after adding CAKE
- Verify the interface is carrying traffic:
queue tree print statsshould show incrementingbytes. - Check
max-limitis below your ISP link speed. If it equals or exceeds the ISP rate, the bottleneck queue is still inside the ISP’s equipment. - Confirm FastTrack is disabled for the shaped flows.
- Run a bufferbloat test (e.g., DSLReports Speed Test) before and after to compare latency under load.
Speed test shows lower throughput than expected
- Check
cake-overhead-schemematches your connection type. An incorrect overhead preset under-shapes. - Set
max-limitto 90–95% of the subscribed rate, not 100%. - Verify the queue tree
parentpoints to the correct interface.
CAKE queue shows 0 bytes / packets
- Traffic may not be reaching the queue. Check that the
parentinterface or packet mark is correct. - Confirm that
max-limitis set — a queue tree entry with nomax-limitdoes not shape traffic.
Parameters Reference
Section titled “Parameters Reference”CAKE Parameters
Section titled “CAKE Parameters”| Parameter | Values | Description |
|---|---|---|
cake-overhead-scheme | ethernet | Verified L2 overhead preset on RouterOS 7.15.3 CHR |
cake-rtt | duration (e.g. 100ms) | Expected RTT; tunes CoDel aggressiveness |
cake-diffserv | diffserv3, diffserv4, diffserv8 | Traffic classification and tin scheme |
cake-wash | yes, no | Strip DSCP markings on egress |
cake-ack-filter | filter, none | TCP ACK filtering for asymmetric links |
FQ-CoDel Parameters
Section titled “FQ-CoDel Parameters”| Parameter | Default | Description |
|---|---|---|
fq-codel-target | 5ms | Target queuing delay before drops start |
fq-codel-interval | 100ms | Measurement window for delay evaluation |
fq-codel-quantum | 1514 | Per-flow scheduling quantum in bytes |
fq-codel-limit | 1024 | Maximum queue depth in packets |
fq-codel-ecn | yes | Enable ECN marking instead of drop |
Related Resources
Section titled “Related Resources”- Queue Types Overview — PCQ, SFQ, RED, HTB algorithm details
- Queue Tree — Hierarchical queue configuration
- Simple Queues — Per-client rate limiting
- Firewall Mangle — Packet marking for queue classification
- PFIFO, BFIFO — Simple FIFO queue types