Skip to content
8 min read Updated

Discord Voice Choppy? It Was Bufferbloat: 51 Lines of Terraform

Discord voice sounded robotic to others but clean over mobile data. With no WAN QoS, a 50 Mbit upload saturated easily. The fix and its FastTrack catch.


Disclosure: This post contains Amazon affiliate links (marked with *). As an Amazon Associate I earn from qualifying purchases. Buying through them costs you nothing extra.

Discord voice was choppy, and in one direction only: I heard everyone fine, but others heard me as robotic, garbled audio that came and went. Over mobile data it was clean, which put the problem on my home network path, not Discord or the ISP.

The investigation led to a textbook bufferbloat setup on the MikroTik RB5009*: no QoS or AQM on the WAN interface, a 50 Mbit upload ceiling that is easy to saturate, and only the default interface queue, with no active queue management, doing nothing to stop one bulk transfer from monopolizing the link against latency-sensitive UDP voice traffic.

Update (November 2026): The PCQ simple queue below never shaped most traffic, for the FastTrack reason in the correction further down. On 2026-11-11 it was replaced by a CAKE queue tree on ether1 (kind=cake, diffserv4, nat, dual-srchost). That queue tree counted 0 bytes at first, even after a test that limited FastTrack to non-WAN traffic with a 68M cap; that test cost download throughput (849 to 711 Mbit/s) and doubled router CPU, so it was rolled back the same day. The real cause came on 2026-11-12: a queue tree leaf with an empty packet-mark receives no packets, and unmarked traffic needs packet-mark=no-mark. With that set and the cap raised to 68M (about 90% of the 74 Mbit/s upload measured then; the 50 Mbit figure below is from July), the post-apply check counted 159 MB through the queue, upload was 64.8 Mbit/s, and a ping to 1.1.1.1 under full upload was 11.3 ms against 10.2 ms idle (16.8 to 19.6 ms before). Interface-parented queue trees also see FastTracked packets, so global FastTrack stayed on. On 2026-11-22 a mangle rule started marking traffic from ether1 to the Fritz!Box LAN so it skips the shaper, because that LAN also hangs off ether1 and 4K streams to the TVs were being capped at 68 Mbit/s. The sections below describe the July attempt as it was.

View the complete homelab infrastructure source on GitHub

The Investigation

First step: check what was actually configured on the WAN. /queue simple and /queue tree were both empty, so ether1 (WAN) was running on its default interface queue. MikroTik’s Queues documentation gives only-hardware-queue as the default on its own hardware, which leaves queuing to the NIC’s transmit ring: plain FIFO behaviour, no active queue management.

The ISP profile is asymmetric cable: 1000 Mbit down, 50 Mbit up. That is the value from repeated live speed tests, not MySpeed’s configured target, which happened to match but wasn’t the authoritative source. A 50 Mbit uplink is easy to fill, and without AQM, nothing stops the send buffer from filling up and inflating latency for everything sharing the link.

The next question was what saturates the upload. I went through the WAN-upload consumers:

  • Garage/PBS backups: LAN-local, don’t cross the WAN. Ruled out.
  • PBS Google Drive offsite sync: already disabled (REL-051). Ruled out.
  • Image pulls: downloads, not uploads. Ruled out.
  • Cloudflare-tunneled remote Jellyfin/Immich streaming: the realistic WAN-upload consumer.

So the traffic profile is mostly latency-insensitive bulk upload (media streaming through Cloudflare), with Discord’s UDP voice flow competing for the same 50 Mbit.

Why Simple Queues, Not Queue Trees

The usual RouterOS QoS design is mangle plus queue tree: mark packets by type in mangle, then shape the marks with queue-tree rules. The obstacle here is that FastTrack is enabled globally (see firewall_deterministic.tf). Once a connection is fasttracked, its packets skip the firewall, including mangle, so a mark-based queue tree would stop seeing most real traffic, which is exactly the traffic that needs shaping.

My reasoning at the time was that an address-based Simple Queue sidesteps this: its target is a plain IP-range match with no mangle dependency. That part is true, but it does not get around FastTrack. See the correction below.

The Fix: PCQ Behind a Rate Cap

