
Sqm configuration can be a daunting task, but with the right guidance, you'll be up and running in no time.
To start, you'll need to enable sqm in your OpenWRT configuration. This can be done by setting the "sqm" option to "1" in the "network" section of your configuration file.
The default sqm configuration file is located in /etc/config/sqm. This file contains various settings that control how sqm operates, including the "sqm" option mentioned earlier.
The most important setting to consider is the "rate" option, which determines the maximum bandwidth that can be allocated to each client. This is typically set in kbps.
Tuning and Optimization
You can experiment with optimizing your max bandwidth, but be cautious not to overdo it.
Optimizing max bandwidth is optional, but if you want to try, you can start by reducing your upload and download speeds to 90% of your maximum speeds.
If your rating is still A or A+ on dslreports.com, you can keep it at 90% and then try pushing the limits by increasing it to 92%.
Tuning Session Walk-Through
As you sit down for a tuning session, you're likely to be bombarded with a plethora of data and metrics. This can be overwhelming, especially if you're new to the process.
To start, identify the key performance indicators (KPIs) that are most relevant to your application. In the "Understanding Your Application" section, we discussed how to determine the most critical metrics for your specific use case.
A typical tuning session involves iterating through several rounds of experimentation, each time refining your approach based on the results. This process can be time-consuming, but it's essential for achieving optimal performance.
By focusing on the most critical KPIs, you can quickly determine whether your changes are having a positive impact. For example, if you're optimizing for response time, you can use the "Benchmarking and Profiling" section to identify areas of improvement.
During the tuning session, it's essential to monitor your application's behavior in real-time. This will help you quickly identify any issues that may arise and make adjustments as needed.
As you iterate through each round of experimentation, be sure to take notes and track your progress. This will help you stay organized and ensure that you don't miss any critical insights.
Optimizing Max Bandwidth (Optional)

Optimizing max bandwidth can make a big difference in your internet experience. This step is optional, but it's worth considering if you want to squeeze out every last bit of speed from your connection.
You can start by experimenting with 85% of your maximum bandwidth, which is a common starting point. For example, if your upload and download speeds are 100 Mbps, you could try setting SQM to 85 Mbps.
If you retest at dslreports.com and get an A or A+ rating, you can keep it at 85%. But if you want to push the limits, you can try increasing it to 90% or even 92%. Just be aware that if you max out your available bandwidth, your ping times may increase.
Most websites don't come close to saturating your connection, but certain activities like publishing a YouTube video or updating a game can fill up your uplink or downlink. So, it's essential to find the sweet spot that works for you.

In fact, one person found that disabling SQM after they had everything dialed in resulted in a significantly worse test result. This shows just how important it is to find the right balance for your connection.
As a general rule, it's not recommended to go above 95% of your maximum speeds. So, if you're unsure, it's always best to err on the side of caution and stick with a lower setting.
Run Time Debugging
Run Time Debugging is a crucial step in fine-tuning your system. SQM_VERBOSITY_MAX controls the verbosity of sqm's output to the shell and syslog, with a range of 0 (no logging) to 8 (full debug output).
You can adjust SQM_VERBOSITY_MAX to suit your needs, but keep in mind that it won't affect the logs written by SQM_DEBUG. SQM_DEBUG controls whether sqm will log the output of the last invocation of start-sqm and stop-sqm into specific log files.
To log only the binary invocations and their output, you can set SQM_DEBUG=1 and SQM_VERBOSITY_MAX=0. This will provide you with a clear view of what's happening without overwhelming you with debug information.

Here are some example commands to get you started:
Keep in mind that these logs will be rewritten on every sqm instance start and stop, so be mindful of the media you're using. If you're using a hard disk, SSD, or flash drive with wear-leveling, you can safely set SQM_DEBUG to 1 in defaults.sh.
Queue Management
Queue management is crucial if your Internet connection's download speed is significantly faster than your upload speed. This is a common issue, especially with cable modems.
If your download speed is 10 or 20 times faster than your upload speed, queue management can have a dramatic impact.
You'll notice around 2% as much traffic on your uplink while running an Internet speed test. This indicates a bottleneck in your upload bandwidth.
The additional latency from filling up your cable modem's download capacity isn't a bufferbloat problem, but rather a consequence of insufficient upload bandwidth.
Running queue management is essential if you have a cable modem, as it helps manage your upload bandwidth and reduce latency.
In my case, I have a cable modem, and I've noticed that my upload bandwidth is not being utilized to its full potential. I have around 17 megabits of unused uplink bandwidth while my download speed is 800 megabits.
I've never noticed additional latency from other people in the house streaming movies or downloading large files. This is likely because I still have a significant amount of unused upload bandwidth.
Setting Up
To set up sqm-scripts, you'll need to install the necessary packages. On a regular Linux box, you can do this by running `sudo make install`, while on OpenWrt, you can simply install the `sqm-scripts` package and optionally `luci-app-sqm` for GUI support.
sqm-scripts uses the Linux qdisc mechanism to configure traffic shaping and scheduling. It can either use the HTB qdisc for shaping and fq_codel for packet scheduling, or the CAKE integrated scheduler to do both at once.
To enable sqm-scripts, you'll need to follow the installation instructions specific to your device, whether that's installing from source or using a package manager like OpenWrt's package manager.
See what others are reading: Openwrt Install Tailscale
Installing

Installing sqm-scripts on a regular Linux box is as simple as running the command sudo make install.
For OpenWrt, you can install the sqm-scripts package directly from the distribution, which will take care of all the dependencies.
If you're using OpenWrt, you should install the "normal" sqm-scripts package first to ensure everything is set up properly.
To update to the newest sqm-scripts on OpenWrt, you'll need to run the steps on your own computer, not on the router, to retrieve the latest script version from the repository.
This method relies on the presence of the required qdiscs on the router or destination host, so make sure they're installed beforehand.
On OpenWrt, installing the luci-app-sqm package will give you GUI support for the sqm-scripts.
Curious to learn more? Check out: Openwrt Travel Router
Setting Up Traffic Shaping
Setting Up Traffic Shaping is a crucial step in optimizing your network's performance.
To adjust SQM, navigate to the Network -> SQM QoS tab in your router's interface.
You'll need to checkmark the Enable this SQM instance box.
Calculate roughly 85% of your max DL and UL speeds in kbits/s and enter it in. For example, if your max download speed was 55000, you should enter in 46750 under Download speed.
Entering 100% of your DL and UL speeds will prevent SQM from working. We're trading off 10-15% of our total bandwidth to guarantee low latency and minimize packet loss.
The OpenWRT wiki advises using traffic shaping from the wiki, which is what the author did successfully.
The cake module may not be suitable for older routers with limited single-core CPU performance, as it can max out one core during speed tests.
Frequently Asked Questions
Is sqm better than QoS?
SQM offers more advanced features than QoS, including network scheduling, traffic shaping, and active queue length management, making it a more comprehensive solution for network optimization. If you're looking for prioritization only, QoS might be sufficient, but for a more robust network management system, SQM is the better choice.
Does sqm lower latency?
Yes, SQM helps reduce latency, making your internet experience smoother. By managing traffic more efficiently, SQM minimizes delays and ensures a more responsive connection.
Is OpenWrt still used?
Yes, many router manufacturers still use OpenWrt as the base for their stock firmware. It continues to be a foundation for ongoing development of key network algorithms.
Featured Images: pexels.com
