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 [email protected] # 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.