The change is 51 lines of Terraform, most of which is the comment block explaining the reasoning. The resource itself:

# terraform/stacks/network/qos.tf

resource "routeros_queue_simple" "wan_egress_sqm" {
  name      = "wan-egress-sqm"
  target    = ["10.0.0.0/16"]
  max_limit = "45M/900M"
  queue     = "pcq-upload-default/pcq-download-default"
  comment   = "SQM: cap WAN link under real measured ISP ceiling (1000/50 Mbit) + PCQ per-flow fairness so one bulk transfer can't fill the buffer and starve latency-sensitive traffic (Discord voice bufferbloat fix)"
}

Three details matter.

1. max_limit = "45M/900M": 90% of the real ceiling, not 100%. Capping below the ISP’s ceiling makes this router’s queue the bottleneck instead of the modem’s. Without that margin, the bottleneck (and its buffer) stays inside the ISP modem, outside this queue’s control, and the bufferbloat just happens there instead.

2. queue = "pcq-upload-default/pcq-download-default": fairness between hosts. PCQ splits traffic into sub-queues and serves them in turn. The default PCQ types classify by address (pcq-upload-default by source address, pcq-download-default by destination address), so the fairness is per host rather than per 5-tuple flow. For this problem that is enough: the Cloudflare tunnel’s bulk upload and the machine running Discord come from different LAN addresses, so each gets its own sub-queue instead of the bulk stream monopolizing the link.

3. target = ["10.0.0.0/16"]: all VLANs in one queue. Deliberately not split per VLAN yet. The goal is fixing the shared WAN bottleneck, not per-VLAN prioritization. All five VLANs (10.0.10.0/24 through 10.0.100.0/24) share this WAN link.

Correction: FastTrack Bypasses Simple Queues Too

The original version of this post (and the comment in qos.tf) claimed a Simple Queue works independently of FastTrack. That is wrong. MikroTik’s Packet Flow in RouterOS documentation lists what fasttracked packets skip: the firewall, connection tracking, simple queues, queue trees with parent=global, traffic-flow, IP accounting, IPsec, and more. With the global fasttrack-connection rule for established,related in place, this queue only sees packets that are not fasttracked, which leaves out most of a long-lived bulk stream.

So the queue above is not enough on its own. Two ways to make shaping actually apply, both documented by MikroTik:

  • Exempt the shaped traffic from FastTrack, for example by narrowing the fasttrack rule so WAN-bound traffic is accepted without being fasttracked. This costs router CPU, so measure the load at full line rate.
  • Shape on the interface queue instead. Interface queues are not on the FastTrack bypass list. Set ether1’s queue to a rate-limited AQM type, or attach a queue tree to ether1 (not parent=global).

A second claim from the original also needs correcting. I had concluded there was no CAKE because /queue type print listed only pfifo/bfifo/red/sfq/pcq/mq-pfifo. That command lists the queue types that are configured, not the kinds RouterOS supports. RouterOS 7, which the RB5009 runs, can create CAKE and fq_codel types with /queue type add kind=cake or kind=fq-codel. CAKE with a bandwidth limit on the WAN interface is the more direct fix for bufferbloat than PCQ.

Validation

Terraform: fmt -check, validate, and tflint were all clean on the change.

It was not applied when I wrote this. It went up as a PR for atlantis plan review (Atlantis has since been replaced by GitHub Actions workflows that keep the same PR comments), because I want to see the plan before any apply on the network stack. This is the gateway router, and a misconfiguration here affects every device in the apartment. Given the correction above, the plan and the change itself need another pass before the bufferbloat can count as fixed. That pass is the CAKE queue tree in the update at the top.


The principle carries over to any shared link: keep the bottleneck in a queue you control, cap it just below the real line rate, and do not let one bulk sender own the buffer. And confirm your shaping is actually on the packet path you think it is.

Was this helpful?
Share
David Woitzik

David Woitzik

Hybrid Cloud Engineer

I work mostly with Azure, Terraform, and Zero-Trust network design, and publish the Terraform templates and write-ups I wanted when I was solving the same problems.

Keep Reading

More Like This in Your Inbox

New Terraform modules and articles by email. No spam.