Penguin
Blame: LinuxQualityOfService
EditPageHistoryDiffInfoLikePages
Annotated edit history of LinuxQualityOfService version 12, including all changes. View license author blame.
Rev Author # Line
3 JamesSpooner 1 Before you start, if you want an authoritive guide to the following material, read [The Linux Advanced Routing and Traffic Control HOWTO | http://lartc.org/lartc.html ] instead.
2
6 StuartYeates 3 This is a brief but concerted effort to minimise the effect of [TCP] traffic on interactive applications, using QoS under [Linux].
1 JamesSpooner 4
6 StuartYeates 5 The major motivating factor behind this work was the effect the new queuing imposed _before_ the bandwidth throttling at the RAN, on [Telecom]'s network in early 2004.
1 JamesSpooner 6
7 I live in a flat where we pay 3rds of the cost of the internet bill, so between three people, they each should have an even crack at the bandwidth.
8
9 I devised two queuing structures that should give a decent balance between users, one for egress on the internal interface and one for egress on the external interface.
10
11 DanielLawson 11 <pre>
1 JamesSpooner 12 Egress on internal interface (eth0).
13
2 JamesSpooner 14 Root Class
15 Qdisc 1: PRIO
1 JamesSpooner 16 ----------------------------------------------
17 | Class 1:1: PRIO Queue priority 1 |
2 JamesSpooner 18 | Qdisc 10: CBQ 128kbit |
1 JamesSpooner 19 | ------------------------------------------ |
20 | | Class 10:1(CBQ Class, 128kbit) | |
2 JamesSpooner 21 | | Qdisc 101: SFQ | |
1 JamesSpooner 22 | | -------------------------------------- | |
23 | | | High Priority Per-User Queue | | |
24 | | | For interactive applications | | |
25 | | | and ICMP etc. | | |
26 | | -------------------------------------- | |
27 | | Class 10:2(CBQ Class, 128kbit) | |
2 JamesSpooner 28 | | Qdisc 102: SFQ | |
1 JamesSpooner 29 | | -------------------------------------- | |
30 | | | High Priority Per-User Queue | | |
31 | | | For interactive applications | | |
32 | | | and ICMP etc. | | |
33 | | -------------------------------------- | |
34 | | Class 10:x(CBQ Class, 128kbit) | |
2 JamesSpooner 35 | | Qdisc 10x: SFQ | |
1 JamesSpooner 36 | | -------------------------------------- | |
37 | | | High Priority Per-User Queue | | |
38 | | | For interactive applications | | |
39 | | | and ICMP etc. | | |
40 | | -------------------------------------- | |
41 | | Class 10:5(CBQ Class, 120kbit) | |
2 JamesSpooner 42 | | Qdisc 105: TBQ (Rate 96kbit) | |
1 JamesSpooner 43 | | -------------------------------------- | |
44 | | | Low Priority Per-User Queue | | |
2 JamesSpooner 45 Routing -> | | | For TCP and other non-interactive | | | -> Network card
1 JamesSpooner 46 | | | applications. | | |
47 | | -------------------------------------- | |
48 | | Class 10:6(CBQ Class, 120kbit) | |
2 JamesSpooner 49 | | Qdisc 106: TBQ (Rate 96kbit) | |
1 JamesSpooner 50 | | -------------------------------------- | |
51 | | | Low Priority Per-User Queue | | |
52 | | | For TCP and other non-interactive | | |
53 | | | applications. | | |
54 | | -------------------------------------- | |
55 | | Class 10:x(CBQ Class, 120kbit) | |
2 JamesSpooner 56 | | Qdisc 10x: TBQ (Rate 96kbit) | |
1 JamesSpooner 57 | | -------------------------------------- | |
58 | | | Low Priority Per-User Queue | | |
59 | | | For TCP and other non-interactive | | |
60 | | | applications. | | |
61 | | -------------------------------------- | |
62 | ------------------------------------------ |
63 | Class 1:2 (PRIO band priority 2) |
2 JamesSpooner 64 | Qdisc 20: SFQ |
1 JamesSpooner 65 | ------------------------------------------ |
66 | | Bypass Queue for internal | |
67 | | Traffic | |
68 | ------------------------------------------ |
69 | |
70 ----------------------------------------------
71
72
73 Egress on external interface (ppp0).
74
2 JamesSpooner 75 Root Class
76 Qdisc 10: CBQ 128kbit
77 ------------------------------------------
78 | Class 10:1(CBQ Class, 128kbit) |
79 | Qdisc 101: SFQ |
80 | -------------------------------------- |
81 | | High Priority Per-User Queue | |
82 | | For interactive applications | |
6 StuartYeates 83 | | and [ICMP] etc. | |
2 JamesSpooner 84 | -------------------------------------- |
85 | Class 10:2(CBQ Class, 128kbit) |
86 | Qdisc 102: SFQ |
87 | -------------------------------------- |
88 | | High Priority Per-User Queue | |
89 | | For interactive applications | |
90 | | and ICMP etc. | |
91 | -------------------------------------- |
92 | Class 10:x(CBQ Class, 128kbit) |
93 | Qdisc 10x: SFQ |
94 | -------------------------------------- |
95 | | High Priority Per-User Queue | |
96 | | For interactive applications | |
97 | | and ICMP etc. | |
98 | -------------------------------------- |
99 | Class 10:5(CBQ Class, 120kbit) |
100 | Qdisc 105: TBQ (Rate 96kbit) |
101 | -------------------------------------- |
102 | | Low Priority Per-User Queue | |
6 StuartYeates 103 Routing -> | | For TCP and other non-interactive | | -> [ADSL] modem
2 JamesSpooner 104 | | applications. | |
105 | -------------------------------------- |
106 | Class 10:6(CBQ Class, 120kbit) |
107 | Qdisc 106: TBQ (Rate 96kbit) |
108 | -------------------------------------- |
109 | | Low Priority Per-User Queue | |
110 | | For TCP and other non-interactive | |
111 | | applications. | |
112 | -------------------------------------- |
113 | Class 10:x(CBQ Class, 120kbit) |
114 | Qdisc 10x: TBQ (Rate 96kbit) |
115 | -------------------------------------- |
116 | | Low Priority Per-User Queue | |
117 | | For TCP and other non-interactive | |
118 | | applications. | |
119 | -------------------------------------- |
120 ------------------------------------------
11 DanielLawson 121 </pre>
2 JamesSpooner 122
3 JamesSpooner 123 Linux QoS is based around a heirachical structure of queueing disciples (qdiscs), classes and filters.
124
125 There are two major types of qdiscs, those that are classful, or contain classes, and those that are classless, or leaf qdiscs.
126
127 Examples of Classless qdiscs
128 * TBF - Token Bucket Filtering
129 * SFQ - Stochiastic fairness queueing.
130
131 Examples of Classful qdiscs
132 * CBQ - Class Based queueing
133 * HTB - Heirachial Token Bucket Queueing
134 * PRIO - Priority Queuing
135
136 Of these classful qdiscs, some such as the PRIO class automagically create classes under the qdisc. Others, such as CBQ require you to explicitly create the classes inside the qdisc if you wish to apply a qdisc to that class.
137
138 You can only apply a qdisc to a class, which is why classless qdiscs are therefore leaf nodes of the 'QoS tree' so to speak.
139
140 With this in mind, let us first create the QoS rules on the ppp0 interface.
141
142 First, lets delete everything and start on a clean slate.
143
11 DanielLawson 144 <pre>
3 JamesSpooner 145 root@sleepy:~# tc qdisc del dev ppp0 root
146 root@sleepy:~# tc qdisc show dev ppp0
11 DanielLawson 147 </pre>
3 JamesSpooner 148
149 Ok, now we need to add the qdisc to the device root class, we're using CBQ
150
12 DanielLawson 151 <pre>
7 MichaelBordignon 152 root@sleepy:~# tc qdisc add dev ppp0 root handle 10: cbq bandwidth 6Mbit rate 127kbit avpkt 1000
153 root@sleepy:~# tc qdisc show dev ppp0
154 qdisc cbq 10: rate 127Kbit (bounded,isolated) prio no-transmit
155 root@sleepy:~# tc class show dev ppp0
156 class cbq 10: root rate 127Kbit (bounded,isolated) prio no-transmit
12 DanielLawson 157 </pre>
3 JamesSpooner 158
159 Notice how this has created a root class, we could refer to it as 10:0 if we desired.
160 Lets create the first of our High priority queues.
161
12 DanielLawson 162 <pre>
7 MichaelBordignon 163 root@sleepy:~# tc class add dev ppp0 parent 10: classid 10:1 cbq bandwidth 6Mbit rate 127kbit weight 20kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 200 bounded
164 root@sleepy:~# tc class show dev ppp0
165 class cbq 10: root rate 127Kbit (bounded,isolated) prio no-transmit
166 class cbq 10:1 parent 10: rate 127Kbit (bounded) prio no-transmit
12 DanielLawson 167 </pre>
3 JamesSpooner 168
169 And apply the SFQ to traffic in that queue!
170
12 DanielLawson 171 <pre>
7 MichaelBordignon 172 root@sleepy:~# tc qdisc show dev ppp0
173 qdisc sfq 101: quantum 1500b
174 qdisc cbq 10: rate 127Kbit (bounded,isolated) prio no-transmit
12 DanielLawson 175 </pre>
3 JamesSpooner 176
177 This is what the QoS looks like now.
178
12 DanielLawson 179 <pre>
3 JamesSpooner 180 Root Class
181 Qdisc 10: CBQ 127kbit
182 ------------------------------------------
183 | Class 10:1(CBQ Class, 127kbit) |
184 | Qdisc 101: SFQ |
185 | -------------------------------------- |
186 | | High Priority Per-User Queue | |
187 | | For interactive applications | |
188 | | and ICMP etc. | |
189 | -------------------------------------- |
190 ------------------------------------------
12 DanielLawson 191 </pre>
3 JamesSpooner 192
193 Lets have a look at whats happening with traffic so far:
12 DanielLawson 194 <pre>
3 JamesSpooner 195 root@sleepy:~# tc -d -s qdisc show dev ppp0
196 qdisc sfq 101: quantum 1500b limit 128p flows 128/1024
197 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
198
199 qdisc cbq 10: rate 127Kbit cell 8b (bounded,isolated) prio no-transmit/8 weight 127Kbit allot 1500b
200 level 1 ewma 5 avpkt 1000b maxidle 1921us
201 Sent 7672003 bytes 14328 pkts (dropped 70, overlimits 0)
202 borrowed 0 overactions 0 avgidle 50393 undertime 0
203
204 root@sleepy:~# tc -d -s class show dev ppp0
205 class cbq 10: root rate 127Kbit cell 8b (bounded,isolated) prio no-transmit/8 weight 127Kbit allot 1500b
206 level 1 ewma 5 avpkt 1000b maxidle 1921us
207 Sent 7713158 bytes 14548 pkts (dropped 70, overlimits 0)
208 borrowed 0 overactions 0 avgidle 48819 undertime 0
209 class cbq 10:1 parent 10: leaf 101: rate 128Kbit cell 8b (bounded) prio no-transmit/8 weight 20Kbit allot 1514b
210 level 0 ewma 5 avpkt 200b maxidle 10812us
211 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
212 borrowed 0 overactions 0 avgidle 283475 undertime 0
12 DanielLawson 213 </pre>
3 JamesSpooner 214
12 DanielLawson 215 Well as we can see, things appear to be working, at least to a certain point.
3 JamesSpooner 216
217 All traffic is being queued by the root class, and not being passed to the SFQ qdisc inside class 10:1.
218
219 Now we need to use the third major building block of Linux QoS, the filter.
220
221 We need to apply a filter, to the root qdisc 10: to move certian traffic to the 10:1 class.
222
223 Linux iptables comes with a feature called fwmark, which allows packets to be tagged as they traverse firewall rules. This can be useful for tagging packets for QoS based on PROTO/IP/PORT information. The iptables MARK target, can be applied to the PREROUTING or POSTROUTING chains on any interface. Because however, I use IP MASQUERADING on my ppp0 interface, the internal IP of the source host sending data to the internet via ADSL has been lost in the ppp0 POSTROUTING chain.
224
225 Therefore, we will use the PREROUTING chain on the eth0 interface to mark the packets.
226
12 DanielLawson 227 <pre>
3 JamesSpooner 228 root@sleepy:~# iptables -t mangle -I PREROUTING -j MARK --set-mark 100 -s 10.1.13.3/32 -i eth0
229 root@sleepy:~# iptables -L -n -t mangle -x -v
230 Chain PREROUTING (policy ACCEPT 367 packets, 125801 bytes)
231 pkts bytes target prot opt in out source destination
232 32 2000 MARK all -- eth0 * 10.1.13.3 0.0.0.0/0 MARK set 0x64
233
12 DanielLawson 234 </pre>
3 JamesSpooner 235 We are now marking packets with 100, or hex 0x64.
236
237 All that remains to get packets matching the SFQ, is to add the filter with tc:
238
239
240
241 And the results...
242
243 Before:
244
12 DanielLawson 245 <pre>
3 JamesSpooner 246 root@sleepy:~# tc -s -d qdisc show dev ppp0
247 qdisc sfq 101: quantum 1500b limit 128p flows 128/1024
248 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
249
250 qdisc cbq 10: rate 127Kbit cell 8b (bounded,isolated) prio no-transmit/8 weight 127Kbit allot 1500b
251 level 1 ewma 5 avpkt 1000b maxidle 1921us
252 Sent 22225127 bytes 39734 pkts (dropped 103, overlimits 0)
253 borrowed 0 overactions 0 avgidle 50393 undertime 0
254
255 root@sleepy:~# tc -s -d class show dev ppp0
256 class cbq 10: root rate 127Kbit cell 8b (bounded,isolated) prio no-transmit/8 weight 127Kbit allot 1500b
257 level 1 ewma 5 avpkt 1000b maxidle 1921us
258 Sent 22206812 bytes 39626 pkts (dropped 103, overlimits 0)
259 borrowed 0 overactions 0 avgidle 50393 undertime 0
260 class cbq 10:1 parent 10: leaf 101: rate 128Kbit cell 8b (bounded) prio no-transmit/8 weight 20Kbit allot 1514b
261 level 0 ewma 5 avpkt 200b maxidle 10812us
262 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
263 borrowed 0 overactions 0 avgidle 283475 undertime 0
12 DanielLawson 264 </pre>
3 JamesSpooner 265 Adding Filter:
12 DanielLawson 266 <pre>
3 JamesSpooner 267 root@sleepy:~# tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 100 fw flowid 10:1
268 root@sleepy:~# tc filter show dev ppp0
269 filter parent 10: protocol ip pref 1 fw
270 filter parent 10: protocol ip pref 1 fw handle 0x64 classid 10:1
12 DanielLawson 271 </pre>
3 JamesSpooner 272 After:
12 DanielLawson 273 <pre>
3 JamesSpooner 274 root@sleepy:~# tc -s -d qdisc show dev ppp0
275 qdisc sfq 101: quantum 1500b limit 128p flows 128/1024
276 Sent 548 bytes 9 pkts (dropped 0, overlimits 0)
277
278 qdisc cbq 10: rate 127Kbit cell 8b (bounded,isolated) prio no-transmit/8 weight 127Kbit allot 1500b
279 level 1 ewma 5 avpkt 1000b maxidle 1921us
280 Sent 22437536 bytes 40128 pkts (dropped 103, overlimits 0)
281 borrowed 0 overactions 0 avgidle 50393 undertime 0
282
283 root@sleepy:~# tc -s -d class show dev ppp0
284 class cbq 10: root rate 127Kbit cell 8b (bounded,isolated) prio no-transmit/8 weight 127Kbit allot 1500b
285 level 1 ewma 5 avpkt 1000b maxidle 1921us
286 Sent 22308840 bytes 39979 pkts (dropped 103, overlimits 0)
287 borrowed 0 overactions 0 avgidle 50393 undertime 0
288 class cbq 10:1 parent 10: leaf 101: rate 128Kbit cell 8b (bounded) prio no-transmit/8 weight 20Kbit allot 1514b
289 level 0 ewma 5 avpkt 200b maxidle 10812us
290 Sent 244 bytes 4 pkts (dropped 0, overlimits 0)
291 borrowed 0 overactions 0 avgidle 283475 undertime 0
12 DanielLawson 292 </pre>
3 JamesSpooner 293
294 Alright, now we're getting some traffic in the SFQ now!
4 JamesSpooner 295
296 Adding the rest of the queues is relatively straight forward, providing you use a sane numbering scheme for your qdisc/class handles.
297
298 Here is the script to setup the QoS structure for ADSL as above, we're adding 5 user queues, for expansions sake, if they're not used, they don't affect anyone else.
299
12 DanielLawson 300 <pre>
4 JamesSpooner 301 # Clear the slate
302 tc qdisc del dev ppp0 root
303
304 # Add a classful qdisc (cbq) to the root class
305
306 tc qdisc add dev ppp0 root handle 10: cbq bandwidth 6Mbit rate 127kbit avpkt 1000
307
308 # High priority Queues
309 # Add the 5 High Priority classes under the CBQ Qdisc
310 tc class add dev ppp0 parent 10: classid 10:1 cbq bandwidth 100Mbit rate 127kbit weight 20kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 200 bounded
311 tc class add dev ppp0 parent 10: classid 10:2 cbq bandwidth 100Mbit rate 127kbit weight 20kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 200 bounded
312 tc class add dev ppp0 parent 10: classid 10:3 cbq bandwidth 100Mbit rate 127kbit weight 20kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 200 bounded
313 tc class add dev ppp0 parent 10: classid 10:4 cbq bandwidth 100Mbit rate 127kbit weight 20kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 200 bounded
314 tc class add dev ppp0 parent 10: classid 10:5 cbq bandwidth 100Mbit rate 127kbit weight 20kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 200 bounded
315
316 # Add leaf qdiscs to these queues
317 tc qdisc add dev ppp0 parent 10:1 handle 101: sfq
318 tc qdisc add dev ppp0 parent 10:2 handle 102: sfq
319 tc qdisc add dev ppp0 parent 10:3 handle 103: sfq
320 tc qdisc add dev ppp0 parent 10:4 handle 104: sfq
321 tc qdisc add dev ppp0 parent 10:5 handle 105: sfq
322
323 # Add filters to match FWMARK packets and sort into these queues
324 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 101 fw flowid 10:1
325 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 102 fw flowid 10:2
326 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 103 fw flowid 10:3
327 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 104 fw flowid 10:4
328 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 105 fw flowid 10:5
329
330
331 # Low Priority Queues
332 tc class add dev ppp0 parent 10: classid 10:6 cbq bandwidth 100Mbit rate 120kbit weight 5kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1500 bounded
333 tc class add dev ppp0 parent 10: classid 10:7 cbq bandwidth 100Mbit rate 120kbit weight 5kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1500 bounded
334 tc class add dev ppp0 parent 10: classid 10:8 cbq bandwidth 100Mbit rate 120kbit weight 5kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1500 bounded
335 tc class add dev ppp0 parent 10: classid 10:9 cbq bandwidth 100Mbit rate 120kbit weight 5kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1500 bounded
336 tc class add dev ppp0 parent 10: classid 10:10 cbq bandwidth 100Mbit rate 120kbit weight 5kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1500 bounded
337
338 # Add leaf qdiscs to these queues
339 tc qdisc add dev ppp0 parent 10:6 handle 106: tbf rate 96kbit buffer 16384 limit 16384 mpu 200
340 tc qdisc add dev ppp0 parent 10:7 handle 107: tbf rate 96kbit buffer 16384 limit 16384 mpu 200
341 tc qdisc add dev ppp0 parent 10:8 handle 108: tbf rate 96kbit buffer 16384 limit 16384 mpu 200
342 tc qdisc add dev ppp0 parent 10:9 handle 109: tbf rate 96kbit buffer 16384 limit 16384 mpu 200
343 tc qdisc add dev ppp0 parent 10:10 handle 110: tbf rate 96kbit buffer 16384 limit 16384 mpu 200
344
345 # Add filters to match FWMARK packets and sort into these queues
346 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 106 fw flowid 10:6
347 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 107 fw flowid 10:7
348 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 108 fw flowid 10:8
349 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 109 fw flowid 10:9
350 tc filter add dev ppp0 protocol ip parent 10: prio 1 handle 110 fw flowid 10:10
12 DanielLawson 351 </pre>
4 JamesSpooner 352
353 Now, all that is needed is to use iptables to MARK packets for the appropriate queues.
354 Remember MARK does not immediately RETURN the packet. I get around this by marking every packet first, then having the sorting rules match on that mark, so once a packet is marked, it won't be marked again in that table.
355
9 MattBrown 356 Heres what my PREROUTING chain looks like.
4 JamesSpooner 357
12 DanielLawson 358 <pre>
4 JamesSpooner 359 Chain PREROUTING (policy ACCEPT 294 packets, 114705 bytes)
360 pkts bytes target prot opt in out source destination
361 716 207616 MARK all -- eth0 * 0.0.0.0/0 0.0.0.0/0 MARK set 0x80
362 18 1080 MARK icmp -- etho * 10.1.13.3 0.0.0.0/0 MARK match 0x80 MARK set 0x65
363 0 0 MARK icmp -- eth0 * 10.1.13.7 0.0.0.0/0 MARK match 0x80 MARK set 0x66
364 5 420 MARK icmp -- eth0 * 0.0.0.0/0 0.0.0.0/0 MARK match 0x80 MARK set 0x69
365 5 320 MARK udp -- eth0 * 10.1.13.3 0.0.0.0/0 MARK match 0x80 MARK set 0x65
366 0 0 MARK udp -- eth0 * 10.1.13.7 0.0.0.0/0 MARK match 0x80 MARK set 0x66
367 52 6074 MARK udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 MARK match 0x80 MARK set 0x69
368 159 7296 MARK all -- eth0 * 10.1.13.3 0.0.0.0/0 MARK match 0x80 MARK set 0x6a
369 435 189427 MARK all -- eth0 * 10.1.13.7 0.0.0.0/0 MARK match 0x80 MARK set 0x6b
370 42 2999 MARK all -- eth0 * 0.0.0.0/0 0.0.0.0/0 MARK match 0x80 MARK set 0x6e
12 DanielLawson 371 </pre>
4 JamesSpooner 372 Cross-Referencing with the tc filters, we see ..
373
12 DanielLawson 374 <pre>
4 JamesSpooner 375 root@sleepy:~# tc filter show dev ppp0
376 filter parent 10: protocol ip pref 1 fw
377 filter parent 10: protocol ip pref 1 fw handle 0x65 classid 10:1
378 filter parent 10: protocol ip pref 1 fw handle 0x66 classid 10:2
379 filter parent 10: protocol ip pref 1 fw handle 0x67 classid 10:3
380 filter parent 10: protocol ip pref 1 fw handle 0x68 classid 10:4
381 filter parent 10: protocol ip pref 1 fw handle 0x69 classid 10:5
382 filter parent 10: protocol ip pref 1 fw handle 0x6a classid 10:6
383 filter parent 10: protocol ip pref 1 fw handle 0x6b classid 10:7
384 filter parent 10: protocol ip pref 1 fw handle 0x6c classid 10:8
385 filter parent 10: protocol ip pref 1 fw handle 0x6d classid 10:9
386 filter parent 10: protocol ip pref 1 fw handle 0x6e classid 10:10
12 DanielLawson 387
388 </pre>
4 JamesSpooner 389
390 For example, a udp packet arriving on eth0 with source address 10.1.13.3 will be market with 0x65, and sent to class 10:1, which has a SFQ qdisc on the child class of CBQ, while a TCP packet from 10.1.13.7 will be marked with 0x6b and sent to class 10:7 which has a token bucken qdisc on a child class of a CBQ.
391
12 DanielLawson 392 <pre>
4 JamesSpooner 393 root@sleepy:~# tc -s -d class show dev ppp0
394 ....
395 class cbq 10:1 parent 10: leaf 101: rate 127Kbit cell 8b (bounded) prio no-transmit/8 weight 20Kbit allot 1514b
396 level 0 ewma 5 avpkt 200b maxidle 10898us
397 Sent 23370 bytes 383 pkts (dropped 0, overlimits 0)
398 borrowed 0 overactions 0 avgidle 285710 undertime 0
399 ...
400 class cbq 10:7 parent 10: leaf 107: rate 120Kbit cell 8b (bounded) prio no-transmit/8 weight 5Kbit allot 2250b
401 level 0 ewma 5 avpkt 1500b maxidle 86516us
402 Sent 4149672 bytes 6294 pkts (dropped 341, overlimits 0)
403 backlog 11p
404 ....
405
5 JamesSpooner 406 root@sleepy:~# tc -s -d qdisc show dev ppp0
407 ...
408 qdisc tbf 107: rate 96Kbit burst 16Kb/8 mpu 200b lat 1us
409 Sent 4149672 bytes 6294 pkts (dropped 341, overlimits 35289)
410 ...
411 qdisc sfq 101: quantum 1500b limit 128p flows 128/1024
412 Sent 23370 bytes 383 pkts (dropped 0, overlimits 0)
413 ...
12 DanielLawson 414 </pre>
4 JamesSpooner 415
416 What remains to do is setup the egress on the internal interface, eth0, and FWMARK packets coming in on the external interface, so we can remark them into the queues.
10 MichaelBordignon 417
418 If you're still confused, this looks like a rather well commented QoS script:
419 http://archives.seul.org/or/talk/May-2005/msg00066.html
420
421 A rather outdated but still useful page showing the various disciplines
422 http://www.opalsoft.net/qos/DS-21.htm
423
8 IanMcDonald 424 ----
425 See also TrafficShaping