WWRT Studio

Services · TUTORIAL

Stop Bufferbloat with SQM on OpenWrt

SQM (Smart Queue Management) keeps latency low even when your connection is saturated. This guide installs SQM on OpenWrt and tunes it for your line speed.

Scope and assumptions

  • OpenWrt version: OpenWrt 24.10 (opkg) and 25.12 and later (apk). CAKE needs the kmod-sched-cake kernel module, which luci-app-sqm pulls in on most targets.
  • Last verified against official sources: 2026-10-07

Hardware, target and driver assumptions

  • A router with enough CPU for the line speed; CAKE on gigabit links needs a capable device.
  • The WAN interface name (often wan; on DSA targets this can be a physical device name).
  • A speed test performed without SQM first, to set realistic limits.

Recovery and rollback warnings

  • A cap set above the real line speed reintroduces bufferbloat; one set too low wastes throughput. Change limits in small steps and test each time.
  • Invalid advanced qdisc options can make SQM silently fail to start. Check the SQM status after applying.
  • SQM shapes the WAN interface only; it cannot fix bufferbloat inside the Wi-Fi driver or the ISP modem.

What is bufferbloat?

Bufferbloat is the high latency caused when a router fills large buffers under load. You see it as lag spikes in games or choppy video calls when someone else is downloading.

SQM fixes this by limiting the router's own transmit rate to slightly below your line speed and using a fair queuing algorithm to give every flow a turn. The result is stable latency at the cost of a tiny bit of peak throughput.

  • Symptom: ping rises from 10 ms to 200+ ms during a download.
  • Cause: oversized buffers in the router or modem.
  • Fix: SQM with CAKE or fq_codel.

Install SQM

Install the `luci-app-sqm` package, which pulls in the SQM scripts and the CAKE qdisc. The package adds a new page under Network → SQM QoS.

CAKE is the recommended qdisc for most home connections. It combines fair queuing, AQM and per-flow shaping in one scheduler.

apk update
apk add luci-app-sqm

OpenWrt 25.12 and later (apk). On OpenWrt 24.10 and earlier use `opkg update` and `opkg install luci-app-sqm`.

Measure your real line speed

SQM works by capping bandwidth slightly below the actual line rate. To set the cap correctly, run a speed test without SQM first. Note the download and upload speeds in Mbps.

Set the SQM download limit to about 85-95% of the measured download speed, and the upload limit to 90-95% of the measured upload speed. The exact percentage depends on how stable your connection is.

Configure SQM in LuCI

Go to Network → SQM QoS. Enable SQM on the WAN interface. Set the download and upload speeds based on your measurements. Choose the CAKE qdisc and the piece_of_cake.qos script.

Save and apply. The SQM instance starts immediately and shapes traffic on the WAN interface.

uci set sqm.@queue[0].enabled='1'
uci set sqm.@queue[0].interface='wan'
uci set sqm.@queue[0].download='900000'
uci set sqm.@queue[0].upload='40000'
uci set sqm.@queue[0].qdisc='cake'
uci set sqm.@queue[0].script='piece_of_cake.qos'
uci commit sqm
/etc/init.d/sqm restart

Enables SQM on the WAN interface at 900 Mbps down and 40 Mbps up with CAKE. Speeds are in kbps.

Tune the parameters

SQM has a link-layer adaptation setting so packet accounting matches your access technology. The correct overhead depends on the connection type (Ethernet, ATM, PPPoE or a tunnel); the official SQM link-layer adaptation table lists the values. This matters mainly on a link that is running at capacity.

In LuCI these options are under the "Link Layer Adaptation" and "Queue Discipline" tabs. Advanced CAKE keywords go in the advanced option string field; invalid values can make SQM fail to start, so check its status after applying.

uci set sqm.@queue[0].linklayer='ethernet'
uci set sqm.@queue[0].overhead='0'
uci commit sqm
/etc/init.d/sqm restart

Sets the link layer to Ethernet. The overhead value is an example only; look up the correct bytes for your access technology in the official SQM link-layer adaptation table before relying on it.

Verify the improvement

Run the bufferbloat test at https://www.waveform.com/tools/bufferbloat or use `ping` while running a simultaneous download. With SQM, the ping should stay close to its idle value even during a full-speed download.

If the latency is still high, lower the bandwidth cap. If the throughput is much lower than expected, raise the cap in small steps until bufferbloat returns, then back off slightly.

ping -i 0.2 8.8.8.8
# in another terminal, run a speed test
# observe whether the ping time spikes

Frequently asked questions

Why is my download speed lower after enabling SQM?

SQM intentionally caps throughput to leave headroom for latency control. Set the limit to 95% of your measured line speed for the best balance; going higher reintroduces bufferbloat.

CAKE or fq_codel?

CAKE is recommended for most home connections because it handles per-host fairness and ACK filtering automatically. fq_codel is lighter and works on routers with very little CPU, but requires more tuning.

Does SQM work on Wi-Fi?

SQM shapes traffic at the WAN interface, so it applies to all clients whether wired or wireless. However, Wi-Fi has its own bufferbloat from the wireless driver; SQM does not fully eliminate that.

Sources

Checked against the official OpenWrt documentation on 2026-10-07. Behaviour that depends on release, target or hardware is called out in the steps above.

Written for wrtstudio.com. Tutorials are updated as OpenWrt releases evolve.

© 2026 WRT Studiowrtstudio.com · Built for everyday problem-solving.