# cake-autorate retunes CAKE bandwidth as your LTE or Starlink link fluctuates

> cake-autorate is a shell script that measures load and latency on a router and rewrites the CAKE shaper rates so a variable bandwidth link is not stuck at a compromise setting. It suits OpenWrt, Asus Merlin and Debian systems on LTE, 5G, Starlink or cable, and it is explicitly not meant for fixed bandwidth lines.

**lynxthecat/cake-autorate** — Eliminate the excess latency and jitter terrorizing your 4G, 5G, LTE, Starlink or other variable rate connection!

- Repository: https://github.com/lynxthecat/cake-autorate
- Website: https://www.bufferbloat.net
- Stars: 575 · Forks: 44
- Language: Shell
- License: GPL-2.0
- Published: 2026-10-22 · Updated: 2026-10-22 · Language: en
- Canonical page: https://hysenlabs.com/projects/lynxthecat-cake-autorate

## The compromise CAKE forces on a link whose speed moves

CAKE is an algorithm that manages the buffering of data being sent and received by a device so that no more data is queued than is necessary, which minimizes the latency called bufferbloat and improves network responsiveness. An instance of CAKE on an interface is set up with a certain bandwidth.

That fixed bandwidth is the problem. The CAKE algorithm itself has no reliable means to adjust the bandwidth on the fly, so on a variable connection the user has to pick a single compromise value and live with it. Set the parameter too low and the connection is unnecessarily throttled even when the link could carry more. Set it too high, and for the times when the usable rate falls below that value the link is not throttled enough, which produces bufferbloat.

cake-autorate bridges that gap. The project description puts it plainly: eliminate the excess latency and jitter terrorizing your 4G, 5G, LTE, Starlink or other variable rate connection.

The interesting part is that the answer is not to set CAKE to a lower number permanently. It is to keep the shaper rate low enough to stay bufferbloat free and then push it up during the periods when the link genuinely has headroom, which is what the script automates.

## Measuring load and latency, then ramping the shaper rate

The theory of operation is stated in terms of what the script watches. cake-autorate.sh monitors load, meaning receive and transmit utilization, and ping response times from one or more reflectors, which are hosts on the internet, and adjusts the download and upload rate settings for CAKE.

The algorithm is applied separately to each direction of traffic, and it has four behaviours. In periods of high traffic, it ramps the rate setting up toward the configured maximum, to take advantage of the increased throughput. Anytime bufferbloat, meaning increased latency, is detected, it ramps the rate down until the latency stabilizes, but never below the configured minimum. In periods of low traffic, it gradually ramps the rate back toward the configured baseline, and a subsequent burst of traffic begins a new search for the right setting. The README says this typically adjusts to new traffic conditions in well under one second.

The last detail is the one that makes the loop usable. To avoid oscillation there is a refractory period during which no further change is made. Without that, a script chasing a latency signal would hunt forever, because raising the rate is what causes the latency that makes it lower the rate again.

The script also keeps a detailed log file that is helpful in examining performance, and the README points at a separate ANALYSIS page for how to read those logs.

## Three numbers per direction, and how to pick them

cake-autorate requires three configuration values for each direction, upload and download, and the README explains each of them in terms of the compromise described earlier.

The minimum bandwidth, min_dl_shaper_rate_kbps and min_ul_shaper_rate_kbps, should be set to the lowest possible observed bufferbloat-free bandwidth. Ideally it should never result in bufferbloat even under the worst conditions, and the README calls it a hard minimum, because the script will never reduce the bandwidth below this level.

The baseline bandwidth, base_dl_shaper_rate_kbps and base_ul_shaper_rate_kbps, is the steady state bandwidth maintained under no or low load. The README says this is likely the compromise bandwidth, the value you would set CAKE to that is bufferbloat-free most, but not necessarily all, of the time.

The maximum bandwidth, max_dl_shaper_rate_kbps and max_ul_shaper_rate_kbps, should be set to the maximum bandwidth the connection can provide, or slightly lower. When there is heavy traffic the script adjusts up to this limit and backs off if an OWD or RTT spike is detected.

The maximum is where the honest trade-off sits. Since the algorithm repeatedly tests for the maximum rate available, it may permit some excess latency at a traffic peak. Reducing the maximum to a value slightly below the link's maximum avoids that excess latency and may let traffic cruise along with low latency at that configured maximum, even when the true capacity is a little higher.

The mental model the README offers is to split a variable connection into a known fixed stable component plus an unknown variable component. The minimum is then set at or slightly below the fixed component, and the maximum at or slightly above the maximum observed bandwidth, or lower if you would trade bandwidth for consistently lower latency. The baseline is likely optimally either the minimum or close to it.

## Where it runs, and which branch to use

cake-autorate presently supports installation on devices running an OpenWrt router, an Asus Merlin router, or an OS from the Debian family.

The branch choice is the important operational detail, and the README is explicit about it. This is the development, master, branch, where new work on cake-autorate appears, and it is not guaranteed to be stable. The stable version for production and everyday use is 3.2.1, available from the v3.2 branch.

The release list shows v3.2.0 on 2024-05-15, v3.2.1 on 2024-05-18 and v3.2.2 on 2024-11-27, with the last push to master on 2026-09-11. The project is written in shell, and the repository layout reflects that, with cake-autorate.sh as the main script, a cake-autorate.template, a launcher.sh.template, config.primary.sh, defaults.sh, lib.sh, setup.sh and uninstall.sh, plus a systemd unit file cake-autorate@.service and an example-uci-config.txt for the OpenWrt UCI configuration.

