1 .TH TC 8 "16 December 2001" "iproute2" "Linux"
3 tc \- show / manipulate traffic control settings
5 .B tc qdisc [ add | change | replace | link ] dev
13 [ qdisc specific parameters ]
16 .B tc class [ add | change | replace ] dev
22 [ qdisc specific parameters ]
25 .B tc filter [ add | change | replace ] dev
33 [ filtertype specific parameters ]
37 .B tc [-s | -d ] qdisc show [ dev
41 .B tc [-s | -d ] class show dev
49 is used to configure Traffic Control in the Linux kernel. Traffic Control consists
54 When traffic is shaped, its rate of transmission is under control. Shaping may
55 be more than lowering the available bandwidth - it is also used to smooth out
56 bursts in traffic for better network behaviour. Shaping occurs on egress.
60 By scheduling the transmission of packets it is possible to improve interactivity
61 for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering
62 is also called prioritizing, and happens only on egress.
66 Where shaping deals with transmission of traffic, policing pertains to traffic
67 arriving. Policing thus occurs on ingress.
71 Traffic exceeding a set bandwidth may also be dropped forthwith, both on
72 ingress and on egress.
75 Processing of traffic is controlled by three kinds of objects: qdiscs,
80 is short for 'queueing discipline' and it is elementary to
81 understanding traffic control. Whenever the kernel needs to send a
82 packet to an interface, it is
84 to the qdisc configured for that interface. Immediately afterwards, the kernel
85 tries to get as many packets as possible from the qdisc, for giving them
86 to the network adaptor driver.
88 A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure
89 First In, First Out queue. It does however store traffic when the network interface
90 can't handle it momentarily.
93 Some qdiscs can contain classes, which contain further qdiscs - traffic may
94 then be enqueued in any of the inner qdiscs, which are within the
96 When the kernel tries to dequeue a packet from such a
98 it can come from any of the classes. A qdisc may for example prioritize
99 certain kinds of traffic by trying to dequeue from certain classes
105 is used by a classful qdisc to determine in which class a packet will
106 be enqueued. Whenever traffic arrives at a class with subclasses, it needs
107 to be classified. Various methods may be employed to do so, one of these
108 are the filters. All filters attached to the class are called, until one of
109 them returns with a verdict. If no verdict was made, other criteria may be
110 available. This differs per qdisc.
112 It is important to notice that filters reside
114 qdiscs - they are not masters of what happens.
117 The classless qdiscs are:
120 Simplest usable qdisc, pure First In, First Out behaviour. Limited in
124 Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
125 queue which honors Type of Service flags, as well as the priority that may be
126 assigned to a packet.
129 Random Early Detection simulates physical congestion by randomly dropping
130 packets when nearing configured bandwidth allocation. Well suited to very
131 large bandwidth applications.
134 Stochastic Fairness Queueing reorders queued traffic so each 'session'
135 gets to send a packet in turn.
138 The Token Bucket Filter is suited for slowing traffic down to a precisely
139 configured rate. Scales well to large bandwidths.
140 .SH CONFIGURING CLASSLESS QDISCS
141 In the absence of classful qdiscs, classless qdiscs can only be attached at
142 the root of a device. Full syntax:
147 QDISC QDISC-PARAMETERS
157 qdisc is the automatic default in the absence of a configured qdisc.
160 The classful qdiscs are:
163 Class Based Queueing implements a rich linksharing hierarchy of classes.
164 It contains shaping elements as well as prioritizing capabilities. Shaping is
165 performed using link idle time calculations based on average packet size and
166 underlying link bandwidth. The latter may be ill-defined for some interfaces.
169 The Hierarchy Token Bucket implements a rich linksharing hierarchy of
170 classes with an emphasis on conforming to existing practices. HTB facilitates
171 guaranteeing bandwidth to classes, while also allowing specification of upper
172 limits to inter-class sharing. It contains shaping elements, based on TBF and
173 can prioritize classes.
176 The PRIO qdisc is a non-shaping container for a configurable number of
177 classes which are dequeued in order. This allows for easy prioritization
178 of traffic, where lower classes are only able to send if higher ones have
179 no packets available. To facilitate configuration, Type Of Service bits are
181 .SH THEORY OF OPERATION
182 Classes form a tree, where each class has a single parent.
183 A class may have multiple children. Some qdiscs allow for runtime addition
184 of classes (CBQ, HTB) while others (PRIO) are created with a static number of
187 Qdiscs which allow dynamic addition of classes can have zero or more
188 subclasses to which traffic may be enqueued.
190 Furthermore, each class contains a
194 behaviour though another qdisc can be attached in place. This qdisc may again
195 contain classes, but each class can have only one leaf qdisc.
197 When a packet enters a classful qdisc it can be
199 to one of the classes within. Three criteria are available, although not all
200 qdiscs will use all three:
203 If tc filters are attached to a class, they are consulted first
204 for relevant instructions. Filters can match on all fields of a packet header,
205 as well as on the firewall mark applied by ipchains or iptables. See
209 Some qdiscs have built in rules for classifying packets based on the TOS field.
212 Userspace programs can encode a class-id in the 'skb->priority' field using
213 the SO_PRIORITY option.
215 Each node within the tree can have its own filters but higher level filters
216 may also point directly to lower classes.
218 If classification did not succeed, packets are enqueued to the leaf qdisc
219 attached to that class. Check qdisc specific manpages for details, however.
222 All qdiscs, classes and filters have IDs, which can either be specified
223 or be automatically assigned.
225 IDs consist of a major number and a minor number, separated by a colon.
229 A qdisc, which potentially can have children,
230 gets assigned a major number, called a 'handle', leaving the minor
231 number namespace available for classes. The handle is expressed as '10:'.
232 It is customary to explicitly assign a handle to qdiscs expected to have
237 Classes residing under a qdisc share their qdisc major number, but each have
238 a separate minor number called a 'classid' that has no relation to their
239 parent classes, only to their parent qdisc. The same naming custom as for
244 Filters have a three part ID, which is only needed when using a hashed
245 filter hierarchy, for which see
248 All parameters accept a floating point number, possibly followed by a unit.
250 Bandwidths or rates can be specified in:
267 Amounts of data can be specified in:
284 Lengths of time can be specified in:
292 us, usec, usecs or a bare number
296 The following commands are available for qdiscs, classes and filter:
299 Add a qdisc, class or filter to a node. For all entities, a
301 must be passed, either by passing its ID or by attaching directly to the root of a device.
302 When creating a qdisc or a filter, it can be named with the
304 parameter. A class is named with the
310 A qdisc can be removed by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs
311 are automatically deleted, as well as any filters attached to them.
315 Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
316 that the handle cannot be changed and neither can the parent. In other words,
323 Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
328 Only available for qdiscs and performs a replace where the node
334 was written by Alexey N. Kuznetsov and added in Linux 2.2.
343 .BR tc-pfifo_fast (8),
347 Manpage maintained by bert hubert (ahu@ds9a.nl)