Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
docs:guide-user:network:traffic-shaping:sqm [2024/05/08 17:43] – small clarifications throughout palebloodskydocs:guide-user:network:traffic-shaping:sqm [2024/05/10 14:52] – remove a dead link, and small language tweaks palebloodsky
Line 1: Line 1:
 ====== SQM (Smart Queue Management) ====== ====== 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.+OpenWrt has a package called SQM for mitigating [[wp>bufferbloat]], the undesirable latency that arises when your router buffers too much data.
  
-Install the ''[[:packages:pkgdata:luci-app-sqm|luci-app-sqm]]'' package (or ''[[:packages:pkgdata:sqm-scripts|sqm-scripts]]'' if you don't use LuCI) and read below.+Install ''[[:packages:pkgdata:luci-app-sqm|luci-app-sqm]]'' (or ''[[:packages:pkgdata:sqm-scripts|sqm-scripts]]'' if you don't use LuCI) and read below.
  
 ===== Overview ===== ===== Overview =====
  
-[[wp>Bufferbloat]] is most evident when a connection is heavily loaded with downloads or uploads which causes increased latency, or ping. It causes performance loss in realtime applications like VoIP, video chat, lag in online games, and generally makes the internet feel less responsive. This lag can be mitigated with SQM.+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” QoS only does prioritization, “classic” AQM only manages queue length.+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 [[https://forum.openwrt.org/t/so-you-have-500mbps-1gbps-fiber-and-need-a-router-read-this-first/90305|keep up]] with your connection speed. SQM is heavily CPU dependent. Slower devices may not be able to [[https://forum.openwrt.org/t/so-you-have-500mbps-1gbps-fiber-and-need-a-router-read-this-first/90305|keep up]] with your connection speed.
Line 17: Line 17:
 ===== Preparation: Measure Your Current Speed and Latency ===== ===== Preparation: Measure Your Current Speed and Latency =====
  
-Before you can optimize your network, you need to know its current state. When your network is quiet, run a speed test to find your peak down/upload link speeds:+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 [[https://www.waveform.com/tools/bufferbloat|Waveform]] or [[https://speedtest.net|Speedtest]]. Both display the latency during download and upload traffic, and grade your existing bufferbloat.   * Run a speed test from [[https://www.waveform.com/tools/bufferbloat|Waveform]] or [[https://speedtest.net|Speedtest]]. Both display the latency during download and upload traffic, and grade your existing bufferbloat.
-  * If you are using this OpenWrt device as an [[docs:guide-user:network:wifi:relay_configuration|Extender, Repeater or Bridge]], test the bufferbloat of your upstream network device (OpenWrt or otherwise) and determine if an issue is present there first.+  * If you are using this OpenWrt device as an [[docs:guide-user:network:wifi:relay_configuration|Extender, Repeateror Bridge]], test your upstream router (OpenWrt or otherwise) and determine if an issue is present there first.
  
 ===== Configuration ===== ===== Configuration =====
  
-In LuCI go to **Network -> SQM QoS**. The default values will work, however you can improve performance by setting values specific to your internet connection described below:+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:
  
   - In the **Basic Settings** tab:   - In the **Basic Settings** tab:
Line 35: Line 35:
   - In the **Link Layer Adaptation** tab, select your link type (optional: set mpu see [[:docs:guide-user:network:traffic-shaping:sqm#a_little_more_sqm_tuning|note 3]]):   - In the **Link Layer Adaptation** tab, select your link type (optional: set mpu see [[:docs:guide-user:network:traffic-shaping:sqm#a_little_more_sqm_tuning|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 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 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 shaper rates > 760 Mbps, set overhead 42 (mpu 84), because now 1 Gbps ethernet between modem and router affects the worst-case per-packet-overhead. +    * //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) +    * //For Ethernet or Fiber// - Choose **Ethernet**, and set overhead 44 (mpu 84). 
-    * //If unsure, it's better to overestimate// - Choose overhead 44 (mpu 96)+    * //If unsure, it's better to overestimate// - Choose overhead 44 (mpu 96).
   - Click **Save & Apply**.   - Click **Save & Apply**.
  
Line 45: Line 45:
 ===== Results ===== ===== Results =====
  
-As an example, the user below is running OpenWrt 23.05 on a [[toh:linksys:wrt_ac_series|WRT32X]] router. The internet connection is a DOCSIS cable modem with 500/35 Mbit service. Note this ISP is including over-provisioning on downloads. 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:+As an example, the user below is running OpenWrt 23.05 on a [[toh:linksys:wrt_ac_series|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:
  
-[[https://www.waveform.com/tools/bufferbloat?test-id=e101a8fc-f017-4eef-8f90-b27bcb783d62|Link to user's speedtest results.]]+[[https://www.waveform.com/tools/bufferbloat?test-id=e101a8fc-f017-4eef-8f90-b27bcb783d62|User's speedtest results with SQM.]]
  
 ^   Speedtest Results   ^^^^^^^^ ^   Speedtest Results   ^^^^^^^^
Line 56: Line 56:
 ===== A Little More Tuning  ===== ===== A Little More Tuning  =====
  
-1. The steps above will handle latency well, but you may improve speed and latency further via adjusting the dl/ul limits and with these steps:+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.   * 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.   * Repeat the same for the Upload speed.
-  * Use [[https://www.waveform.com/tools/bufferbloat|Waveform]] or [[http://dslreports.com/speedtest|DSLReports]] speedtest to achieve A+ quality and A+ bufferbloat grades when optimal settings are found. +  * Use [[https://www.waveform.com/tools/bufferbloat|Waveform]] speedtest to achieve A+ quality and A+ bufferbloat grades when optimal settings are found. 
-  * For DSL, the experiments above may produce Download and Upload values that are actually //higher// than the original speed test results. 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 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!).   * 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 often the [[https://www.bufferbloat.net/projects/codel/wiki/Cake/|preferred algorithm]] as it is excellent at mitigating bufferbloat. However, Fq_codel is often a faster, albeit less comprehensive option. One user found [[https://forum.openwrt.org/t/netgear-r6220-sqm-results-downstream-cut-in-half-and-my-optimal-settings/114301|fq_codel gave about 15% higher throughput when CPU limited]] and this [[https://lists.bufferbloat.net/pipermail/cake/2018-April/003384.html|email thread showed similar results]].+2. Cake is the [[https://www.bufferbloat.net/projects/codel/wiki/Cake/|preferred algorithm]] as it is excellent at mitigating bufferbloat. However, Fq_codel is often a faster, albeit less comprehensive option. One user found [[https://forum.openwrt.org/t/netgear-r6220-sqm-results-downstream-cut-in-half-and-my-optimal-settings/114301|fq_codel gave about 15% higher throughput when CPU limited]] and this [[https://lists.bufferbloat.net/pipermail/cake/2018-April/003384.html|email thread showed similar results]].
  
-3. To set your link **mpu** (read [[docs:guide-user:network:traffic-shaping:sqm-details|SQM Details]] and [[https://forum.openwrt.org/t/sqm-setting-question-link-layer-adaptation/2514/9|SQM setting question]]) for efficiency improvements. Setting mpu will ensure rate shaping is correct for the smallest packets.+3. To set your link **mpu** (read [[docs:guide-user:network:traffic-shaping:sqm-details|SQM Details]] and [[https://forum.openwrt.org/t/sqm-setting-question-link-layer-adaptation/2514/9|SQM setting question]]) for efficiency improvements. Setting mpu will ensure rate shaping is correct for small packets.
  
 4. Check the [[docs:guide-user:network:traffic-shaping:sqm-details#faq|FAQ]] and [[docs:guide-user:network:traffic-shaping:sqm-details#troubleshooting_sqm|Troubleshooting SQM]] guides for more information. See also: [[:docs:guide-user:network:traffic-shaping:sqm_configuration|SQM configuration]] for advanced options. 4. Check the [[docs:guide-user:network:traffic-shaping:sqm-details#faq|FAQ]] and [[docs:guide-user:network:traffic-shaping:sqm-details#troubleshooting_sqm|Troubleshooting SQM]] guides for more information. See also: [[:docs:guide-user:network:traffic-shaping:sqm_configuration|SQM configuration]] for advanced options.
  • Last modified: 2024/11/07 18:49
  • by palebloodsky