24.01.2015
Quality of Service (qosscripts) configuration [OpenWrt Wiki]
http://wiki.openwrt.org/doc/uci/qos
1/4
Quality of Service (qosscripts) configuration
This is the documentation for the UCI configuration file
/etc/config/qos
. It is used by the package
qos‐scripts
only.
Do NOT install multiple QoSpackages simultaneously! Uninstall the old package before installing a new one.
There are at least two other QoS/ToS packages in the OpenWrt repositories regarding:
[https://dev.openwrt.org/browser/packages/net/dsl‐qos‐
[https://dev.openwrt.org/browser/packages/net/wshaper]
qos‐scripts
is written in AWK/shell script and uses
dsl‐qos‐queue
ATM (Asynchronous Transfer Mode)
[http://en.wikipedia.org/wiki/Asynchronous Transfer Mode]
significant. Removed in
[https://dev.openwrt.org/changeset/37494]
wshaper
http://lartc.org/wondershaper/
[http://lartc.org/wondershaper/]
For help writing your own script please see
Traffic Control on OpenWrt: configuring the Linux Network Scheduler
.
You can browse the scripts here:
[https://dev.openwrt.org/browser/trunk/package/network/config/qos‐scripts]
There is direct LuCIsupport for
qos‐scripts
called:
luci‐app‐qos
.
NOTE:
luci‐app‐qos
won't start until you enable the
qos
Initscript within the System–>Startup tab as well as enable qos under Network–>QoS
As of
[https://dev.openwrt.org/changeset/25641/trunk]
qos‐scripts
dropped the use of IMQ (package
iptables‐mod‐imq
– Intermediate Queueing
Device). Its successor is
IFB (Intermediate Functional Block device)
[http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb]
, (requires package:
kmod‐ifb
and the scheduler action
[https://dev.openwrt.org/browser/trunk/package/iproute2/patches/200act_connmark.patch?rev=25639]
As of
[https://dev.openwrt.org/changeset/31759]
qos‐scripts
replaced sfq/red with fq_codel to massively improve latency under load
Sections
A minimal QoS configuration usually consists of:
one interface section
some rules allocating packets to at least two buckets
configuration of the buckets.
Interface
Each Interface can have its own buffer. The
interface
section declares global characteristics of the connection on which the specified interface is communicating. The
following options are defined within this section:
config interface dsl
option enabled 1
option classgroup "Default"
option overhead 1
option upload 512
option download 4096
Name
Type
Required Default Description
enabled
boolean yes
1
Enable/Disable QoS
classgroup
string
yes?
(none)
no idea
overhead
boolean yes
1
decrease upload and download ratio to prevent link saturation
download
integer
yes
4096
in
kilobits/second
(only possible for tcp)
upload
integer
yes
512
in
kilobits/second
Rules
Each
classify
section defines one group of packets and which target (i.e. bucket) this group belongs to. All the packets share the bucket specified.
Name
Type
Required Default Description
target
bucket
yes
(none)
The four defaults are:
Priority, Express, Normal
and
Bulk
proto
string
no
0
Packets matching this protocol belong to the bucket defined in target
srchost
string
no
(none)
Packets matching this source host(s) (single IP or in CIDR notation) belong to the bucket defined in target
dsthost
string
no
(none)
Packets matching this destination host(s) (single IP or in CIDR notation) belong to the bucket defined in target
ports
integer no
(none)
Packets matching this, belong to the bucket defined in target
srcports
integer no
(none)
Packets matching this, belong to the bucket defined in target
24.01.2015
Quality of Service (qosscripts) configuration [OpenWrt Wiki]
http://wiki.openwrt.org/doc/uci/qos
2/4
dstports
integer no
(none)
Packets matching this, belong to the bucket defined in target
portrange
integer no
(none)
Packets matching this, belong to the bucket defined in target
pktsize
integer no
(none)
Packets matching this, belong to the bucket defined in target
tcpflags
string
no
(none)
Packets matching this, belong to the bucket defined in target
mark
string
no
(none)
Packets matching this, belong to the bucket defined in target
layer7
string
no
(none)
Packets matching this, belong to the bucket defined in target
connbytes
int
no
(none)
Packets matching this, belong to the bucket defined in target
tos
string
no
(none)
Packets matching this, belong to the bucket defined in target
dscp
string
no
(none)
Packets matching this, belong to the bucket defined in target
direction
string
no
(none)
Packets matching this traffic direction (
in
or
out
) belong to the bucket defined in target
Classgroup
As we can have more then one interface, we can have more then one classgroup.
Name
Type
Required Default Description
classes
bucket names yes
(none)
Specifies the number of buckets and their names
default
bucket name
yes
(none)
Defines which bucket is considered default
Classes
Each Bucket has its own configuration.
Name
Type
Required Default Description
packetsize
integer yes
(none)
in bytes
packetdelay
integer yes
(none)
in ms
maxsize
integer yes
(none)
in bytes
avgrate
integer yes
(none)
unknown, value in %
limitrate
integer no
100
Defines to how much percent of the available bandwidth this class is capped to, value in %
maxsize
integer yes
(none)
in bytes
priority
integer yes
(none)
in %
Classes (For Advanced Users)
Below is unverified technical breakdown of each /etc/config/qos claass parameters. Source:
[http://pastebin.com/YL55na2E]
### Params:
#
# maxsize:
# limits packet size in iptables rule
#
# avgrate: (note: sum(avgrates) ~ 100)
# rt m1 = avgrate / sum (avgrate) * max_bandwidth
# rt m2 = avgrate * max_bandwidth / 100
# ls m1 = rt m1
#
# packetsize & packetdelay: (only works if avgrate is present)
# rt d = max( packetdelay, 'time required for packetsize to transfer' ) (smaller ps ‐> smaller d)
# ls d = rt d
#
# priority:
# ls m2 = priority / sum (priority) * max_bandwidth
#
# limitrate:
# ul rate = limitrate * max_bandwidth / 100
Quick start guide
1. Install the qosscripts package:
opkg install qos‐scripts
2. Basic configuration using UCI command line:
uci set qos.wan.upload=1000 # Upload speed in kBits/s
uci set qos.wan.download=16000 # Download speed in kBits/s
uci set qos.wan.enabled=1
uci commit qos
3. Start it and look for error output and test):
/etc/init.d/qos start
4. Make script run at every boot up:
/etc/init.d/qos enable
24.01.2015
Quality of Service (qosscripts) configuration [OpenWrt Wiki]
http://wiki.openwrt.org/doc/uci/qos
3/4
Troubleshooting
(Last updated for: Barrier Breaker 14.07)
If your QoS doesn't seem to be working, it may be an error or typo in the config file is preventing it from loading properly.
Check enabled is set to 1 in /etc/config/qos(!)
Run iptablessave and check there are lines near the top prefixed with either A qos_Default or A qos_Default_ct, and featuring the –setxmark directive. Here's an
example:
‐A qos_Default ‐p tcp ‐m mark ‐‐mark 0x0/0xf0 ‐m tcp ‐‐sport 1024:65535 ‐‐dport 1024:65535 ‐j MARK ‐‐set‐xmark 0x44/0xff
The –setxmark is what flags the packet so it is picked up the traffic control subsystem.
Look at the generated traffic control qdisc settings by running:
tc qdisc
The default (ie noQoSapplied) values for any interface look like this:
qdisc fq_codel 0: dev eth0 root refcnt 2 limit 1024p flows 1024 quantum 300 target 5.0ms interval 100.0ms ecn
… Any interface with only a single qdisc line printed, showing the same settings as this line (this one is for dev eth0), indicates no QoS on that interface.
Network interfaces with QoS enabled will have multiple qdisc lines printed, each corresponding to a QoS class, etc.
If the printed qdisc settings don't seem to be correct, you can preview the tc commands generated from the OpenWRT /etc/config/qos by running:
/usr/lib/qos/generate.sh interface wan
(Replace 'wan' with the OpenWRT interface name you're debugging, as given in the /etc/config/qos file.)
This should print a series of insmod and tc commands used to set up the QoS subsystem. You can debug any errors caused by running these commands by running:
/usr/lib/qos/generate.sh interface wan | sh ‐x
(Note x option which tells sh to print each line as it is executed.)
The output of /usr/lib/qos/generate.sh is normally executed automatically as part of /etc/hotplug.d/iface/10qos.
txqueuelen
[http://www.bufferbloat.net/projects/codel/wiki]
(pronounced: Coddle), so this should not be needed.
[http://www.bufferbloat.net/projects/bloat/wiki/Linux_Tips#Reducetransmitqueuelength]
( Note: after i know about bufferbloat websearchd and many misguided users are asking about raising txqueuelen, or how to set it, and this was a recommended read
posted for them , and that just enabling QoS and setting up the rules i wanted didnt produce results, i thought of reduce txqueuelen from the default size of 1000 packets.
On most SOHO applications the upload speed is muchmuch lower than the interface speed (100M or 1G), and it's written that the def buffer is tailored for enterprise size
usage. I used values of 90 where[only] it was 1000 and it is wonderfully responsive and effective now, on a 256k connection. I also raised lenghts of 3 and 5 to 20 as i
imagined it might be hard to do any queuing/shaping on such ultra short buffers. Leave the 0s as 0. Btw, the 90 came by, that with 1500byte packet size and 256kbit
speed, it takes just half a sec to empty it. Well, i mistakenly took mtu as bits so it's 4 second really but i didnt have the courage for a drastically smaller than default
value, 90 already seem so smallish, and it works nicely anyway, awesome lack of latency, jitter and packetloss on the other machine, according to
congestion control to work to reduce "spamming", set speeds as it was envisioned, and keep things leveled out rather than fluctuating widely. While this doesnt directly
effects QoSing itself, it is extremely beneficial, even essential, to the results usually expected from employing it. It sets a foundation, a healthy network environment
over which QoS to function.
First we list the stuff with
ifconfig
. Then apply for example
ifconfig eth0 txqueuelen 90
and
ifconfig pppoe‐wan txqueuelen 20
etc accordingly. Finally an
uci commit
/etc/init.d/network reload
might be needed, i did a network restart too after this.)
Types and Groups
The
qos‐scripts
package didn't come with documentation and there has been some confusion about its features, among users. The information in this section comes
straight from nbd (the developer), so it should come a long way to clearing some confusion on two major issues.
The biggest item of contention was which group setting gives better performance, Priority or Express. As it turns out, it depends on the application. Priority boosts low
bandwidth small frames, such as TCPACKs and DNS more than Express. Express is for prioritizing bigger frames, which would include stuff like VoIP (port 5060).
Another biggie was the exact meaning of each type. Types are necessary for connection tracking. By default, Classify is not run on a connection that had already been
assigned a traffic class, so it is the initial connectiontracked classification. Reclassify can override the traffic class per packet, without altering the connection tracking
24.01.2015
Quality of Service (qosscripts) configuration [OpenWrt Wiki]
http://wiki.openwrt.org/doc/uci/qos
4/4
mark. Default is a fallback for everything that has not been marked by Classify/Reclassify. Rules get processed by type first (Classify gets processed first, then
Reclassify and finally Default) and then based on the order in the configuration file (top to bottom).
Tags
doc/uci/qos.txt · Last modified: 2014/10/07 04:11 by projectgus