Fair bandwidth sharing among different devices may be an issue on a local network, say torrent client on the PC sucking all upload bandwidth. If the router is running openwrt, such situation could be avoided by setting up openwrt qos.
What is QoS ? It stands for Quality of Service, simply how efficiently the bandwidth could be used to improve network quality and minimize network latency. It also ensures a fair portion of bandwidth is always available for critical applications.
Introduction to OpenWrt QoS LuCI, luci-app-sqm
Internet quality degradation on a fast network is mainly due to bufferbloat, excessive data buffering on the router causes this problem.
In this tutorial we're going to use the luci-app-sqm program to configure openwrt qos.
SQM stands for Smart Queue Management, and the SQM luci app is exactly for this, minimize the bufferbloat.
Smart Queue Management or SQM is easier to configure and understand than the previous luci-app-qos, as I think. Though both of them uses the tc command, part of traffic control application as QoS configuration back end. Read more about tc command here http://man.cx/tc .
I'm sure 99% people won't like to type a bunch of command to configure QoS on their router, that's why this openwrt qos luci application.
Install and configure luci-app-sqm on openwrt
Installation is pretty easy, you can install it from both command line and LuCI web interface.
Uninstall other previously installed(if any) OpenWrt QoS related packages like luci-app-qos or qos-scripts, they will interfere with sqm-scripts.
Installation process may require 550KB or more storage space, so if your router has limited flash space, openwrt extroot setup may be necessary. In fact you can't do this without extroot on a router with 4MB NOR flash, running OpenWrt Barrier Breaker (14.07) or later.
Install through command line:-
- First login to the openwrt router through ssh and make sure the router can reach the internet properly.
ssh firstname.lastname@example.org # On PC
ping -c 4 google.com # On OpenWrt
- Now update the opkg package repository and and install luci-app-sqm, these commands will install SQM with all dependency.
opkg update # On OpenWrt opkg install luci-app-sqm # On OpenWrt
- Now start the SQM service and enable automatic startup after each reboot.
/etc/init.d/sqm start # On OpenWrt /etc/init.d/sqm enable # On OpenWrt
Install through LuCI web interface:-
- This method is even easier, login to the router's web interface and go to the System > Software section from the dropdown menu. Update the package list and put luci-app-sqm in the Download and install package: field, this will install SQM QoS service with all dependency.
- Don't forget to start the SQM service, also add it to auto startup list , go to System > Startup section from the dropdown menu. Hit the Disabled button to enable auto startup and hit the Start button to start QoS service, the screenshot above may be helpful.
OpenWrt QoS settings with SQM in LuCI web interface
At this step you need to determine your internet download/upload speed and network latency, measurement should be done when network is idle. The official OpenWrt guide recommends to use www.dslreports.com/speedtest for speed testing and latency measurement. But I'm using http://speedtest.net or https://www.speedcheck.org/ simply for more available test servers.
Though network latency measurement is not necessary, you could do it with ping command. Note the time required to ping different domains and take the average time. Example bellow
ping -c 4 www.google.de
ping -c 4 www.google.com.br
From those tests I got about 2.62 Mbps download and 2.98 Mbps upload speed with a USB 3G mobile broadband connection. Average network latency was 140mS to maximum ~450mS . You may want to use google's data transfer rate converter to convert different formats.
Now configure the SQM, go to the Network > SQM QoS setting from the LuCI web interface dropdown menu.
- First check the enable box, in the Basic Settings tab to enable QoS .
- Select the Network interface, generally the eth1 or eth0 interface is used for the WAN network, for mobile broadband it's ppp0. For Tp-Link MR3220 the WAN interface is eth1 .
- Set the Download and Upload speed about 90-95% of your maximum speed, in kbps not kB/s, I've set 2480kbps download speed and 2800kbps upload speed, heavily rounded.
- Leave both options to default in the Queue Discipline tab, no need to change anything in the Show and Use Advanced Configuration section.
- Choose your connection type in the Link layer adaptation tab, it's pretty self explanatory, I'm choosing none as using a mobile broadband connection.
- Finally Hit the Save & Apply button, this will enable openwrt QoS on the router.
Test the openwrt qos capability
QoS capability could be tested many way, I'm giving an example bellow to simulate such situation.
- Connect a PC/laptop through the routers LAN port, if available, then run a heavy downloading app like a torrent client.
- Turn on router's wi-fi and connect one or two smartphone, start browsing few web pages.
- Give the wi-fi password to friends and tell them to chat on Skype.
- Connect another PC/laptop with the best ethernet cable you have to LAN port for testing.
Surely the above setup will impose a heavy stress on the network, now you from the last PC you could do some ping to remote servers like google, browse few webpages etc. etc. Now everything should be somewhat smoother than previous, i.e. without any QoS openwrt setup.
Credits: 50% credit goes to the official openwrt SQM documentation and rest 50% to Wikipedia, specially these links bellow.
Conclusion and thoughts on QoS
OpenWrt is bloating day by day, the luci is even more bloated, seriously a bad news for routers with limited flash.
DD-Wrt or Tomato USB could be alternative, but they don't support a wide range of hardware like openwrt.
Hope this openwrt qos tutorial is simple enough to understand and will help you to improve network quality. Just drop a comment if you have any suggestion or question, I'll like to hear from you.
Hi, maybe you will be able to help me, I have connected two PC one to LAN 1 and another to LAN3. I don't know how to seperate them and make qos for them, could you help me?
thx for great guide
im using OpenWrt 19.07.3 on netgear R6220
and after listing interfaces i have:
in configuration does it matter which network port I choose
eth0.2(wan) or pppoe-wan(wan) ?
i tested both and for pppoe-wan speedtest was lil bit faster
Arnab Satapathi says
Yes, it does matter, depending on the router, mot of them bridge the LAN interfaces together, but not the WAN interface.
Thankyou. I had been experiencing serious bandwidth degradation on my Linksys WRT1900AC only in the evenings, just when my wife and daughter would fire up their tablets and PCs, and the TV would kick in. In desperation I tried several range extenders, and even powerline transmission. Nothing made a difference so it had to be the router. I installed OpenWrt on the router and played with various settings. Still no cigar. I finally found your page. Installing sqm in LUCI was a snap. After following your configuration instructions and using the DSL Reports Speedtest, bufferbloat, quality and speed all improved dramatically. I can finally surf from my remote upstairs den. I'm still looking into how to fine tune sqm, but that should be fun.
Arnab Satapathi says
Good to know it helped you.
i have an issue i have the nighthawk r7800 i have istalled openwrt but it doesnt have luci-app-sqm how do i get this??
also i tried in available packages and it have said when updating lists failed to download package from lists??
how do i get this i even tried ssh to see if that would work but still not able to what could i be doing wrong??
Arnab Satapathi says
Which OpenWrt/LEDE version you're using?
May be the package isn't available anymore.
Would you mind explaining the options in the link layer adaptation tab? What would you suggest for standard residential LAN and WAN?
Why did you choose "none" for mobile?
First off, thank you very much for this guide. I feel moderately comfortable with SSH access to devices, but have limited knowledge of networking topics, syntax, and linux. I find guide like yours extremely helpful as a networking and OpenWRT/LEDE neewbie.
Quick question, how does this package differ from luci-app-qos or qos-scripts packages? What functionality is being traded here?
Also what are the advantages for sqm approach, vs. trying to control or prioritize usage for certain devices?
Arnab Satapathi says
The truth is I never unpacked the both packages and looked inside to find out how they're working. I got overall better network responsiveness with SQM and continued using it.
Now the second question, with the SQM approach you don't need to set priority of individual applications or devices again and again. It automatically calculates the best possible usage of the available bandwidth.
Though I never analyzed the luci-app-sqm package, but I presume it reserves a portion of bandwidth for critical networking functionalities, while slowing down the download and upload speed a little, thus making a better user experience.
https://wiki.openwrt.org/doc/howto/packet.scheduler/packet.scheduler, I think this page will be more useful for you.
Great, thanks for the response. Will read more into the packet scheduler!
My i have error notification like this
"root@OpenWrt:~# opkg install luci-app-sqm
Unknown package 'luci-app-sqm'.
* opkg_install_cmd: Cannot install package luci-app-sqm."
What seems to be the problem?
Arnab Satapathi says
What's the OpenWrt version you're using ?
Did you forgot to run opkg update before installing by any chance ?
You need to run "opkg update" first
Very well explained.
I've go one question though : will we still be able to set bandwith limit for specified ipaddresses?
Thanks a lot
I'm not very sure, but I think we can, let me check.
Sebastian Pieper says
Would love to know too please!
very useful. thanks
Huge help. Thank you!
Thanks for the feedback.