SQM (Smart Queue Management)
Smart Queue Management
SQM is an advanced router feature that prevents bufferbloat by actively managing queue depth, keeping latency low even when the connection is fully saturated.
SQM (Smart Queue Management) is a class of queue management algorithms designed to solve bufferbloat — the latency inflation that occurs when router buffers fill up during heavy traffic. Standard FIFO queuing lets buffers grow until they are full, adding hundreds of milliseconds of latency. SQM prevents this by keeping queues short and dropping or delaying packets intelligently before the buffer overflows.
Why bufferbloat happens and what SQM does about it
Modern routers and modems have large buffers — sometimes capable of holding hundreds of milliseconds of data — intended to smooth over brief bursts. The problem is that TCP fills any available buffer and keeps it full. When you start a large download, your router's outbound buffer saturates within seconds. Every other packet — your gaming traffic, VoIP audio, video call — sits behind the download in that queue and waits. Measured latency can jump from 5 ms idle to 300 ms or more under load. SQM attacks this by combining two techniques: traffic shaping (rate-limiting the connection slightly below line speed to keep the queue from ever filling) and Active Queue Management (AQM) algorithms that drop or delay packets early, signaling TCP senders to back off before the buffer overflows.
fq_codel: fair queuing plus controlled delay
FQ-CoDel (Fair Queuing Controlled Delay) is the algorithm at the heart of most SQM implementations. It works in two layers. The fair queuing layer hashes flows (each unique source/destination/port combination) into separate sub-queues and round-robins between them. This prevents any single flow from monopolising the buffer — a large download shares the queue equally with a small VoIP packet. The CoDel (Controlled Delay) layer tracks sojourn time — how long a packet has been sitting in the queue. If sojourn time stays above a target (typically 5 ms) for more than an interval (typically 100 ms), CoDel marks or drops packets to force TCP to slow down. The combination keeps latency near the target even when the link is saturated.
CAKE: an improvement on fq_codel
CAKE (Common Applications Kept Enhanced) is a newer AQM algorithm that extends fq_codel with additional features. It handles both download and upload shaping in a single qdisc, with built-in awareness of ATM/ADSL overhead compensation (important for DSL users, where the true line overhead differs from the Ethernet payload size). CAKE also provides optional priority tiers based on DSCP markings, diffserv classification, and host isolation — spreading bandwidth fairly between different hosts even when they share the same flow classification. For most users CAKE is now the recommended algorithm when available.
How to configure SQM
The most capable SQM implementation is in OpenWrt. Under LuCI (the OpenWrt web interface), navigate to Network → SQM QoS. Enable the interface, set the download and upload speeds to 85–95% of your measured speeds, and select the CAKE or fq_codel script. Apply and test with a bufferbloat test tool that measures latency under load. The speed values you enter are critical — setting them too high defeats the shaping; too low wastes bandwidth unnecessarily. Some consumer routers (certain Asus models with Adaptive QoS, Ubiquiti EdgeRouters, and a few Netgear Nighthawk models) offer SQM or CAKE modes in their standard firmware.
Setting bandwidth accurately
SQM only works if the shaper runs at the real bottleneck. If you tell SQM your connection is 100 Mbps but your ISP delivers 80 Mbps, the ISP's modem becomes the true bottleneck and SQM never gets to manage the queue. Measure your actual speeds with a speed test at off-peak hours, then configure SQM to 90% of those values. If your speed varies significantly throughout the day, set to the lower end to ensure SQM remains in control during all conditions.
SQM vs basic QoS priority queuing
Basic QoS assigns traffic to priority queues — gaming traffic goes in a high-priority queue, downloads in a low-priority queue. This helps, but the high-priority queue can itself suffer bufferbloat if it fills up. SQM manages queue depth at every level using AQM, not just priority. The practical difference: with basic QoS, latency can still spike to 50–100 ms under load; with SQM and CAKE, latency under full saturation is typically within 5–15 ms of idle latency. For gaming and VoIP, SQM is more effective. For strict bandwidth rationing between users (e.g., limiting streaming to 20 Mbps), basic QoS is more appropriate — the two approaches can also be combined.
Frequently Asked Questions
Does SQM reduce my internet speed?
SQM requires rate-limiting your connection to slightly below line speed — typically set to 90–95% of measured speed. This small headroom is necessary for the AQM algorithms to work. The speed reduction is minimal (5–10%) but the latency improvement under load is dramatic.
Is SQM the same as QoS?
SQM is a type of QoS, but more specifically targeted at bufferbloat prevention through active queue management. Basic QoS manages priority between traffic classes. SQM manages queue depth within classes to prevent latency spikes. For gaming and video calls, SQM provides better results than simple priority-based QoS.