]> git.proxmox.com Git - mirror_iproute2.git/blob - man/man8/tc.8
tc: man: Add man entry for the matchall classifier.
[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 The available filters are:
148 .TP
149 basic
150 Filter packets based on an ematch expression. See
151 .BR tc-ematch (8)
152 for details.
153 .TP
154 bpf
155 Filter packets using (e)BPF, see
156 .BR tc-bpf (8)
157 for details.
158 .TP
159 cgroup
160 Filter packets based on the control group of their process. See
161 . BR tc-cgroup (8)
162 for details.
163 .TP
164 flow, flower
165 Flow-based classifiers, filtering packets based on their flow (identified by selectable keys). See
166 .BR tc-flow "(8) and"
167 .BR tc-flower (8)
168 for details.
169 .TP
170 fw
171 Filter based on fwmark. Directly maps fwmark value to traffic class. See
172 .BR tc-fw (8).
173 .TP
174 route
175 Filter packets based on routing table. See
176 .BR tc-route (8)
177 for details.
178 .TP
179 rsvp
180 Match Resource Reservation Protocol (RSVP) packets.
181 .TP
182 tcindex
183 Filter packets based on traffic control index. See
184 .BR tc-tcindex (8).
185 .TP
186 u32
187 Generic filtering on arbitrary packet data, assisted by syntax to abstract common operations. See
188 .BR tc-u32 (8)
189 for details.
190 .TP
191 matchall
192 Traffic control filter that matches every packet. See
193 .BR tc-matchall (8)
194 for details.
195
196 .SH CLASSLESS QDISCS
197 The classless qdiscs are:
198 .TP
199 choke
200 CHOKe (CHOose and Keep for responsive flows, CHOose and Kill for unresponsive
201 flows) is a classless qdisc designed to both identify and penalize flows that
202 monopolize the queue. CHOKe is a variation of RED, and the configuration is
203 similar to RED.
204 .TP
205 codel
206 CoDel (pronounced "coddle") is an adaptive "no-knobs" active queue management
207 algorithm (AQM) scheme that was developed to address the shortcomings of
208 RED and its variants.
209 .TP
210 [p|b]fifo
211 Simplest usable qdisc, pure First In, First Out behaviour. Limited in
212 packets or in bytes.
213 .TP
214 fq
215 Fair Queue Scheduler realises TCP pacing and scales to millions of concurrent
216 flows per qdisc.
217 .TP
218 fq_codel
219 Fair Queuing Controlled Delay is queuing discipline that combines Fair
220 Queuing with the CoDel AQM scheme. FQ_Codel uses a stochastic model to classify
221 incoming packets into different flows and is used to provide a fair share of the
222 bandwidth to all the flows using the queue. Each such flow is managed by the
223 CoDel queuing discipline. Reordering within a flow is avoided since Codel
224 internally uses a FIFO queue.
225 .TP
226 gred
227 Generalized Random Early Detection combines multiple RED queues in order to
228 achieve multiple drop priorities. This is required to realize Assured
229 Forwarding (RFC 2597).
230 .TP
231 hhf
232 Heavy-Hitter Filter differentiates between small flows and the opposite,
233 heavy-hitters. The goal is to catch the heavy-hitters and move them to a
234 separate queue with less priority so that bulk traffic does not affect the
235 latency of critical traffic.
236 .TP
237 ingress
238 This is a special qdisc as it applies to incoming traffic on an interface, allowing for it to be filtered and policed.
239 .TP
240 mqprio
241 The Multiqueue Priority Qdisc is a simple queuing discipline that allows
242 mapping traffic flows to hardware queue ranges using priorities and a
243 configurable priority to traffic class mapping. A traffic class in this context
244 is a set of contiguous qdisc classes which map 1:1 to a set of hardware exposed
245 queues.
246 .TP
247 multiq
248 Multiqueue is a qdisc optimized for devices with multiple Tx queues. It has
249 been added for hardware that wishes to avoid head-of-line blocking. It will
250 cycle though the bands and verify that the hardware queue associated with the
251 band is not stopped prior to dequeuing a packet.
252 .TP
253 netem
254 Network Emulator is an enhancement of the Linux traffic control facilities that
255 allow to add delay, packet loss, duplication and more other characteristics to
256 packets outgoing from a selected network interface.
257 .TP
258 pfifo_fast
259 Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
260 queue which honors Type of Service flags, as well as the priority that may be
261 assigned to a packet.
262 .TP
263 pie
264 Proportional Integral controller-Enhanced (PIE) is a control theoretic active
265 queue management scheme. It is based on the proportional integral controller but
266 aims to control delay.
267 .TP
268 red
269 Random Early Detection simulates physical congestion by randomly dropping
270 packets when nearing configured bandwidth allocation. Well suited to very
271 large bandwidth applications.
272 .TP
273 rr
274 Round-Robin qdisc with support for multiqueue network devices. Removed from
275 Linux since kernel version 2.6.27.
276 .TP
277 sfb
278 Stochastic Fair Blue is a classless qdisc to manage congestion based on
279 packet loss and link utilization history while trying to prevent
280 non-responsive flows (i.e. flows that do not react to congestion marking
281 or dropped packets) from impacting performance of responsive flows.
282 Unlike RED, where the marking probability has to be configured, BLUE
283 tries to determine the ideal marking probability automatically.
284 .TP
285 sfq
286 Stochastic Fairness Queueing reorders queued traffic so each 'session'
287 gets to send a packet in turn.
288 .TP
289 tbf
290 The Token Bucket Filter is suited for slowing traffic down to a precisely
291 configured rate. Scales well to large bandwidths.
292 .SH CONFIGURING CLASSLESS QDISCS
293 In the absence of classful qdiscs, classless qdiscs can only be attached at
294 the root of a device. Full syntax:
295 .P
296 .B tc qdisc add dev
297 DEV
298 .B root
299 QDISC QDISC-PARAMETERS
300
301 To remove, issue
302 .P
303 .B tc qdisc del dev
304 DEV
305 .B root
306
307 The
308 .B pfifo_fast
309 qdisc is the automatic default in the absence of a configured qdisc.
310
311 .SH CLASSFUL QDISCS
312 The classful qdiscs are:
313 .TP
314 ATM
315 Map flows to virtual circuits of an underlying asynchronous transfer mode
316 device.
317 .TP
318 CBQ
319 Class Based Queueing implements a rich linksharing hierarchy of classes.
320 It contains shaping elements as well as prioritizing capabilities. Shaping is
321 performed using link idle time calculations based on average packet size and
322 underlying link bandwidth. The latter may be ill-defined for some interfaces.
323 .TP
324 DRR
325 The Deficit Round Robin Scheduler is a more flexible replacement for Stochastic
326 Fairness Queuing. Unlike SFQ, there are no built-in queues \-\- you need to add
327 classes and then set up filters to classify packets accordingly. This can be
328 useful e.g. for using RED qdiscs with different settings for particular
329 traffic. There is no default class \-\- if a packet cannot be classified, it is
330 dropped.
331 .TP
332 DSMARK
333 Classify packets based on TOS field, change TOS field of packets based on
334 classification.
335 .TP
336 HFSC
337 Hierarchical Fair Service Curve guarantees precise bandwidth and delay allocation for leaf classes and allocates excess bandwidth fairly. Unlike HTB, it makes use of packet dropping to achieve low delays which interactive sessions benefit from.
338 .TP
339 HTB
340 The Hierarchy Token Bucket implements a rich linksharing hierarchy of
341 classes with an emphasis on conforming to existing practices. HTB facilitates
342 guaranteeing bandwidth to classes, while also allowing specification of upper
343 limits to inter-class sharing. It contains shaping elements, based on TBF and
344 can prioritize classes.
345 .TP
346 PRIO
347 The PRIO qdisc is a non-shaping container for a configurable number of
348 classes which are dequeued in order. This allows for easy prioritization
349 of traffic, where lower classes are only able to send if higher ones have
350 no packets available. To facilitate configuration, Type Of Service bits are
351 honored by default.
352 .TP
353 QFQ
354 Quick Fair Queueing is an O(1) scheduler that provides near-optimal guarantees,
355 and is the first to achieve that goal with a constant cost also with respect to
356 the number of groups and the packet length. The QFQ algorithm has no loops, and
357 uses very simple instructions and data structures that lend themselves very
358 well to a hardware implementation.
359 .SH THEORY OF OPERATION
360 Classes form a tree, where each class has a single parent.
361 A class may have multiple children. Some qdiscs allow for runtime addition
362 of classes (CBQ, HTB) while others (PRIO) are created with a static number of
363 children.
364
365 Qdiscs which allow dynamic addition of classes can have zero or more
366 subclasses to which traffic may be enqueued.
367
368 Furthermore, each class contains a
369 .B leaf qdisc
370 which by default has
371 .B pfifo
372 behaviour, although another qdisc can be attached in place. This qdisc may again
373 contain classes, but each class can have only one leaf qdisc.
374
375 When a packet enters a classful qdisc it can be
376 .B classified
377 to one of the classes within. Three criteria are available, although not all
378 qdiscs will use all three:
379 .TP
380 tc filters
381 If tc filters are attached to a class, they are consulted first
382 for relevant instructions. Filters can match on all fields of a packet header,
383 as well as on the firewall mark applied by ipchains or iptables.
384 .TP
385 Type of Service
386 Some qdiscs have built in rules for classifying packets based on the TOS field.
387 .TP
388 skb->priority
389 Userspace programs can encode a class-id in the 'skb->priority' field using
390 the SO_PRIORITY option.
391 .P
392 Each node within the tree can have its own filters but higher level filters
393 may also point directly to lower classes.
394
395 If classification did not succeed, packets are enqueued to the leaf qdisc
396 attached to that class. Check qdisc specific manpages for details, however.
397
398 .SH NAMING
399 All qdiscs, classes and filters have IDs, which can either be specified
400 or be automatically assigned.
401
402 IDs consist of a
403 .BR major " number and a " minor
404 number, separated by a colon -
405 .BR major ":" minor "."
406 Both
407 .BR major " and " minor
408 are hexadecimal numbers and are limited to 16 bits. There are two special
409 values: root is signified by
410 .BR major " and " minor
411 of all ones, and unspecified is all zeros.
412
413 .TP
414 QDISCS
415 A qdisc, which potentially can have children, gets assigned a
416 .B major
417 number, called a 'handle', leaving the
418 .B minor
419 number namespace available for classes. The handle is expressed as '10:'.
420 It is customary to explicitly assign a handle to qdiscs expected to have children.
421
422 .TP
423 CLASSES
424 Classes residing under a qdisc share their qdisc
425 .B major
426 number, but each have a separate
427 .B minor
428 number called a 'classid' that has no relation to their
429 parent classes, only to their parent qdisc. The same naming custom as for
430 qdiscs applies.
431
432 .TP
433 FILTERS
434 Filters have a three part ID, which is only needed when using a hashed
435 filter hierarchy.
436
437 .SH PARAMETERS
438 The following parameters are widely used in TC. For other parameters,
439 see the man pages for individual qdiscs.
440
441 .TP
442 RATES
443 Bandwidths or rates.
444 These parameters accept a floating point number, possibly followed by
445 a unit (both SI and IEC units supported).
446 .RS
447 .TP
448 bit or a bare number
449 Bits per second
450 .TP
451 kbit
452 Kilobits per second
453 .TP
454 mbit
455 Megabits per second
456 .TP
457 gbit
458 Gigabits per second
459 .TP
460 tbit
461 Terabits per second
462 .TP
463 bps
464 Bytes per second
465 .TP
466 kbps
467 Kilobytes per second
468 .TP
469 mbps
470 Megabytes per second
471 .TP
472 gbps
473 Gigabytes per second
474 .TP
475 tbps
476 Terabytes per second
477
478 .P
479 To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with
480 IEC prefix (ki-, mi-, gi- and ti-) respectively.
481
482 .P
483 TC store rates as a 32-bit unsigned integer in bps internally,
484 so we can specify a max rate of 4294967295 bps.
485 .RE
486
487 .TP
488 TIMES
489 Length of time. Can be specified as a floating point number
490 followed by an optional unit:
491 .RS
492 .TP
493 s, sec or secs
494 Whole seconds
495 .TP
496 ms, msec or msecs
497 Milliseconds
498 .TP
499 us, usec, usecs or a bare number
500 Microseconds.
501
502 .P
503 TC defined its own time unit (equal to microsecond) and stores
504 time values as 32-bit unsigned integer, thus we can specify a max time value
505 of 4294967295 usecs.
506 .RE
507
508 .TP
509 SIZES
510 Amounts of data. Can be specified as a floating point number
511 followed by an optional unit:
512 .RS
513 .TP
514 b or a bare number
515 Bytes.
516 .TP
517 kbit
518 Kilobits
519 .TP
520 kb or k
521 Kilobytes
522 .TP
523 mbit
524 Megabits
525 .TP
526 mb or m
527 Megabytes
528 .TP
529 gbit
530 Gigabits
531 .TP
532 gb or g
533 Gigabytes
534
535 .P
536 TC stores sizes internally as 32-bit unsigned integer in byte,
537 so we can specify a max size of 4294967295 bytes.
538 .RE
539
540 .TP
541 VALUES
542 Other values without a unit.
543 These parameters are interpreted as decimal by default, but you can
544 indicate TC to interpret them as octal and hexadecimal by adding a '0'
545 or '0x' prefix respectively.
546
547 .SH TC COMMANDS
548 The following commands are available for qdiscs, classes and filter:
549 .TP
550 add
551 Add a qdisc, class or filter to a node. For all entities, a
552 .B parent
553 must be passed, either by passing its ID or by attaching directly to the root of a device.
554 When creating a qdisc or a filter, it can be named with the
555 .B handle
556 parameter. A class is named with the
557 .B classid
558 parameter.
559
560 .TP
561 delete
562 A qdisc can be deleted by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs
563 are automatically deleted, as well as any filters attached to them.
564
565 .TP
566 change
567 Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
568 that the handle cannot be changed and neither can the parent. In other words,
569 .B
570 change
571 cannot move a node.
572
573 .TP
574 replace
575 Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
576 it is created.
577
578 .TP
579 link
580 Only available for qdiscs and performs a replace where the node
581 must exist already.
582
583 .SH OPTIONS
584
585 .TP
586 .BR "\-b", " \-b filename", " \-batch", " \-batch filename"
587 read commands from provided file or standard input and invoke them.
588 First failure will cause termination of tc.
589
590 .TP
591 .BR "\-force"
592 don't terminate tc on errors in batch mode.
593 If there were any errors during execution of the commands, the application return code will be non zero.
594
595 .TP
596 .BR "\-n" , " \-net" , " \-netns " <NETNS>
597 switches
598 .B tc
599 to the specified network namespace
600 .IR NETNS .
601 Actually it just simplifies executing of:
602
603 .B ip netns exec
604 .IR NETNS
605 .B tc
606 .RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
607 .BR help " }"
608
609 to
610
611 .B tc
612 .RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
613 .BR help " }"
614
615 .TP
616 .BR "\-cf" , " \-conf " <FILENAME>
617 specifies path to the config file. This option is used in conjunction with other options (e.g.
618 .BR -nm ")."
619
620 .SH FORMAT
621 The show command has additional formatting options:
622
623 .TP
624 .BR "\-s" , " \-stats", " \-statistics"
625 output more statistics about packet usage.
626
627 .TP
628 .BR "\-d", " \-details"
629 output more detailed information about rates and cell sizes.
630
631 .TP
632 .BR "\-r", " \-raw"
633 output raw hex values for handles.
634
635 .TP
636 .BR "\-p", " \-pretty"
637 decode filter offset and mask values to equivalent filter commands based on TCP/IP.
638
639 .TP
640 .BR "\-iec"
641 print rates in IEC units (ie. 1K = 1024).
642
643 .TP
644 .BR "\-g", " \-graph"
645 shows classes as ASCII graph. Prints generic stats info under each class if
646 .BR "-s"
647 option was specified. Classes can be filtered only by
648 .BR "dev"
649 option.
650
651 .TP
652 .BR "\-nm" , " \-name"
653 resolve class name from
654 .B /etc/iproute2/tc_cls
655 file or from file specified by
656 .B -cf
657 option. This file is just a mapping of
658 .B classid
659 to class name:
660
661 .RS 10
662 # Here is comment
663 .RE
664 .RS 10
665 1:40 voip # Here is another comment
666 .RE
667 .RS 10
668 1:50 web
669 .RE
670 .RS 10
671 1:60 ftp
672 .RE
673 .RS 10
674 1:2 home
675 .RE
676
677 .RS
678 .B tc
679 will not fail if
680 .B -nm
681 was specified without
682 .B -cf
683 option but
684 .B /etc/iproute2/tc_cls
685 file does not exist, which makes it possible to pass
686 .B -nm
687 option for creating
688 .B tc
689 alias.
690 .RE
691
692 .SH "EXAMPLES"
693 .PP
694 tc -g class show dev eth0
695 .RS 4
696 Shows classes as ASCII graph on eth0 interface.
697 .RE
698 .PP
699 tc -g -s class show dev eth0
700 .RS 4
701 Shows classes as ASCII graph with stats info under each class.
702
703 .SH HISTORY
704 .B tc
705 was written by Alexey N. Kuznetsov and added in Linux 2.2.
706 .SH SEE ALSO
707 .BR tc-basic (8),
708 .BR tc-bfifo (8),
709 .BR tc-bpf (8),
710 .BR tc-cbq (8),
711 .BR tc-cgroup (8),
712 .BR tc-choke (8),
713 .BR tc-codel (8),
714 .BR tc-drr (8),
715 .BR tc-ematch (8),
716 .BR tc-flow (8),
717 .BR tc-flower (8),
718 .BR tc-fq (8),
719 .BR tc-fq_codel (8),
720 .BR tc-fw (8),
721 .BR tc-hfsc (7),
722 .BR tc-hfsc (8),
723 .BR tc-htb (8),
724 .BR tc-mqprio (8),
725 .BR tc-pfifo (8),
726 .BR tc-pfifo_fast (8),
727 .BR tc-red (8),
728 .BR tc-route (8),
729 .BR tc-sfb (8),
730 .BR tc-sfq (8),
731 .BR tc-stab (8),
732 .BR tc-tbf (8),
733 .BR tc-tcindex (8),
734 .BR tc-u32 (8),
735 .br
736 .RB "User documentation at " http://lartc.org/ ", but please direct bugreports and patches to: " <netdev@vger.kernel.org>
737
738 .SH AUTHOR
739 Manpage maintained by bert hubert (ahu@ds9a.nl)