There are also two pieces beyond the core script. mqtt-publisher.sh with its own template and config publishes state over MQTT, and fn_parse_autorate_log.m parses the autorate log, which is what the ANALYSIS page describes. The licence is GPL-2.0, in a LICENCE.md file at the root.

The installation itself is not in the README. The README points to a separate INSTALLATION page for that, so the commands belong to that document rather than to the main readme.

## CPU saturation silently throttles the very link you are tuning

The CPU usage section is short and carries a warning that deserves more attention than its length.

The user should verify that total CPU usage is kept within acceptable ranges, especially for higher bandwidth connections and devices with weaker CPUs. The reason is mechanical: on CPU saturation, bandwidth on a running CAKE qdisc is throttled.

A CAKE qdisc is run on a specific CPU core, so care should be taken to ensure the cores on which CAKE qdiscs are run are not saturated during normal use.

That is a feedback loop worth thinking about. You install a tool to remove bufferbloat, and if the router's CPU is the bottleneck, the shaper itself becomes the source of the throttling you were trying to eliminate. The symptom would look like the script failing to raise the rate during a burst, and the natural conclusion would be that the algorithm is not working, when the real cause is that the box is out of cycles.

There is a bench_cpu.sh script in the repository, which is a reasonable place to start if you want to measure what your hardware can do before tuning rates on top of it.

## Why this is not the tool for a fixed line, and what it costs to run

The README states the scope limit in the opening paragraph: cake-autorate is intended for variable bandwidth connections such as LTE, Starlink and cable modems, and is not generally required for use on connections that have a stable, fixed bandwidth.

That makes sense mechanically. On a fixed link, the correct CAKE rate is known and can simply be configured, and the whole adaptive search buys nothing while adding a moving part that can misbehave. The script is for the case where the right number changes minute to minute.

The cost of running it on a variable link is a background process, an extra set of measurements against reflector hosts, a configuration file with three values per direction, and logs to read when something looks wrong. It also has to be trusted with the shaper settings, so a misconfigured minimum or maximum turns a latency fix into a throughput problem, and the two failure modes are opposite in character, which is exactly the kind of thing that needs a log you can read.

The upstream project is CAKE itself, documented on bufferbloat.net, and the forum thread the README links on forum.openwrt.org is where the community discusses the adaptive bandwidth work.

## Conclusion

Adopt cake-autorate if your uplink is a variable rate link, such as LTE, 5G, Starlink or a cable modem, and you are running CAKE and are tired of choosing one compromise rate that is either too slow or too fast for the moment. Do not adopt it on a fixed bandwidth line, because the README says it is not generally required there. Before you deploy it, read INSTALLATION.md, because the README does not carry the install steps, decide your minimum, baseline and maximum rates for each direction, and use the stable v3.2 branch rather than master for production, since the README states that the development branch is not guaranteed to be stable.

## FAQ

### What does cake-autorate do and what problem does it solve?

It is a script that minimizes latency on a router by adjusting CAKE bandwidth settings. CAKE uses static upload and download rates, which on a variable link forces one compromise setting that is either too low and throttles unnecessarily or too high and produces bufferbloat, and the script measures load and latency and rewrites the rates as conditions change.

### Which three values do I need to configure for cake-autorate?

Three per direction, upload and download. The minimum, min_dl_shaper_rate_kbps and min_ul_shaper_rate_kbps, is the lowest observed bufferbloat-free bandwidth and a hard floor. The baseline, base_dl_shaper_rate_kbps and base_ul_shaper_rate_kbps, is the steady state rate under low load. The maximum, max_dl_shaper_rate_kbps and max_ul_shaper_rate_kbps, is the ceiling the script will test up to.

### Where can I install cake-autorate and which branch should I use?

It supports OpenWrt routers, Asus Merlin routers, and operating systems from the Debian family. The README says the master branch is the development branch and is not guaranteed to be stable, and that the stable version for production use is 3.2.1 from the v3.2 branch, with the install steps in the separate INSTALLATION page.

### How does cake-autorate avoid oscillating its bandwidth setting?

The script ramps the rate up under high traffic, ramps it down when bufferbloat is detected, and returns it toward the baseline under low traffic, with a refractory period during which no further change is made. The README says this typically adjusts to new traffic conditions in well under one second.

### Does running cake-autorate cost much CPU?

The README asks users to verify that total CPU usage stays within acceptable ranges, especially on higher bandwidth connections and devices with weaker CPUs, because on CPU saturation the bandwidth on a running CAKE qdisc is throttled. CAKE qdiscs run on a specific CPU core, so those cores should not be saturated during normal use.

## Sources

- [License: GPL-2.0](https://github.com/lynxthecat/cake-autorate/blob/master/LICENSE)
- [lynxthecat/cake-autorate on GitHub](https://github.com/lynxthecat/cake-autorate)
- [Project website](https://www.bufferbloat.net)
- [README](https://github.com/lynxthecat/cake-autorate/blob/master/README.md)
- [Releases](https://github.com/lynxthecat/cake-autorate/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/lynxthecat-cake-autorate
