]> git.proxmox.com Git - mirror_iproute2.git/blob - man/man8/tc.8
Merge branch 'net-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shemminger...
[mirror_iproute2.git] / man / man8 / tc.8
1 .TH TC 8 "16 December 2001" "iproute2" "Linux"
2 .SH NAME
3 tc \- show / manipulate traffic control settings
4 .SH SYNOPSIS
5 .B tc
6 .RI "[ " OPTIONS " ]"
7 .B qdisc [ add | change | replace | link | delete ] dev
8 DEV
9 .B
10 [ parent
11 qdisc-id
12 .B | root ]
13 .B [ handle
14 qdisc-id ] qdisc
15 [ qdisc specific parameters ]
16 .P
17
18 .B tc
19 .RI "[ " OPTIONS " ]"
20 .B class [ add | change | replace | delete ] dev
21 DEV
22 .B parent
23 qdisc-id
24 .B [ classid
25 class-id ] qdisc
26 [ qdisc specific parameters ]
27 .P
28
29 .B tc
30 .RI "[ " OPTIONS " ]"
31 .B filter [ add | change | replace | delete ] dev
32 DEV
33 .B [ parent
34 qdisc-id
35 .B | root ] protocol
36 protocol
37 .B prio
38 priority filtertype
39 [ filtertype specific parameters ]
40 .B flowid
41 flow-id
42
43 .B tc
44 .RI "[ " OPTIONS " ]"
45 .RI "[ " FORMAT " ]"
46 .B qdisc show [ dev
47 DEV
48 .B ]
49 .P
50 .B tc
51 .RI "[ " OPTIONS " ]"
52 .RI "[ " FORMAT " ]"
53 .B class show dev
54 DEV
55 .P
56 .B tc
57 .RI "[ " OPTIONS " ]"
58 .B filter show dev
59 DEV
60
61 .P
62 .ti 8
63 .IR OPTIONS " := {"
64 \fB[ -force ] -b\fR[\fIatch\fR] \fB[ filename ] \fR|
65 \fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR|
66 \fB[ \fB-nm \fR| \fB-nam\fR[\fIes\fR] \fB] \fR|
67 \fB[ \fR{ \fB-cf \fR| \fB-c\fR[\fIonf\fR] \fR} \fB[ filename ] \fB] \fR}
68
69 .ti 8
70 .IR FORMAT " := {"
71 \fB\-s\fR[\fItatistics\fR] |
72 \fB\-d\fR[\fIetails\fR] |
73 \fB\-r\fR[\fIaw\fR] |
74 \fB\-p\fR[\fIretty\fR] |
75 \fB\-i\fR[\fIec\fR] |
76 \fB\-g\fR[\fIraph\fR] }
77
78 .SH DESCRIPTION
79 .B Tc
80 is used to configure Traffic Control in the Linux kernel. Traffic Control consists
81 of the following:
82
83 .TP
84 SHAPING
85 When traffic is shaped, its rate of transmission is under control. Shaping may
86 be more than lowering the available bandwidth - it is also used to smooth out
87 bursts in traffic for better network behaviour. Shaping occurs on egress.
88
89 .TP
90 SCHEDULING
91 By scheduling the transmission of packets it is possible to improve interactivity
92 for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering
93 is also called prioritizing, and happens only on egress.
94
95 .TP
96 POLICING
97 Whereas shaping deals with transmission of traffic, policing pertains to traffic
98 arriving. Policing thus occurs on ingress.
99
100 .TP
101 DROPPING
102 Traffic exceeding a set bandwidth may also be dropped forthwith, both on
103 ingress and on egress.
104
105 .P
106 Processing of traffic is controlled by three kinds of objects: qdiscs,
107 classes and filters.
108
109 .SH QDISCS
110 .B qdisc
111 is short for 'queueing discipline' and it is elementary to
112 understanding traffic control. Whenever the kernel needs to send a
113 packet to an interface, it is
114 .B enqueued
115 to the qdisc configured for that interface. Immediately afterwards, the kernel
116 tries to get as many packets as possible from the qdisc, for giving them
117 to the network adaptor driver.
118
119 A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure
120 First In, First Out queue. It does however store traffic when the network interface
121 can't handle it momentarily.
122
123 .SH CLASSES
124 Some qdiscs can contain classes, which contain further qdiscs - traffic may
125 then be enqueued in any of the inner qdiscs, which are within the
126 .B classes.
127 When the kernel tries to dequeue a packet from such a
128 .B classful qdisc
129 it can come from any of the classes. A qdisc may for example prioritize
130 certain kinds of traffic by trying to dequeue from certain classes
131 before others.
132
133 .SH FILTERS
134 A
135 .B filter
136 is used by a classful qdisc to determine in which class a packet will
137 be enqueued. Whenever traffic arrives at a class with subclasses, it needs
138 to be classified. Various methods may be employed to do so, one of these
139 are the filters. All filters attached to the class are called, until one of
140 them returns with a verdict. If no verdict was made, other criteria may be
141 available. This differs per qdisc.
142
143 It is important to notice that filters reside
144 .B within
145 qdiscs - they are not masters of what happens.
146
147 .SH CLASSLESS QDISCS
148 The classless qdiscs are:
149 .TP
150 [p|b]fifo
151 Simplest usable qdisc, pure First In, First Out behaviour. Limited in
152 packets or in bytes.
153 .TP
154 pfifo_fast
155 Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
156 queue which honors Type of Service flags, as well as the priority that may be
157 assigned to a packet.
158 .TP
159 red
160 Random Early Detection simulates physical congestion by randomly dropping
161 packets when nearing configured bandwidth allocation. Well suited to very
162 large bandwidth applications.
163 .TP
164 sfq
165 Stochastic Fairness Queueing reorders queued traffic so each 'session'
166 gets to send a packet in turn.
167 .TP
168 tbf
169 The Token Bucket Filter is suited for slowing traffic down to a precisely
170 configured rate. Scales well to large bandwidths.
171 .SH CONFIGURING CLASSLESS QDISCS
172 In the absence of classful qdiscs, classless qdiscs can only be attached at
173 the root of a device. Full syntax:
174 .P
175 .B tc qdisc add dev
176 DEV
177 .B root
178 QDISC QDISC-PARAMETERS
179
180 To remove, issue
181 .P
182 .B tc qdisc del dev
183 DEV
184 .B root
185
186 The
187 .B pfifo_fast
188 qdisc is the automatic default in the absence of a configured qdisc.
189
190 .SH CLASSFUL QDISCS
191 The classful qdiscs are:
192 .TP
193 CBQ
194 Class Based Queueing implements a rich linksharing hierarchy of classes.
195 It contains shaping elements as well as prioritizing capabilities. Shaping is
196 performed using link idle time calculations based on average packet size and
197 underlying link bandwidth. The latter may be ill-defined for some interfaces.
198 .TP
199 HTB
200 The Hierarchy Token Bucket implements a rich linksharing hierarchy of
201 classes with an emphasis on conforming to existing practices. HTB facilitates
202 guaranteeing bandwidth to classes, while also allowing specification of upper
203 limits to inter-class sharing. It contains shaping elements, based on TBF and
204 can prioritize classes.
205 .TP
206 PRIO
207 The PRIO qdisc is a non-shaping container for a configurable number of
208 classes which are dequeued in order. This allows for easy prioritization
209 of traffic, where lower classes are only able to send if higher ones have
210 no packets available. To facilitate configuration, Type Of Service bits are
211 honored by default.
212 .SH THEORY OF OPERATION
213 Classes form a tree, where each class has a single parent.
214 A class may have multiple children. Some qdiscs allow for runtime addition
215 of classes (CBQ, HTB) while others (PRIO) are created with a static number of
216 children.
217
218 Qdiscs which allow dynamic addition of classes can have zero or more
219 subclasses to which traffic may be enqueued.
220
221 Furthermore, each class contains a
222 .B leaf qdisc
223 which by default has
224 .B pfifo
225 behaviour, although another qdisc can be attached in place. This qdisc may again
226 contain classes, but each class can have only one leaf qdisc.
227
228 When a packet enters a classful qdisc it can be
229 .B classified
230 to one of the classes within. Three criteria are available, although not all
231 qdiscs will use all three:
232 .TP
233 tc filters
234 If tc filters are attached to a class, they are consulted first
235 for relevant instructions. Filters can match on all fields of a packet header,
236 as well as on the firewall mark applied by ipchains or iptables.
237 .TP
238 Type of Service
239 Some qdiscs have built in rules for classifying packets based on the TOS field.
240 .TP
241 skb->priority
242 Userspace programs can encode a class-id in the 'skb->priority' field using
243 the SO_PRIORITY option.
244 .P
245 Each node within the tree can have its own filters but higher level filters
246 may also point directly to lower classes.
247
248 If classification did not succeed, packets are enqueued to the leaf qdisc
249 attached to that class. Check qdisc specific manpages for details, however.
250
251 .SH NAMING
252 All qdiscs, classes and filters have IDs, which can either be specified
253 or be automatically assigned.
254
255 IDs consist of a
256 .BR major " number and a " minor
257 number, separated by a colon -
258 .BR major ":" minor "."
259 Both
260 .BR major " and " minor
261 are hexadecimal numbers and are limited to 16 bits. There are two special
262 values: root is signified by
263 .BR major " and " minor
264 of all ones, and unspecified is all zeros.
265
266 .TP
267 QDISCS
268 A qdisc, which potentially can have children, gets assigned a
269 .B major
270 number, called a 'handle', leaving the
271 .B minor
272 number namespace available for classes. The handle is expressed as '10:'.
273 It is customary to explicitly assign a handle to qdiscs expected to have children.
274
275 .TP
276 CLASSES
277 Classes residing under a qdisc share their qdisc
278 .B major
279 number, but each have a separate
280 .B minor
281 number called a 'classid' that has no relation to their
282 parent classes, only to their parent qdisc. The same naming custom as for
283 qdiscs applies.
284
285 .TP
286 FILTERS
287 Filters have a three part ID, which is only needed when using a hashed
288 filter hierarchy.
289
290 .SH PARAMETERS
291 The following parameters are widely used in TC. For other parameters,
292 see the man pages for individual qdiscs.
293
294 .TP
295 RATES
296 Bandwidths or rates.
297 These parameters accept a floating point number, possibly followed by
298 a unit (both SI and IEC units supported).
299 .RS
300 .TP
301 bit or a bare number
302 Bits per second
303 .TP
304 kbit
305 Kilobits per second
306 .TP
307 mbit
308 Megabits per second
309 .TP
310 gbit
311 Gigabits per second
312 .TP
313 tbit
314 Terabits per second
315 .TP
316 bps
317 Bytes per second
318 .TP
319 kbps
320 Kilobytes per second
321 .TP
322 mbps
323 Megabytes per second
324 .TP
325 gbps
326 Gigabytes per second
327 .TP
328 tbps
329 Terabytes per second
330
331 .P
332 To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with
333 IEC prefix (ki-, mi-, gi- and ti-) respectively.
334
335 .P
336 TC store rates as a 32-bit unsigned integer in bps internally,
337 so we can specify a max rate of 4294967295 bps.
338 .RE
339
340 .TP
341 TIMES
342 Length of time. Can be specified as a floating point number
343 followed by an optional unit:
344 .RS
345 .TP
346 s, sec or secs
347 Whole seconds
348 .TP
349 ms, msec or msecs
350 Milliseconds
351 .TP
352 us, usec, usecs or a bare number
353 Microseconds.
354
355 .P
356 TC defined its own time unit (equal to microsecond) and stores
357 time values as 32-bit unsigned integer, thus we can specify a max time value
358 of 4294967295 usecs.
359 .RE
360
361 .TP
362 SIZES
363 Amounts of data. Can be specified as a floating point number
364 followed by an optional unit:
365 .RS
366 .TP
367 b or a bare number
368 Bytes.
369 .TP
370 kbit
371 Kilobits
372 .TP
373 kb or k
374 Kilobytes
375 .TP
376 mbit
377 Megabits
378 .TP
379 mb or m
380 Megabytes
381 .TP
382 gbit
383 Gigabits
384 .TP
385 gb or g
386 Gigabytes
387
388 .P
389 TC stores sizes internally as 32-bit unsigned integer in byte,
390 so we can specify a max size of 4294967295 bytes.
391 .RE
392
393 .TP
394 VALUES
395 Other values without a unit.
396 These parameters are interpreted as decimal by default, but you can
397 indicate TC to interpret them as octal and hexadecimal by adding a '0'
398 or '0x' prefix respectively.
399
400 .SH TC COMMANDS
401 The following commands are available for qdiscs, classes and filter:
402 .TP
403 add
404 Add a qdisc, class or filter to a node. For all entities, a
405 .B parent
406 must be passed, either by passing its ID or by attaching directly to the root of a device.
407 When creating a qdisc or a filter, it can be named with the
408 .B handle
409 parameter. A class is named with the
410 .B classid
411 parameter.
412
413 .TP
414 delete
415 A qdisc can be deleted by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs
416 are automatically deleted, as well as any filters attached to them.
417
418 .TP
419 change
420 Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
421 that the handle cannot be changed and neither can the parent. In other words,
422 .B
423 change
424 cannot move a node.
425
426 .TP
427 replace
428 Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
429 it is created.
430
431 .TP
432 link
433 Only available for qdiscs and performs a replace where the node
434 must exist already.
435
436 .SH OPTIONS
437
438 .TP
439 .BR "\-b", " \-b filename", " \-batch", " \-batch filename"
440 read commands from provided file or standard input and invoke them.
441 First failure will cause termination of tc.
442
443 .TP
444 .BR "\-force"
445 don't terminate tc on errors in batch mode.
446 If there were any errors during execution of the commands, the application return code will be non zero.
447
448 .TP
449 .BR "\-n" , " \-net" , " \-netns " <NETNS>
450 switches
451 .B tc
452 to the specified network namespace
453 .IR NETNS .
454 Actually it just simplifies executing of:
455
456 .B ip netns exec
457 .IR NETNS
458 .B tc
459 .RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
460 .BR help " }"
461
462 to
463
464 .B tc
465 .RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
466 .BR help " }"
467
468 .TP
469 .BR "\-cf" , " \-conf " <FILENAME>
470 specifies path to the config file. This option is used in conjuction with other options (e.g.
471 .BR -nm ")."
472
473 .SH FORMAT
474 The show command has additional formatting options:
475
476 .TP
477 .BR "\-s" , " \-stats", " \-statistics"
478 output more statistics about packet usage.
479
480 .TP
481 .BR "\-d", " \-details"
482 output more detailed information about rates and cell sizes.
483
484 .TP
485 .BR "\-r", " \-raw"
486 output raw hex values for handles.
487
488 .TP
489 .BR "\-p", " \-pretty"
490 decode filter offset and mask values to equivalent filter commands based on TCP/IP.
491
492 .TP
493 .BR "\-iec"
494 print rates in IEC units (ie. 1K = 1024).
495
496 .TP
497 .BR "\-g", " \-graph"
498 shows classes as ASCII graph. Prints generic stats info under each class if
499 .BR "-s"
500 option was specified. Classes can be filtered only by
501 .BR "dev"
502 option.
503
504 .TP
505 .BR "\-nm" , " \-name"
506 resolve class name from
507 .B /etc/iproute2/tc_cls
508 file or from file specified by
509 .B -cf
510 option. This file is just a mapping of
511 .B classid
512 to class name:
513
514 .RS 10
515 # Here is comment
516 .RE
517 .RS 10
518 1:40 voip # Here is another comment
519 .RE
520 .RS 10
521 1:50 web
522 .RE
523 .RS 10
524 1:60 ftp
525 .RE
526 .RS 10
527 1:2 home
528 .RE
529
530 .RS
531 .B tc
532 will not fail if
533 .B -nm
534 was specified without
535 .B -cf
536 option but
537 .B /etc/iproute2/tc_cls
538 file does not exist, which makes it possible to pass
539 .B -nm
540 option for creating
541 .B tc
542 alias.
543 .RE
544
545 .SH "EXAMPLES"
546 .PP
547 tc -g class show dev eth0
548 .RS 4
549 Shows classes as ASCII graph on eth0 interface.
550 .RE
551 .PP
552 tc -g -s class show dev eth0
553 .RS 4
554 Shows classes as ASCII graph with stats info under each class.
555
556 .SH HISTORY
557 .B tc
558 was written by Alexey N. Kuznetsov and added in Linux 2.2.
559 .SH SEE ALSO
560 .BR tc-bfifo (8),
561 .BR tc-cbq (8),
562 .BR tc-choke (8),
563 .BR tc-codel (8),
564 .BR tc-drr (8),
565 .BR tc-ematch (8),
566 .BR tc-fq_codel (8),
567 .BR tc-hfsc (7),
568 .BR tc-hfsc (8),
569 .BR tc-htb (8),
570 .BR tc-mqprio (8),
571 .BR tc-pfifo (8),
572 .BR tc-pfifo_fast (8),
573 .BR tc-red (8),
574 .BR tc-sfb (8),
575 .BR tc-sfq (8),
576 .BR tc-stab (8),
577 .BR tc-tbf (8),
578 .br
579 .RB "User documentation at " http://lartc.org/ ", but please direct bugreports and patches to: " <netdev@vger.kernel.org>
580
581 .SH AUTHOR
582 Manpage maintained by bert hubert (ahu@ds9a.nl)
583