1 .TH TC 8 "16 December 2001" "iproute2" "Linux"
3 tc \- show / manipulate traffic control settings
7 .B qdisc [ add | change | replace | link | delete ] dev
14 \fIqdisc-id\fR ] qdisc
15 [ qdisc specific parameters ]
20 .B class [ add | change | replace | delete ] dev
25 \fIclass-id\fR ] qdisc
26 [ qdisc specific parameters ]
31 .B filter [ add | change | replace | delete | get ] dev
35 .B | root ] [ handle \fIfilter-id\fR ]
39 \fIpriority\fR filtertype
40 [ filtertype specific parameters ]
65 \fB[ -force ] -b\fR[\fIatch\fR] \fB[ filename ] \fR|
66 \fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR|
67 \fB[ \fB-nm \fR| \fB-nam\fR[\fIes\fR] \fB] \fR|
68 \fB[ \fR{ \fB-cf \fR| \fB-c\fR[\fIonf\fR] \fR} \fB[ filename ] \fB] \fR}
72 \fB\-s\fR[\fItatistics\fR] |
73 \fB\-d\fR[\fIetails\fR] |
75 \fB\-p\fR[\fIretty\fR] |
77 \fB\-g\fR[\fIraph\fR] |
78 \fB\-j\fR[\fIjson\fR] }
82 is used to configure Traffic Control in the Linux kernel. Traffic Control consists
87 When traffic is shaped, its rate of transmission is under control. Shaping may
88 be more than lowering the available bandwidth - it is also used to smooth out
89 bursts in traffic for better network behaviour. Shaping occurs on egress.
93 By scheduling the transmission of packets it is possible to improve interactivity
94 for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering
95 is also called prioritizing, and happens only on egress.
99 Whereas shaping deals with transmission of traffic, policing pertains to traffic
100 arriving. Policing thus occurs on ingress.
104 Traffic exceeding a set bandwidth may also be dropped forthwith, both on
105 ingress and on egress.
108 Processing of traffic is controlled by three kinds of objects: qdiscs,
113 is short for 'queueing discipline' and it is elementary to
114 understanding traffic control. Whenever the kernel needs to send a
115 packet to an interface, it is
117 to the qdisc configured for that interface. Immediately afterwards, the kernel
118 tries to get as many packets as possible from the qdisc, for giving them
119 to the network adaptor driver.
121 A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure
122 First In, First Out queue. It does however store traffic when the network interface
123 can't handle it momentarily.
126 Some qdiscs can contain classes, which contain further qdiscs - traffic may
127 then be enqueued in any of the inner qdiscs, which are within the
129 When the kernel tries to dequeue a packet from such a
131 it can come from any of the classes. A qdisc may for example prioritize
132 certain kinds of traffic by trying to dequeue from certain classes
138 is used by a classful qdisc to determine in which class a packet will
139 be enqueued. Whenever traffic arrives at a class with subclasses, it needs
140 to be classified. Various methods may be employed to do so, one of these
141 are the filters. All filters attached to the class are called, until one of
142 them returns with a verdict. If no verdict was made, other criteria may be
143 available. This differs per qdisc.
145 It is important to notice that filters reside
147 qdiscs - they are not masters of what happens.
149 The available filters are:
152 Filter packets based on an ematch expression. See
157 Filter packets using (e)BPF, see
162 Filter packets based on the control group of their process. See
167 Flow-based classifiers, filtering packets based on their flow (identified by selectable keys). See
168 .BR tc-flow "(8) and"
173 Filter based on fwmark. Directly maps fwmark value to traffic class. See
177 Filter packets based on routing table. See
182 Match Resource Reservation Protocol (RSVP) packets.
185 Filter packets based on traffic control index. See
189 Generic filtering on arbitrary packet data, assisted by syntax to abstract common operations. See
194 Traffic control filter that matches every packet. See
199 The classless qdiscs are:
202 CHOKe (CHOose and Keep for responsive flows, CHOose and Kill for unresponsive
203 flows) is a classless qdisc designed to both identify and penalize flows that
204 monopolize the queue. CHOKe is a variation of RED, and the configuration is
208 CoDel (pronounced "coddle") is an adaptive "no-knobs" active queue management
209 algorithm (AQM) scheme that was developed to address the shortcomings of
210 RED and its variants.
213 Simplest usable qdisc, pure First In, First Out behaviour. Limited in
217 Fair Queue Scheduler realises TCP pacing and scales to millions of concurrent
221 Fair Queuing Controlled Delay is queuing discipline that combines Fair
222 Queuing with the CoDel AQM scheme. FQ_Codel uses a stochastic model to classify
223 incoming packets into different flows and is used to provide a fair share of the
224 bandwidth to all the flows using the queue. Each such flow is managed by the
225 CoDel queuing discipline. Reordering within a flow is avoided since Codel
226 internally uses a FIFO queue.
229 Generalized Random Early Detection combines multiple RED queues in order to
230 achieve multiple drop priorities. This is required to realize Assured
231 Forwarding (RFC 2597).
234 Heavy-Hitter Filter differentiates between small flows and the opposite,
235 heavy-hitters. The goal is to catch the heavy-hitters and move them to a
236 separate queue with less priority so that bulk traffic does not affect the
237 latency of critical traffic.
240 This is a special qdisc as it applies to incoming traffic on an interface, allowing for it to be filtered and policed.
243 The Multiqueue Priority Qdisc is a simple queuing discipline that allows
244 mapping traffic flows to hardware queue ranges using priorities and a
245 configurable priority to traffic class mapping. A traffic class in this context
246 is a set of contiguous qdisc classes which map 1:1 to a set of hardware exposed
250 Multiqueue is a qdisc optimized for devices with multiple Tx queues. It has
251 been added for hardware that wishes to avoid head-of-line blocking. It will
252 cycle though the bands and verify that the hardware queue associated with the
253 band is not stopped prior to dequeuing a packet.
256 Network Emulator is an enhancement of the Linux traffic control facilities that
257 allow to add delay, packet loss, duplication and more other characteristics to
258 packets outgoing from a selected network interface.
261 Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
262 queue which honors Type of Service flags, as well as the priority that may be
263 assigned to a packet.
266 Proportional Integral controller-Enhanced (PIE) is a control theoretic active
267 queue management scheme. It is based on the proportional integral controller but
268 aims to control delay.
271 Random Early Detection simulates physical congestion by randomly dropping
272 packets when nearing configured bandwidth allocation. Well suited to very
273 large bandwidth applications.
276 Round-Robin qdisc with support for multiqueue network devices. Removed from
277 Linux since kernel version 2.6.27.
280 Stochastic Fair Blue is a classless qdisc to manage congestion based on
281 packet loss and link utilization history while trying to prevent
282 non-responsive flows (i.e. flows that do not react to congestion marking
283 or dropped packets) from impacting performance of responsive flows.
284 Unlike RED, where the marking probability has to be configured, BLUE
285 tries to determine the ideal marking probability automatically.
288 Stochastic Fairness Queueing reorders queued traffic so each 'session'
289 gets to send a packet in turn.
292 The Token Bucket Filter is suited for slowing traffic down to a precisely
293 configured rate. Scales well to large bandwidths.
294 .SH CONFIGURING CLASSLESS QDISCS
295 In the absence of classful qdiscs, classless qdiscs can only be attached at
296 the root of a device. Full syntax:
301 QDISC QDISC-PARAMETERS
311 qdisc is the automatic default in the absence of a configured qdisc.
314 The classful qdiscs are:
317 Map flows to virtual circuits of an underlying asynchronous transfer mode
321 Class Based Queueing implements a rich linksharing hierarchy of classes.
322 It contains shaping elements as well as prioritizing capabilities. Shaping is
323 performed using link idle time calculations based on average packet size and
324 underlying link bandwidth. The latter may be ill-defined for some interfaces.
327 The Deficit Round Robin Scheduler is a more flexible replacement for Stochastic
328 Fairness Queuing. Unlike SFQ, there are no built-in queues \-\- you need to add
329 classes and then set up filters to classify packets accordingly. This can be
330 useful e.g. for using RED qdiscs with different settings for particular
331 traffic. There is no default class \-\- if a packet cannot be classified, it is
335 Classify packets based on TOS field, change TOS field of packets based on
339 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.
342 The Hierarchy Token Bucket implements a rich linksharing hierarchy of
343 classes with an emphasis on conforming to existing practices. HTB facilitates
344 guaranteeing bandwidth to classes, while also allowing specification of upper
345 limits to inter-class sharing. It contains shaping elements, based on TBF and
346 can prioritize classes.
349 The PRIO qdisc is a non-shaping container for a configurable number of
350 classes which are dequeued in order. This allows for easy prioritization
351 of traffic, where lower classes are only able to send if higher ones have
352 no packets available. To facilitate configuration, Type Of Service bits are
356 Quick Fair Queueing is an O(1) scheduler that provides near-optimal guarantees,
357 and is the first to achieve that goal with a constant cost also with respect to
358 the number of groups and the packet length. The QFQ algorithm has no loops, and
359 uses very simple instructions and data structures that lend themselves very
360 well to a hardware implementation.
361 .SH THEORY OF OPERATION
362 Classes form a tree, where each class has a single parent.
363 A class may have multiple children. Some qdiscs allow for runtime addition
364 of classes (CBQ, HTB) while others (PRIO) are created with a static number of
367 Qdiscs which allow dynamic addition of classes can have zero or more
368 subclasses to which traffic may be enqueued.
370 Furthermore, each class contains a
374 behaviour, although another qdisc can be attached in place. This qdisc may again
375 contain classes, but each class can have only one leaf qdisc.
377 When a packet enters a classful qdisc it can be
379 to one of the classes within. Three criteria are available, although not all
380 qdiscs will use all three:
383 If tc filters are attached to a class, they are consulted first
384 for relevant instructions. Filters can match on all fields of a packet header,
385 as well as on the firewall mark applied by ipchains or iptables.
388 Some qdiscs have built in rules for classifying packets based on the TOS field.
391 Userspace programs can encode a \fIclass-id\fR in the 'skb->priority' field using
392 the SO_PRIORITY option.
394 Each node within the tree can have its own filters but higher level filters
395 may also point directly to lower classes.
397 If classification did not succeed, packets are enqueued to the leaf qdisc
398 attached to that class. Check qdisc specific manpages for details, however.
401 All qdiscs, classes and filters have IDs, which can either be specified
402 or be automatically assigned.
405 .BR major " number and a " minor
406 number, separated by a colon -
407 .BR major ":" minor "."
409 .BR major " and " minor
410 are hexadecimal numbers and are limited to 16 bits. There are two special
411 values: root is signified by
412 .BR major " and " minor
413 of all ones, and unspecified is all zeros.
417 A qdisc, which potentially can have children, gets assigned a
419 number, called a 'handle', leaving the
421 number namespace available for classes. The handle is expressed as '10:'.
422 It is customary to explicitly assign a handle to qdiscs expected to have children.
426 Classes residing under a qdisc share their qdisc
428 number, but each have a separate
430 number called a 'classid' that has no relation to their
431 parent classes, only to their parent qdisc. The same naming custom as for
436 Filters have a three part ID, which is only needed when using a hashed
440 The following parameters are widely used in TC. For other parameters,
441 see the man pages for individual qdiscs.
446 These parameters accept a floating point number, possibly followed by
447 either a unit (both SI and IEC units supported), or a float followed by a '%'
448 character to specify the rate as a percentage of the device's speed
449 (e.g. 5%, 99.5%). Warning: specifying the rate as a percentage means a fraction
450 of the current speed; if the speed changes, the value will not be recalculated.
484 To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with
485 IEC prefix (ki-, mi-, gi- and ti-) respectively.
488 TC store rates as a 32-bit unsigned integer in bps internally,
489 so we can specify a max rate of 4294967295 bps.
494 Length of time. Can be specified as a floating point number
495 followed by an optional unit:
504 us, usec, usecs or a bare number
508 TC defined its own time unit (equal to microsecond) and stores
509 time values as 32-bit unsigned integer, thus we can specify a max time value
515 Amounts of data. Can be specified as a floating point number
516 followed by an optional unit:
541 TC stores sizes internally as 32-bit unsigned integer in byte,
542 so we can specify a max size of 4294967295 bytes.
547 Other values without a unit.
548 These parameters are interpreted as decimal by default, but you can
549 indicate TC to interpret them as octal and hexadecimal by adding a '0'
550 or '0x' prefix respectively.
553 The following commands are available for qdiscs, classes and filter:
556 Add a qdisc, class or filter to a node. For all entities, a
558 must be passed, either by passing its ID or by attaching directly to the root of a device.
559 When creating a qdisc or a filter, it can be named with the
561 parameter. A class is named with the
567 A qdisc can be deleted by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs
568 are automatically deleted, as well as any filters attached to them.
572 Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
573 that the handle cannot be changed and neither can the parent. In other words,
580 Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
585 Displays a single filter given the interface \fIDEV\fR, \fIqdisc-id\fR,
586 \fIpriority\fR, \fIprotocol\fR and \fIfilter-id\fR.
590 Displays all filters attached to the given interface. A valid parent ID must be passed.
594 Only available for qdiscs and performs a replace where the node
600 .BR "\-b", " \-b filename", " \-batch", " \-batch filename"
601 read commands from provided file or standard input and invoke them.
602 First failure will cause termination of tc.
606 don't terminate tc on errors in batch mode.
607 If there were any errors during execution of the commands, the application return code will be non zero.
610 .BR "\-n" , " \-net" , " \-netns " <NETNS>
613 to the specified network namespace
615 Actually it just simplifies executing of:
620 .RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
626 .RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
630 .BR "\-cf" , " \-conf " <FILENAME>
631 specifies path to the config file. This option is used in conjunction with other options (e.g.
635 The show command has additional formatting options:
638 .BR "\-s" , " \-stats", " \-statistics"
639 output more statistics about packet usage.
642 .BR "\-d", " \-details"
643 output more detailed information about rates and cell sizes.
647 output raw hex values for handles.
650 .BR "\-p", " \-pretty"
651 decode filter offset and mask values to equivalent filter commands based on TCP/IP.
655 print rates in IEC units (ie. 1K = 1024).
658 .BR "\-g", " \-graph"
659 shows classes as ASCII graph. Prints generic stats info under each class if
661 option was specified. Classes can be filtered only by
667 Display results in JSON format.
670 .BR "\-nm" , " \-name"
671 resolve class name from
672 .B /etc/iproute2/tc_cls
673 file or from file specified by
675 option. This file is just a mapping of
683 1:40 voip # Here is another comment
699 was specified without
702 .B /etc/iproute2/tc_cls
703 file does not exist, which makes it possible to pass
712 tc -g class show dev eth0
714 Shows classes as ASCII graph on eth0 interface.
717 tc -g -s class show dev eth0
719 Shows classes as ASCII graph with stats info under each class.
723 was written by Alexey N. Kuznetsov and added in Linux 2.2.
744 .BR tc-pfifo_fast (8),
754 .RB "User documentation at " http://lartc.org/ ", but please direct bugreports and patches to: " <netdev@vger.kernel.org>
757 Manpage maintained by bert hubert (ahu@ds9a.nl)