CAKE Algorithm Explained

Run a Speed Test

CAKE is the reason many OpenWrt routers can make a busy internet connection feel calm. It does not magically create bandwidth. It controls the bottleneck, shares it more fairly, and keeps delay from building up inside oversized queues.

What CAKE Stands For

CAKE stands for Common Applications Kept Enhanced. The name reflects the project's goal: an algorithm comprehensive enough to handle the varied traffic of a real home connection without requiring per-application manual rules. It was developed by the Bufferbloat project team as a successor to fq_codel, incorporating lessons from deploying active queue management on real home internet links.

What CAKE Does

CAKE is a queue management system for links where latency matters. It combines several jobs that older routers often treated separately: rate shaping, fair queueing, active queue management, traffic class handling, overhead compensation, and host fairness. In home terms, it tries to stop one upload, game download, cloud backup, or device from making everything else lag — without requiring you to classify every application manually.

CAKE ComponentPlain-English JobWhy It Matters
Integrated shaperSets a controlled rate slightly below the real bottleneckKeeps the queue inside your router, not in modem or ISP equipment
Flow fair queueingSeparates traffic into per-flow queues and round-robins between themOne busy flow cannot monopolize the link
AQM (CoDel-based)Measures sojourn time and signals congestion before queues grow deepReduces bufferbloat and ping spikes under load
Host isolationApplies fairness per source IP and per destination IPOne heavy downloader does not starve other household devices
Overhead compensationAccounts for per-packet framing overhead on DSL, PPPoE, ATM linksShaping is accurate even when link framing adds bytes not counted by the router
Tin traffic classesThree priority classes: Bulk, Best Effort, and VoiceDSCP-marked or heuristically detected latency-sensitive traffic gets faster service

Host Isolation: Per-Device Fairness

One of CAKE's most practically important features for home use is host isolation. Standard flow-based fair queueing distributes bandwidth fairly between TCP flows, but a single device running many parallel connections (a torrent client, a game launcher, a backup service) can still dominate the link by having more flows than other devices. CAKE's host isolation mode applies fairness at the IP address level — both per source IP and per destination IP. A device making twenty simultaneous connections gets the same total share as a device making one connection. This prevents any single household device from crowding out others even when it opens many parallel flows.

Overhead Compensation: Why It Must Match Your Connection

The rate you configure in CAKE is measured in IP-layer bytes, but your physical link may add additional framing per packet that the router does not see. DSL connections using ATM cell segmentation add significant overhead: each ATM cell is 53 bytes, and short IP packets waste much of that cell. PPPoE adds 8 bytes of header per frame. VDSL2 with PTM framing has its own overhead. If CAKE's shaping rate does not account for this overhead, it will allow more traffic than the physical link can actually carry, allowing queues to form in the modem or DSLAM instead — defeating the purpose of shaping at the router.

CAKE's overhead compensation modes include: none for fiber and Ethernet links where IP bytes match link bytes; pppoe-ptm for VDSL2 with PPPoE over PTM framing; pppoa-vcmux and related modes for older ADSL with ATM; and ethernet for links where Ethernet frame overhead should be included. Selecting the wrong mode means CAKE's effective shaping rate is off by a systematic amount, making latency improvements unreliable.

The Tin System: Traffic Classes

CAKE organizes traffic into three tins: Bulk (lower priority, for background transfers), Best Effort (the default for most traffic), and Voice (highest priority, for latency-sensitive traffic). Traffic is classified into tins based on DSCP markings in the IP header — EF-marked traffic goes to Voice, CS1/LE goes to Bulk, and everything else goes to Best Effort. CAKE can also use heuristic detection to classify traffic that lacks DSCP marks. Within each tin, flow fair queueing and CoDel-based AQM still operate, so even the highest-priority tin does not allow a single flow to dominate.

Why the Rate Setting Is Everything

CAKE needs to be the narrowest point in the path. If your modem, ONT, or ISP equipment is still the real bottleneck, queues form there instead of in CAKE, and CAKE's AQM cannot help. Setting the shaping rate a few percent below measured speed ensures CAKE's queue is the queue that fills first. For a 300 Mbps down / 20 Mbps up cable plan that tests at 285/18.5, a starting point of 260–270 Mbps down and 16.5–17 Mbps up is reasonable. Test loaded ping, then tune upward until latency starts rising, then back off slightly.

Ingress Shaping with CAKE

CAKE applies naturally to egress (outgoing) traffic, where it can hold packets in its own queue before transmission. Ingress (incoming, download) shaping is harder because packets arrive from the ISP before CAKE can queue them — they are already in the modem or OS receive buffer. The standard approach on Linux and OpenWrt is to use an IFB (Intermediate Functional Block) interface with a mirred redirect: incoming packets are redirected through an IFB interface, where CAKE can apply egress-style shaping with a rate limit and AQM before they are delivered to the local network. This works but adds some CPU overhead and complexity compared to egress-only shaping.

CAKE vs fq_codel

Featurefq_codelCAKE
Integrated shaperNo — needs separate tc tbf or similarYes — shaper is built in
Host fairnessNo — flow-level onlyYes — per source and destination IP
Overhead compensationNoYes — multiple modes for DSL, PPPoE, ATM
Traffic classesNoYes — three tins with DSCP mapping
Configuration complexityLower — fewer optionsHigher — more options, more to get right

Setting Up CAKE in OpenWrt

Install luci-app-sqm and sqm-scripts. Under Network → SQM QoS, select the WAN interface, set download and upload bandwidth, choose cake as the queue discipline, and set the link layer compensation to match your connection type. After saving and enabling, run a bufferbloat test at Waveform or DSLReports to confirm loaded ping has dropped significantly. A well-tuned CAKE configuration typically reduces loaded ping from hundreds of milliseconds to under 20 ms on the same connection.

When CAKE Helps Most

  • Gaming feels fine until someone uploads photos, joins a call, or downloads a game update.
  • Video calls become choppy even though speed tests look fast.
  • Ping spikes hard during uploads — a classic bufferbloat signature.
  • Several people and devices share one cable, DSL, fixed wireless, or 5G home connection.
  • Your router runs OpenWrt SQM or another firmware with CAKE support.

When CAKE Is Not the Right Fix

CAKE cannot fix a weak Wi-Fi signal, a damaged coax line, packet loss from an ISP issue, or a router CPU that cannot shape at your plan speed. Shaping at multi-gigabit rates (1 Gbps and above) requires a router with a fast enough CPU or hardware offload support for CAKE — many consumer routers cannot do this in software at full speed.

Frequently Asked Questions

Does CAKE increase internet speed?

No. It shapes slightly below line rate, which may reduce peak measured speed. The benefit is that the connection stays usable and low-latency when multiple devices or flows compete for bandwidth.

What speed should I set for CAKE?

Start around 90 to 95 percent of your measured wired download and upload speeds, then tune upward while monitoring loaded ping until latency begins rising, then back off slightly.

Is CAKE better than basic QoS?

For most home networks, yes. Basic QoS prioritizes application categories but does nothing about queue depth. CAKE shapes the link, keeps queues short, distributes capacity fairly per flow and per host, and requires far fewer manual classification rules.

Related Guides

More From This Section