version 4 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
TC |
|
|
2 |
!!!TC |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
QDISCS |
|
|
7 |
CLASSES |
|
|
8 |
FILTERS |
|
|
9 |
CLASSLESS QDISCS |
|
|
10 |
CONFIGURING CLASSLESS QDISCS |
|
|
11 |
CLASSFUL QDISCS |
|
|
12 |
THEORY OF OPERATION |
|
|
13 |
NAMING |
|
|
14 |
UNITS |
|
|
15 |
TC COMMANDS |
|
|
16 |
HISTORY |
|
|
17 |
SEE ALSO |
|
|
18 |
AUTHOR |
|
|
19 |
---- |
|
|
20 |
!!NAME |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
tc - show / manipulate traffic control settings |
|
|
24 |
!!SYNOPSIS |
|
|
25 |
|
|
|
26 |
|
|
|
27 |
__tc qdisc [[ add | change | replace | link ] dev__ DEV |
|
|
28 |
__[[ parent__ qdisc-id __| root ] [[ handle__ qdisc-id ] |
|
|
29 |
qdisc [[ qdisc specific parameters ] |
|
|
30 |
|
|
|
31 |
|
|
|
32 |
__tc class [[ add | change | replace ] dev__ DEV |
|
|
33 |
__parent__ qdisc-id __[[ classid__ class-id ] qdisc [[ |
|
|
34 |
qdisc specific parameters ] |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
__tc filter [[ add | change | replace ] dev__ DEV __[[ |
|
|
38 |
parent__ qdisc-id __| root ] protocol__ protocol |
|
|
39 |
__prio__ priority filtertype [[ filtertype specific |
|
|
40 |
parameters ] __flowid__ flow-id |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
__tc [[-s | -d ] qdisc show [[ dev__ DEV |
|
|
44 |
__]__ |
|
|
45 |
|
|
|
46 |
|
|
|
47 |
__tc [[-s | -d ] class show dev__ DEV |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
__tc filter show dev__ DEV |
|
|
51 |
!!DESCRIPTION |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
__Tc__ is used to configure Traffic Control in the Linux |
|
|
55 |
kernel. Traffic Control consists of the |
|
|
56 |
following: |
|
|
57 |
|
|
|
58 |
|
|
|
59 |
SHAPING |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
When traffic is shaped, its rate of transmission is under |
|
|
63 |
control. Shaping may be more than lowering the available |
|
|
64 |
bandwidth - it is also used to smooth out bursts in traffic |
|
|
65 |
for better network behaviour. Shaping occurs on |
|
|
66 |
egress. |
|
|
67 |
|
|
|
68 |
|
|
|
69 |
SCHEDULING |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
By scheduling the transmission of packets it is possible to |
|
|
73 |
improve interactivity for traffic that needs it while still |
|
|
74 |
guaranteeing bandwidth to bulk transfers. Reordering is also |
|
|
75 |
called prioritizing, and happens only on |
|
|
76 |
egress. |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
POLICING |
|
|
80 |
|
|
|
81 |
|
|
|
82 |
Where shaping deals with transmission of traffic, policing |
|
|
83 |
pertains to traffic arriving. Policing thus occurs on |
|
|
84 |
ingress. |
|
|
85 |
|
|
|
86 |
|
|
|
87 |
DROPPING |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
Traffic exceeding a set bandwidth may also be dropped |
|
|
91 |
forthwith, both on ingress and on egress. |
|
|
92 |
|
|
|
93 |
|
|
|
94 |
Processing of traffic is controlled by three kinds of |
|
|
95 |
objects: qdiscs, classes and filters. |
|
|
96 |
!!QDISCS |
|
|
97 |
|
|
|
98 |
|
|
|
99 |
__qdisc__ is short for 'queueing discipline' and it is |
|
|
100 |
elementary to understanding traffic control. Whenever the |
|
|
101 |
kernel needs to send a packet to an interface, it is |
|
|
102 |
__enqueued__ to the qdisc configured for that interface. |
|
|
103 |
Immediately afterwards, the kernel tries to get as many |
|
|
104 |
packets as possible from the qdisc, for giving them to the |
|
|
105 |
network adaptor driver. |
|
|
106 |
|
|
|
107 |
|
|
|
108 |
A simple QDISC is the 'pfifo' one, which does no processing |
|
|
109 |
at all and is a pure First In, First Out queue. It does |
|
|
110 |
however store traffic when the network interface can't |
|
|
111 |
handle it momentarily. |
|
|
112 |
!!CLASSES |
|
|
113 |
|
|
|
114 |
|
|
|
115 |
Some qdiscs can contain classes, which contain further |
|
|
116 |
qdiscs - traffic may then be enqueued in any of the inner |
|
|
117 |
qdiscs, which are within the __classes.__ When the kernel |
|
|
118 |
tries to dequeue a packet from such a __classful qdisc__ |
|
|
119 |
it can come from any of the classes. A qdisc may for example |
|
|
120 |
prioritize certain kinds of traffic by trying to dequeue |
|
|
121 |
from certain classes before others. |
|
|
122 |
!!FILTERS |
|
|
123 |
|
|
|
124 |
|
|
|
125 |
A __filter__ is used by a classful qdisc to determine in |
|
|
126 |
which class a packet will be enqueued. Whenever traffic |
|
|
127 |
arrives at a class with subclasses, it needs to be |
|
|
128 |
classified. Various methods may be employed to do so, one of |
|
|
129 |
these are the filters. All filters attached to the class are |
|
|
130 |
called, until one of them returns with a verdict. If no |
|
|
131 |
verdict was made, other criteria may be available. This |
|
|
132 |
differs per qdisc. |
|
|
133 |
|
|
|
134 |
|
|
|
135 |
It is important to notice that filters reside __within__ |
|
|
136 |
qdiscs - they are not masters of what happens. |
|
|
137 |
!!CLASSLESS QDISCS |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
The classless qdiscs are: |
|
|
141 |
|
|
|
142 |
|
|
|
143 |
[[p|b]fifo |
|
|
144 |
|
|
|
145 |
|
|
|
146 |
Simplest usable qdisc, pure First In, First Out behaviour. |
|
|
147 |
Limited in packets or in bytes. |
|
|
148 |
|
|
|
149 |
|
|
|
150 |
pfifo_fast |
|
|
151 |
|
|
|
152 |
|
|
|
153 |
Standard qdisc for 'Advanced Router' enabled kernels. |
|
|
154 |
Consists of a three-band queue which honors Type of Service |
|
|
155 |
flags, as well as the priority that may be assigned to a |
|
|
156 |
packet. |
|
|
157 |
|
|
|
158 |
|
|
|
159 |
red |
|
|
160 |
|
|
|
161 |
|
|
|
162 |
Random Early Detection simulates physical congestion by |
|
|
163 |
randomly dropping packets when nearing configured bandwidth |
|
|
164 |
allocation. Well suited to very large bandwidth |
|
|
165 |
applications. |
|
|
166 |
|
|
|
167 |
|
|
|
168 |
sfq |
|
|
169 |
|
|
|
170 |
|
|
|
171 |
Stochastic Fairness Queueing reorders queued traffic so each |
|
|
172 |
'session' gets to send a packet in turn. |
|
|
173 |
|
|
|
174 |
|
|
|
175 |
tbf |
|
|
176 |
|
|
|
177 |
|
|
|
178 |
The Token Bucket Filter is suited for slowing traffic down |
|
|
179 |
to a precisely configured rate. Scales well to large |
|
|
180 |
bandwidths. |
|
|
181 |
!!CONFIGURING CLASSLESS QDISCS |
|
|
182 |
|
|
|
183 |
|
|
|
184 |
In the absence of classful qdiscs, classless qdiscs can only |
|
|
185 |
be attached at the root of a device. Full |
|
|
186 |
syntax: |
|
|
187 |
|
|
|
188 |
|
|
|
189 |
__tc qdisc add dev__ DEV __root__ QDISC |
|
|
190 |
QDISC-PARAMETERS |
|
|
191 |
|
|
|
192 |
|
|
|
193 |
To remove, issue |
|
|
194 |
|
|
|
195 |
|
|
|
196 |
__tc qdisc del dev__ DEV __root__ |
|
|
197 |
|
|
|
198 |
|
|
|
199 |
The __pfifo_fast__ qdisc is the automatic default in the |
|
|
200 |
absence of a configured qdisc. |
|
|
201 |
!!CLASSFUL QDISCS |
|
|
202 |
|
|
|
203 |
|
|
|
204 |
The classful qdiscs are: |
|
|
205 |
|
|
|
206 |
|
|
|
207 |
CBQ |
|
|
208 |
|
|
|
209 |
|
|
|
210 |
Class Based Queueing implements a rich linksharing hierarchy |
|
|
211 |
of classes. It contains shaping elements as well as |
|
|
212 |
prioritizing capabilities. Shaping is performed using link |
|
|
213 |
idle time calculations based on average packet size and |
|
|
214 |
underlying link bandwidth. The latter may be ill-defined for |
|
|
215 |
some interfaces. |
|
|
216 |
|
|
|
217 |
|
|
|
218 |
HTB |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
The Hierarchy Token Bucket implements a rich linksharing |
|
|
222 |
hierarchy of classes with an emphasis on conforming to |
|
|
223 |
existing practices. HTB facilitates guaranteeing bandwidth |
|
|
224 |
to classes, while also allowing specification of upper |
|
|
225 |
limits to inter-class sharing. It contains shaping elements, |
|
|
226 |
based on TBF and can prioritize classes. |
|
|
227 |
|
|
|
228 |
|
|
|
229 |
PRIO |
|
|
230 |
|
|
|
231 |
|
|
|
232 |
The PRIO qdisc is a non-shaping container for a configurable |
|
|
233 |
number of classes which are dequeued in order. This allows |
|
|
234 |
for easy prioritization of traffic, where lower classes are |
|
|
235 |
only able to send if higher ones have no packets available. |
|
|
236 |
To facilitate configuration, Type Of Service bits are |
|
|
237 |
honored by default. |
|
|
238 |
!!THEORY OF OPERATION |
|
|
239 |
|
|
|
240 |
|
|
|
241 |
Classes form a tree, where each class has a single parent. A |
|
|
242 |
class may have multiple children. Some qdiscs allow for |
|
|
243 |
runtime addition of classes (CBQ, HTB) while others (PRIO) |
|
|
244 |
are created with a static number of children. |
|
|
245 |
|
|
|
246 |
|
|
|
247 |
Qdiscs which allow dynamic addition of classes can have zero |
|
|
248 |
or more subclasses to which traffic may be |
|
|
249 |
enqueued. |
|
|
250 |
|
|
|
251 |
|
|
|
252 |
Furthermore, each class contains a __leaf qdisc__ which |
|
|
253 |
by default has __pfifo__ behaviour though another qdisc |
|
|
254 |
can be attached in place. This qdisc may again contain |
|
|
255 |
classes, but each class can have only one leaf |
|
|
256 |
qdisc. |
|
|
257 |
|
|
|
258 |
|
|
|
259 |
When a packet enters a classful qdisc it can be |
|
|
260 |
__classified__ to one of the classes within. Three |
|
|
261 |
criteria are available, although not all qdiscs will use all |
|
|
262 |
three: |
|
|
263 |
|
|
|
264 |
|
|
|
265 |
tc filters |
|
|
266 |
|
|
|
267 |
|
|
|
268 |
If tc filters are attached to a class, they are consulted |
|
|
269 |
first for relevant instructions. Filters can match on all |
|
|
270 |
fields of a packet header, as well as on the firewall mark |
|
|
271 |
applied by ipchains or iptables. See |
|
|
272 |
tc-filters(8). |
|
|
273 |
|
|
|
274 |
|
|
|
275 |
Type of Service |
|
|
276 |
|
|
|
277 |
|
|
|
278 |
Some qdiscs have built in rules for classifying packets |
|
|
279 |
based on the TOS field. |
|
|
280 |
|
|
|
281 |
|
|
|
282 |
skb- |
|
|
283 |
|
|
|
284 |
|
|
|
285 |
Userspace programs can encode a class-id in the |
|
|
286 |
'skb- |
|
|
287 |
|
|
|
288 |
|
|
|
289 |
Each node within the tree can have its own filters but |
|
|
290 |
higher level filters may also point directly to lower |
|
|
291 |
classes. |
|
|
292 |
|
|
|
293 |
|
|
|
294 |
If classification did not succeed, packets are enqueued to |
|
|
295 |
the leaf qdisc attached to that class. Check qdisc specific |
|
|
296 |
manpages for details, however. |
|
|
297 |
!!NAMING |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
All qdiscs, classes and filters have IDs, which can either |
|
|
301 |
be specified or be automatically assigned. |
|
|
302 |
|
|
|
303 |
|
|
|
304 |
IDs consist of a major number and a minor number, separated |
|
|
305 |
by a colon. |
|
|
306 |
|
|
|
307 |
|
|
|
308 |
QDISCS |
|
|
309 |
|
|
|
310 |
|
|
|
311 |
A qdisc, which potentially can have children, gets assigned |
|
|
312 |
a major number, called a 'handle', leaving the minor number |
|
|
313 |
namespace available for classes. The handle is expressed as |
|
|
314 |
'10:'. It is customary to explicitly assign a handle to |
|
|
315 |
qdiscs expected to have children. |
|
|
316 |
|
|
|
317 |
|
|
|
318 |
CLASSES |
|
|
319 |
|
|
|
320 |
|
|
|
321 |
Classes residing under a qdisc share their qdisc major |
|
|
322 |
number, but each have a separate minor number called a |
|
|
323 |
'classid' that has no relation to their parent classes, only |
|
|
324 |
to their parent qdisc. The same naming custom as for qdiscs |
|
|
325 |
applies. |
|
|
326 |
|
|
|
327 |
|
|
|
328 |
FILTERS |
|
|
329 |
|
|
|
330 |
|
|
|
331 |
Filters have a three part ID, which is only needed when |
|
|
332 |
using a hashed filter hierarchy, for which see |
|
|
333 |
tc-filters(8). |
|
|
334 |
!!UNITS |
|
|
335 |
|
|
|
336 |
|
|
|
337 |
All parameters accept a floating point number, possibly |
|
|
338 |
followed by a unit. |
|
|
339 |
|
|
|
340 |
|
|
|
341 |
Bandwidths or rates can be specified in: |
|
|
342 |
|
|
|
343 |
|
|
|
344 |
kbps |
|
|
345 |
|
|
|
346 |
|
|
|
347 |
Kilobytes per second |
|
|
348 |
|
|
|
349 |
|
|
|
350 |
mbps |
|
|
351 |
|
|
|
352 |
|
|
|
353 |
Megabytes per second |
|
|
354 |
|
|
|
355 |
|
|
|
356 |
kbit |
|
|
357 |
|
|
|
358 |
|
|
|
359 |
Kilobits per second |
|
|
360 |
|
|
|
361 |
|
|
|
362 |
mbit |
|
|
363 |
|
|
|
364 |
|
|
|
365 |
Megabits per second |
|
|
366 |
|
|
|
367 |
|
|
|
368 |
bps or a bare number |
|
|
369 |
|
|
|
370 |
|
|
|
371 |
Bits per second |
|
|
372 |
|
|
|
373 |
|
|
|
374 |
Amounts of data can be specified in: |
|
|
375 |
|
|
|
376 |
|
|
|
377 |
kb or k |
|
|
378 |
|
|
|
379 |
|
|
|
380 |
Kilobytes |
|
|
381 |
|
|
|
382 |
|
|
|
383 |
mb or m |
|
|
384 |
|
|
|
385 |
|
|
|
386 |
Megabytes |
|
|
387 |
|
|
|
388 |
|
|
|
389 |
mbit |
|
|
390 |
|
|
|
391 |
|
|
|
392 |
Megabits |
|
|
393 |
|
|
|
394 |
|
|
|
395 |
kbit |
|
|
396 |
|
|
|
397 |
|
|
|
398 |
Kilobits |
|
|
399 |
|
|
|
400 |
|
|
|
401 |
b or a bare number |
|
|
402 |
|
|
|
403 |
|
|
|
404 |
Bytes. |
|
|
405 |
|
|
|
406 |
|
|
|
407 |
Lengths of time can be specified in: |
|
|
408 |
|
|
|
409 |
|
|
|
410 |
s, sec or secs |
|
|
411 |
|
|
|
412 |
|
|
|
413 |
Whole seconds |
|
|
414 |
|
|
|
415 |
|
|
|
416 |
ms, msec or msecs |
|
|
417 |
|
|
|
418 |
|
|
|
419 |
Milliseconds |
|
|
420 |
|
|
|
421 |
|
|
|
422 |
us, usec, usecs or a bare number |
|
|
423 |
|
|
|
424 |
|
|
|
425 |
Microseconds. |
|
|
426 |
!!TC COMMANDS |
|
|
427 |
|
|
|
428 |
|
|
|
429 |
The following commands are available for qdiscs, classes and |
|
|
430 |
filter: |
|
|
431 |
|
|
|
432 |
|
|
|
433 |
add |
|
|
434 |
|
|
|
435 |
|
|
|
436 |
Add a qdisc, class or filter to a node. For all entities, a |
|
|
437 |
__parent__ must be passed, either by passing its ID or by |
|
|
438 |
attaching directly to the root of a device. When creating a |
|
|
439 |
qdisc or a filter, it can be named with the __handle__ |
|
|
440 |
parameter. A class is named with the __classid__ |
|
|
441 |
parameter. |
|
|
442 |
|
|
|
443 |
|
|
|
444 |
remove |
|
|
445 |
|
|
|
446 |
|
|
|
447 |
A qdisc can be removed by specifying its handle, which may |
|
|
448 |
also be 'root'. All subclasses and their leaf qdiscs are |
|
|
449 |
automatically deleted, as well as any filters attached to |
|
|
450 |
them. |
|
|
451 |
|
|
|
452 |
|
|
|
453 |
change |
|
|
454 |
|
|
|
455 |
|
|
|
456 |
Some entities can be modified 'in place'. Shares the syntax |
|
|
457 |
of 'add', with the exception that the handle cannot be |
|
|
458 |
changed and neither can the parent. In other words, |
|
|
459 |
__change__ cannot move a node. |
|
|
460 |
|
|
|
461 |
|
|
|
462 |
replace |
|
|
463 |
|
|
|
464 |
|
|
|
465 |
Performs a nearly atomic remove/add on an existing node id. |
|
|
466 |
If the node does not exist yet it is created. |
|
|
467 |
|
|
|
468 |
|
|
|
469 |
link |
|
|
470 |
|
|
|
471 |
|
|
|
472 |
Only available for qdiscs and performs a replace where the |
|
|
473 |
node must exist already. |
|
|
474 |
!!HISTORY |
|
|
475 |
|
|
|
476 |
|
|
|
477 |
__tc__ was written by Alexey N. Kuznetsov and added in |
|
|
478 |
Linux 2.2. |
|
|
479 |
!!SEE ALSO |
|
|
480 |
|
|
|
481 |
|
|
|
482 |
tc-cbq(8), tc-htb(8), tc-sfq(8), |
|
|
483 |
tc-red(8), tc-tbf(8), tc-pfifo(8), |
|
|
484 |
tc-bfifo(8), tc-pfifo_fast(8), |
|
|
485 |
tc-filters(8) |
|
|
486 |
!!AUTHOR |
|
|
487 |
|
|
|
488 |
|
|
|
489 |
Manpage maintained by bert hubert (ahu@ds9a.nl) |
|
|
490 |
---- |