TTR Networks

Intermediate · Traffic shaping with CAKE on Debian · section 1 of 8

Bufferbloat, and the lab

✓ Lab-tested 5 November 2026 on Debian 13.7 (kernel 6.12, in a QEMU VM), iproute2 6.15.0, systemd 257, iperf3 3.18

Measure bufferbloat on an office line, then fix it on a Debian 13 router with CAKE: shaping uploads on the WAN and downloads through an IFB, fair shares between hosts, making it permanent with systemd-networkd, and tuning it for your line.

By the end you will be able to:

  • Measure bufferbloat as latency under load
  • Shape uploads with CAKE on the WAN interface, and downloads with CAKE on an IFB
  • Choose the shaping rate, and read CAKE's statistics
  • Share the line fairly between hosts with dual-srchost and dual-dsthost, including behind NAT
  • Make shaping survive a reboot with systemd-networkd and a systemd service

Prerequisites: Debian as an office router: interfaces, VLANs and a firewall

Someone in the office starts a big upload, a backup to the cloud say, and suddenly video calls stutter, web pages crawl and SSH sessions lag, for everyone. The link isn't broken, and it isn't really "full": a single upload is using all of it, and everything else is stuck in a queue behind it. That queue is the problem, and it has a name: bufferbloat.

Every link that's slower than the network feeding it needs a buffer. A broadband modem receives packets from your router at a gigabit and sends them out at, say, 5 Mbit/s, so packets wait in its buffer. Modems are typically built with large, simple first-in-first-out buffers, often big enough to hold a second or more of traffic. A bulk transfer keeps that buffer full, and every other packet, your ping, your VoIP call, your keystroke, waits behind it.

You can't change the modem's buffer. What you can do is make your router send a little slower than the line, so the queue builds up in the router instead, and then manage that queue well. That's what CAKE (Common Applications Kept Enhanced) does: a shaper, a fair queue per flow and per host, and active queue management (AQM) that keeps every queue short, in one Linux queueing discipline with very few settings.

The lab, and why it's a VM

The office router, gw, sits between the office LAN (two PCs) and a "modem" with a 5 Mbit/s upload and a 20 Mbit/s download, each with a deep buffer, as many real ones have. Beyond the modem is a server to measure against with ping and iperf3.

Unlike the other Debian lessons, the router here is a real Debian 13 virtual machine, not a container. Containers share the host's kernel, and Docker Desktop's kernel is built without CAKE (and without fq_codel). Debian's own kernel has both, so the lab runs Debian's official cloud image under QEMU, the same way the VyOS lessons run VyOS. Everything you type on gw is plain Debian 13.

Diagram: The CAKE lab — Two office PCs behind a Debian router, a modem with a slow, deep-buffered line, and a server to measure against.
  1. The queue builds in the modem. An upload fills the 5 Mbit/s line. The router sends far faster, so packets pile up in the modem's buffer, and a ping waits behind up to a second of upload.
  2. Uploads: CAKE on the WAN. gw shapes to 4.5 Mbit/s, just under the line, so the queue is in the router, where CAKE keeps it short: ping 2.2 ms during the upload.
  3. Downloads: CAKE on an IFB. Incoming packets are redirected to an IFB device and shaped to 18 Mbit/s, so the ISP's queue stays empty: ping 0.64 ms during a download.
  4. Fair between hosts. With dual-srchost and dual-dsthost, one connection on client gets as much as eight on client2.