Remove docs menu.inc and uci_menu.inc
[web.git] / docs / uci_qos.txt
1 ---
2 ---
3 Quality of Service (qos-scripts) configuration
4 ==============================================
5
6 == Quality of Service configuration
7
8 This is the documentation for the UCI configuration file **'/etc/config/qos'**.
9
10 *WARNING*: '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
11
12 == Sections
13
14 A minimal QoS configuration usually consists of:
15
16 * one _interface_ section
17 * some _rules_ allocating packets to at least two buckets
18 * _configuration_ of the buckets.
19
20 === Interface
21
22 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:
23
24 ----
25 config interface dsl
26 option enabled 1
27 option classgroup "Default"
28 option overhead 1
29 option upload 512
30 option download 4096
31 ----
32
33 [cols="4*1,4",options="header"]
34 |====
35 | Name | Type | Required | Default | Description
36 | 'enabled' | boolean | yes | '1' | Enable/Disable QoS
37 | 'classgroup' | string | yes | 'Default' | Specify 'classgroup' used for this interface (see description of 'classgroup' below)
38 | 'overhead' | boolean | yes | '1' | decrease upload and download ratio to prevent link saturation
39 | 'download' | integer | yes | '4096' | Download limit in 'kilobits/second'
40 | 'upload' | integer | yes | '512' | Upload limit in 'kilobits/second'
41 |====
42
43 === Rules
44
45 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.
46
47 [cols="4*1,4",options="header"]
48 |====
49 | Name | Type | Required | Default | Description
50 | 'target' | bucket | yes | _(none)_ | The four defaults are: 'Priority, Express, Normal' and 'Bulk'
51 | 'proto' | string | no | '0' | Packets matching this protocol belong to the bucket defined in target
52 | 'srchost' | string | no | _(none)_ | Packets matching this source host(s) (single IP or in CIDR notation) belong to the bucket defined in target
53 | 'dsthost' | string | no | _(none)_ | Packets matching this destination host(s) (single IP or in CIDR notation) belong to the bucket defined in target
54 | 'ports' | integer | no | _(none)_ | Packets matching this, belong to the bucket defined in target
55 | 'srcports' | integer | no | _(none)_ | Packets matching this, belong to the bucket defined in target
56 | 'dstports' | integer | no | _(none)_ | Packets matching this, belong to the bucket defined in target
57 | 'portrange' | integer | no | _(none)_ | Packets matching this, belong to the bucket defined in target
58 | 'pktsize' | integer | no | _(none)_ | Packets matching this, belong to the bucket defined in target
59 | 'tcpflags' | string | no | _(none)_ | Packets matching this, belong to the bucket defined in target
60 | 'mark' | string | no | _(none)_ | Packets matching this, belong to the bucket defined in target
61 | 'connbytes' | int | no | _(none)_ | Packets matching this, belong to the bucket defined in target
62 | 'tos' | string | no | _(none)_ | Packets matching this, belong to the bucket defined in target
63 | 'dscp' | string | no | _(none)_ | Packets matching this, belong to the bucket defined in target
64 | 'direction' | string | no | _(none)_ | Packets matching this traffic direction ('in' or 'out') belong to the bucket defined in target
65 |====
66
67 === Classgroup
68
69 As we can have more then one interface, we can have more then one classgroup.
70
71 ----
72 config classgroup "Default"
73 option classes "Priority Express Normal Bulk"
74 option default "Normal"
75 ----
76
77 [cols="4*1,4",options="header"]
78 |====
79 | Name | Type | Required | Default | Description
80 | 'classes' | bucket names | yes | _(none)_ | Specifies the list of names of _classes_
81 | 'default' | bucket name | yes | _(none)_ | Defines which _class_ is considered default
82 |====
83
84
85 === Classes
86
87 Each Bucket has its own configuration.
88
89 Example:
90 ----
91 config class "Normal"
92 option packetsize 1500
93 option packetdelay 100
94 option avgrate 10
95 option priority 5
96 ----
97
98 [cols="4*1,4",options="header"]
99 |====
100 | Name | Type | Required | Default | Description
101 | 'packetsize' | integer | yes | _(none)_ | in bytes
102 | 'packetdelay' | integer | yes | _(none)_ | in ms
103 | 'maxsize' | integer | yes | _(none)_ | in bytes
104 | 'avgrate' | integer | yes | _(none)_ | Average rate for this class, value in % of bandwidth (this value uses for calculate vaues 'Nx' of ''tc ... hfsc rt m1 N1 d N2 m2 N3'')
105 | 'limitrate' | integer | no | 100 | Defines to how much percent of the available bandwidth this class is capped to, value in %
106 | 'maxsize' | integer | yes | _(none)_ | in bytes
107 | 'priority' | integer | yes | _(none)_ | in %
108 |====
109
110 === Classes (For Advanced Users)
111
112 Below is unverified technical breakdown of each /etc/config/qos class parameters.
113
114 ----
115 ### Params:
116 #
117 # maxsize:
118 # limits packet size in iptables rule
119 #
120 # avgrate: (note: sum(avgrates) ~ 100)
121 # rt m1 = avgrate / sum (avgrate) * max_bandwidth
122 # rt m2 = avgrate * max_bandwidth / 100
123 # ls m1 = rt m1
124 #
125 # packetsize & packetdelay: (only works if avgrate is present)
126 # rt d = max( packetdelay, 'time required for packetsize to transfer' ) (smaller ps -> smaller d)
127 # ls d = rt d
128 #
129 # priority:
130 # ls m2 = priority / sum (priority) * max_bandwidth
131 #
132 # limitrate:
133 # ul rate = limitrate * max_bandwidth / 100
134 ----
135
136 == Quick start guide
137
138 Install the qos-scripts package:
139
140 ----
141 opkg install qos-scripts
142 ----
143
144 Basic configuration using UCI command line:
145
146 ----
147 uci set qos.wan.upload=1000 # Upload speed in kBits/s
148 uci set qos.wan.download=16000 # Download speed in kBits/s
149 uci set qos.wan.enabled=1
150 uci commit qos
151 ----
152
153 Start it and look for error output and test):
154
155 ----
156 /etc/init.d/qos start
157 ----
158
159 * Make script run at every boot up:
160
161 ----
162 /etc/init.d/qos enable
163 ----
164
165 == Troubleshooting
166
167 Look at the generated traffic control qdisc settings by running:
168
169 ----
170 tc qdisc
171 ----
172
173 The default (ie no-QoS-applied) values for any interface look like this:
174
175 ----
176 qdisc fq_codel 0: dev eth0 root refcnt 2 limit 1024p flows 1024 quantum 300 target 5.0ms interval 100.0ms ecn
177 ----
178
179 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.
180
181 Network interfaces with QoS enabled will have multiple qdisc lines printed, each corresponding to a QoS class, etc.
182
183 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:
184
185 ----
186 /usr/lib/qos/generate.sh interface wan
187 ----
188
189 (Replace 'wan' with the UCI interface name you're debugging, as given in the _/etc/config/qos_ file.)
190
191 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:
192
193 ----
194 /usr/lib/qos/generate.sh interface wan | sh -x
195 ----
196
197 The output of _/usr/lib/qos/generate.sh_ is normally executed automatically as part of _/etc/hotplug.d/iface/10-qos_.