SQM (Smart Queue Management)

OpenWrt has a package called SQM for mitigating bufferbloat, the undesirable latency that arises when your router buffers too much data.

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

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 apps like VoIP, video chat, lag in online games, and generally makes the internet feel unresponsive. This can be mitigated with SQM.

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 not be able to keep up with your connection speed.

SQM is incompatible with software/hardware flow offloading which bypasses part of the network stack. Be sure to uncheck those features in LuCI → 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 to find your peak download/upload speeds:

  • Run a speed test from Waveform or Speedtest. Both display the latency during download and upload traffic, and grade your existing bufferbloat.
  • 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.

In LuCI go to Network → SQM QoS. The default settings will work, however you can improve performance with settings specific to your internet connection as described below:

  1. In the Basic Settings tab:
    • Check the Enable box
    • Set the Interface name to your internet (WAN) link. Interfaces are listed in the dropdown, or check Network → Interfaces to find the WAN port.
    • Set the Download and Upload speeds to 90% of what you measured in Preparation
  2. In the Queue Discipline tab:
    • Choose cake as the Queueing Discipline (or fq_codel, consider note 2)
    • Choose piece_of_cake.qos as the Queue Setup Script
    • Advanced Configuration may be left unchecked
  3. In the Link Layer Adaptation tab, select your link type (optional: set mpu see note 3):
    • For VDSL - Choose Ethernet, and set overhead 34 (or 26 if you're not using PPPoE) (mpu 68). If the link uses 100 Mbps ethernet, set overhead 42 (mpu 84).
    • For DSL of any other type - Choose ATM, and set overhead 44 (mpu 96).
    • For DOCSIS Cable - Choose Ethernet, and set overhead 22 (mpu 64). For rates > 760 Mbps, set overhead 42 (mpu 84), because 1 Gbps ethernet between modem and router affects the worst-case per-packet-overhead.
    • For Ethernet or Fiber - Choose Ethernet, and set overhead 44 (mpu 84).
    • If unsure, it's better to overestimate - Choose overhead 44 (mpu 96).
  4. Click Save & Apply.

That's it! You can confirm mitigation of bufferbloat 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. Note this ISP includes over-provisioning. Cake was selected with 90% dl/ul limits on baseline speedtest values. Latency increase under load dropped to zero, lower ping with no packet loss is observed during VoIP and online gaming during heavy internet usage. Speedtests results with and without SQM:

User's speedtest results with SQM.

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 this further via adjusting the dl/ul limits and with these steps:

  • Increase the Download speed limit and retest until latency begins to increase, then go back to a slightly lower value.
  • Repeat the same for the Upload speed.
  • Use Waveform speedtest to achieve A+ quality and A+ bufferbloat grades when optimal settings are found.
  • For DSL, the experiments above may produce download/upload values that are actually higher than the original speed test. This is ok, the 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-15% over-provisioning for the first 10 seconds (so speed tests look better!).

2. Cake is the preferred algorithm as it is excellent at mitigating bufferbloat. However, Fq_codel is often 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.

3. To set your link mpu (read SQM Details and SQM setting question) for efficiency improvements. Setting mpu will ensure rate shaping is correct for small packets.

4. Check the FAQ and Troubleshooting SQM guides for more information. See also: SQM configuration for advanced options.

5. Consider Cake tuning parameters: https://man7.org/linux/man-pages/man8/tc-cake.8.html

6. To use SQM it is necessary to disable hardware flow offloading as per this post.

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: 2024/05/10 14:53
  • by palebloodsky