SQM (Smart Queue Management)

OpenWrt supports SQM for mitigating bufferbloat, the undesirable latency that arises when your router buffers too much data.

Bufferbloat is most evident when a connection is heavily loaded with downloads or uploads. It causes increased latency (ping), resulting in poor performance for realtime tasks like VoIP, video chat, lag in online gaming, and generally makes the internet less responsive. This can be mitigated using SQM with a fast enough CPU and small reduction to peak throughput.

SQM is an integrated system that performs per-packet/per-flow network scheduling, active queue management (AQM), traffic shaping, rate limiting, and QoS prioritization. In comparison, “classic” AQM only manages queue length and “classic” QoS only does prioritization.

SQM is heavily CPU dependent. Slower devices may be unable to keep up with your connection speed.

SQM is incompatible with hardware flow offloading which bypasses part of the kernel as discussed in this thread. Be sure that is disabled in LuCI → Network → Firewall to use SQM.

Before you can optimize your network, you need to know its current state.

  • When your internet is quiet run a speed test from Waveform or Speedtest. This is to determine your peak download/upload speeds, latency, and grade your bufferbloat.
  • To maximize performance most devices will benefit from enabling Packet Steering under LuCI → Network → Interfaces → Global network options.
  • If you are using this OpenWrt device as an Extender, Repeater, or Bridge, test your upstream router (OpenWrt or otherwise) and determine if an issue is present there first.
  • If you are on a wireless AP, test your upstream router separately. If your AP wifi driver supports AQL limits (e.g. mt76 does) adjust/reduce those seperately to improve wifi latency.

Install luci-app-sqm (or sqm-scripts if you don't use LuCI) and read below.

In LuCI go to Network → SQM QoS:

  1. In the Basic Settings tab:
    • Check the Enable box
    • Set the Interface to your internet (WAN) link in the dropdown. Check Network → Interfaces if you need to determine your WAN port.
    • Enter your Download and Upload speeds to 90% of the results you tested in Preparation
  2. In the Queue Discipline tab:
    • Choose cake as the Queueing Discipline (or fq_codel, consider note 3)
    • Choose piece_of_cake.qos as the Queue Setup Script
    • Advanced Configuration may be left unchecked (see note 4 for advanced settings)
  3. In the Link Layer Adaptation tab, select your link and overhead (setting mpu is optional see note 2):
    • VDSL - choose Ethernet, and set overhead 34 (or 26 if you're not using PPPoE) (mpu 68). If the link is 100 Mbps Ethernet set overhead 42 (mpu 84).
    • DSL of any other type - choose ATM, and set overhead 44 (mpu 96).
    • DOCSIS Cable - choose Ethernet, and for rates < 760 Mbps set overhead 22 (mpu 64), for rates >= 760 Mbps set overhead 42 (mpu 84).
    • Fiber - choose Ethernet, and set overhead 44 (mpu 84).
    • Ethernet - choose Ethernet, and set overhead 44 (mpu 84).
    • If unsure - it's better to overestimate, choose Ethernet, and set overhead 44 (mpu 96).
  4. Click Save & Apply.

Done! You can confirm results by re-running the speedtest. Any increased ping during download/uploads will now be minimal.

As an example, the user below is running OpenWrt 23.05 on a WRT32X router. The internet connection is a DOCSIS cable modem with 500/35 Mbit service and this ISP includes over-provisioning. SQM cake was selected with 90% dl/ul limits on baseline speedtest values. Packet Steering is also enabled. Latency increase under load dropped to zero, lower ping with no packet loss is observed during VoIP and online gaming during heavy internet usage. The user's speedtest results with SQM and summary of tests below:

Speedtest Results
QoS Download Upload Unloaded Ping DL Latency UL Latency Quality grade Bufferbloat grade
None 532 Mbits 37 Mbits 12 ms +18 ms +38 ms B B
SQM 495 Mbits 28 Mbits 12 ms +0 ms +0 ms A+ A +

1. The steps above will handle latency well but you may improve it further with these steps:

  • Increase the Download and Upload speed limit settings and retest until bufferbloat latency begins to increase, then go back to a slightly lower value.
  • Test using Waveform speedtest to achieve A+ quality and A+ bufferbloat grades when optimal settings are found.
  • For DSL, this may produce download/upload values that are actually higher than the original speed test. This is ok, ATM framing bytes of a DSL link add an average of 9% overhead, and these settings tell SQM how to make up for that overhead.
  • For DOCSIS cable, some providers trick speed tests by adding 10% over-provisioning for the first 10 seconds (so speed tests look better!).

2. Set your mpu to ensure rate shaping is correct for small packets in LuCI under SQM QoS → Link Layer Adaptation → Advanced Linklayer Options. See SQM Details and SQM setting question for more details.

3. Cake is the preferred queuing discipline as it is excellent at mitigating bufferbloat. However fq_codel is a faster, albeit less comprehensive option. One user found fq_codel gave about 15% higher throughput when CPU limited and this email thread showed similar results. See discussion of these algorithms on this forum post.

4. See SQM configuration for advanced settings.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2025/01/10 04:15
  • by palebloodsky