1TC(8)                                Linux                               TC(8)
2
3
4

NAME

6       tc - show / manipulate traffic control settings
7

SYNOPSIS

9       tc  qdisc [ add | change | replace | link ] dev DEV [ parent qdisc-id |
10       root ] [ handle qdisc-id ] qdisc [ qdisc specific parameters ]
11
12       tc class [ add | change | replace ] dev DEV parent qdisc-id  [  classid
13       class-id ] qdisc [ qdisc specific parameters ]
14
15       tc filter [ add | change | replace ] dev DEV [ parent qdisc-id | root ]
16       protocol protocol prio priority filtertype [ filtertype specific param‐
17       eters ] flowid flow-id
18
19       tc [ FORMAT ] qdisc show [ dev DEV ]
20
21       tc [ FORMAT ] class show dev DEV
22
23       tc filter show dev DEV
24
25
26       tc [ -force ] [ -OK ] -b[atch] [ filename ]
27

FORMAT := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | i[ec] }

29
30

DESCRIPTION

32       Tc  is  used  to configure Traffic Control in the Linux kernel. Traffic
33       Control consists of the following:
34
35
36       SHAPING
37              When traffic is shaped, its rate of transmission is  under  con‐
38              trol.  Shaping may be more than lowering the available bandwidth
39              - it is also used to smooth out bursts  in  traffic  for  better
40              network behaviour. Shaping occurs on egress.
41
42
43       SCHEDULING
44              By  scheduling  the  transmission  of  packets it is possible to
45              improve interactivity for traffic  that  needs  it  while  still
46              guaranteeing  bandwidth  to  bulk  transfers. Reordering is also
47              called prioritizing, and happens only on egress.
48
49
50       POLICING
51              Whereas shaping deals with  transmission  of  traffic,  policing
52              pertains to traffic arriving. Policing thus occurs on ingress.
53
54
55       DROPPING
56              Traffic exceeding a set bandwidth may also be dropped forthwith,
57              both on ingress and on egress.
58
59
60       Processing of traffic is controlled by three kinds of objects:  qdiscs,
61       classes and filters.
62
63

QDISCS

65       qdisc is short for 'queueing discipline' and it is elementary to under‐
66       standing traffic control. Whenever the kernel needs to send a packet to
67       an  interface,  it  is enqueued to the qdisc configured for that inter‐
68       face. Immediately afterwards, the kernel tries to get as  many  packets
69       as  possible  from  the  qdisc,  for giving them to the network adaptor
70       driver.
71
72       A simple QDISC is the 'pfifo' one, which does no processing at all  and
73       is a pure First In, First Out queue. It does however store traffic when
74       the network interface can't handle it momentarily.
75
76

CLASSES

78       Some qdiscs can contain classes, which contain further qdiscs - traffic
79       may  then  be enqueued in any of the inner qdiscs, which are within the
80       classes.  When the kernel tries to dequeue a packet from such a  class‐
81       ful  qdisc it can come from any of the classes. A qdisc may for example
82       prioritize certain kinds of traffic by trying to dequeue  from  certain
83       classes before others.
84
85

FILTERS

87       A  filter  is  used  by  a classful qdisc to determine in which class a
88       packet will be enqueued. Whenever traffic arrives at a class with  sub‐
89       classes,  it needs to be classified. Various methods may be employed to
90       do so, one of these are the filters. All filters attached to the  class
91       are called, until one of them returns with a verdict. If no verdict was
92       made, other criteria may be available. This differs per qdisc.
93
94       It is important to notice that filters reside within qdiscs - they  are
95       not masters of what happens.
96
97       The available filters are:
98
99       basic  Filter  packets  based on an ematch expression. See tc-ematch(8)
100              for details.
101
102       cgroup Filter packets based on the control group of their process.  See
103              tc-cgroup(8) for details.
104
105       flow   Flow-based  classifier,  filtering  packets  based on their flow
106              (identified by selectable keys). See tc-flow(8) for details.
107
108       fw     Filter based on fwmark. Directly maps fwmark  value  to  traffic
109              class. See tc-fw(8).
110
111       route  Filter  packets  based  on  routing  table.  See tc-route(8) for
112              details.
113
114       rsvp   Match Resource Reservation Protocol (RSVP) packets.
115
116       tcindex
117              Filter packets based on traffic control index. See tc-index(8).
118
119       u32    Generic filtering on arbitrary packet data, assisted  by  syntax
120              to abstract common operations. See tc-u32(8) for details.
121
122

CLASSLESS QDISCS

124       The classless qdiscs are:
125
126       [p|b]fifo
127              Simplest  usable qdisc, pure First In, First Out behaviour. Lim‐
128              ited in packets or in bytes.
129
130       pfifo_fast
131              Standard qdisc for 'Advanced Router' enabled  kernels.  Consists
132              of  a  three-band  queue  which honors Type of Service flags, as
133              well as the priority that may be assigned to a packet.
134
135       red    Random Early Detection simulates physical congestion by randomly
136              dropping  packets  when nearing configured bandwidth allocation.
137              Well suited to very large bandwidth applications.
138
139       sfq    Stochastic Fairness Queueing reorders  queued  traffic  so  each
140              'session' gets to send a packet in turn.
141
142       tbf    The  Token Bucket Filter is suited for slowing traffic down to a
143              precisely configured rate. Scales well to large bandwidths.
144

CONFIGURING CLASSLESS QDISCS

146       In the absence  of  classful  qdiscs,  classless  qdiscs  can  only  be
147       attached at the root of a device. Full syntax:
148
149       tc qdisc add dev DEV root QDISC QDISC-PARAMETERS
150
151       To remove, issue
152
153       tc qdisc del dev DEV root
154
155       The  pfifo_fast qdisc is the automatic default in the absence of a con‐
156       figured qdisc.
157
158

CLASSFUL QDISCS

160       The classful qdiscs are:
161
162       CBQ    Class Based Queueing implements a rich linksharing hierarchy  of
163              classes.   It  contains shaping elements as well as prioritizing
164              capabilities. Shaping is performed using link idle time calcula‐
165              tions  based  on  average  packet size and underlying link band‐
166              width. The latter may be ill-defined for some interfaces.
167
168       HTB    The Hierarchy Token Bucket implements a rich linksharing hierar‐
169              chy  of classes with an emphasis on conforming to existing prac‐
170              tices. HTB facilitates guaranteeing bandwidth to classes,  while
171              also allowing specification of upper limits to inter-class shar‐
172              ing. It contains shaping elements, based on TBF and can  priori‐
173              tize classes.
174
175       PRIO   The  PRIO  qdisc  is  a non-shaping container for a configurable
176              number of classes which are dequeued in order. This  allows  for
177              easy  prioritization  of  traffic,  where lower classes are only
178              able to send if higher ones have no packets available. To facil‐
179              itate  configuration,  Type  Of  Service  bits  are  honored  by
180              default.
181

THEORY OF OPERATION

183       Classes form a tree, where each class has a single parent.  A class may
184       have  multiple  children.  Some  qdiscs  allow  for runtime addition of
185       classes (CBQ, HTB) while others (PRIO) are created with a static number
186       of children.
187
188       Qdiscs  which  allow  dynamic addition of classes can have zero or more
189       subclasses to which traffic may be enqueued.
190
191       Furthermore, each class contains a leaf  qdisc  which  by  default  has
192       pfifo  behaviour, although another qdisc can be attached in place. This
193       qdisc may again contain classes, but each class can have only one  leaf
194       qdisc.
195
196       When  a  packet  enters a classful qdisc it can be classified to one of
197       the classes within. Three criteria  are  available,  although  not  all
198       qdiscs will use all three:
199
200       tc filters
201              If  tc filters are attached to a class, they are consulted first
202              for relevant instructions. Filters can match on all fields of  a
203              packet  header,  as  well  as  on  the  firewall mark applied by
204              ipchains or iptables.
205
206       Type of Service
207              Some qdiscs have built in rules for classifying packets based on
208              the TOS field.
209
210       skb->priority
211              Userspace  programs can encode a class-id in the 'skb->priority'
212              field using the SO_PRIORITY option.
213
214       Each node within the tree can have its own  filters  but  higher  level
215       filters may also point directly to lower classes.
216
217       If  classification  did  not  succeed, packets are enqueued to the leaf
218       qdisc attached  to  that  class.  Check  qdisc  specific  manpages  for
219       details, however.
220
221

NAMING

223       All qdiscs, classes and filters have IDs, which can either be specified
224       or be automatically assigned.
225
226       IDs consist of a major number and a minor number, separated by a colon.
227       Both  major and minor number are limited to 16 bits. There are two spe‐
228       cial values: root is signified by major and  minor  of  all  ones,  and
229       unspecified is all zeros.
230
231
232       QDISCS A  qdisc,  which  potentially can have children, gets assigned a
233              major number, called a 'handle', leaving the minor number names‐
234              pace  available  for  classes. The handle is expressed as '10:'.
235              It is customary to explicitly assign a handle to qdiscs expected
236              to have children.
237
238
239       CLASSES
240              Classes  residing  under a qdisc share their qdisc major number,
241              but each have a separate minor number called  a  'classid'  that
242              has  no  relation  to their parent classes, only to their parent
243              qdisc. The same naming custom as for qdiscs applies.
244
245
246       FILTERS
247              Filters have a three part ID, which is only needed when using  a
248              hashed filter hierarchy.
249

UNITS

251       All  parameters  accept a floating point number, possibly followed by a
252       unit.
253
254       Bandwidths or rates can be specified in:
255
256       kbps   Kilobytes per second
257
258       mbps   Megabytes per second
259
260       kbit   Kilobits per second
261
262       mbit   Megabits per second
263
264       bps or a bare number
265              Bytes per second
266
267       Amounts of data can be specified in:
268
269       kb or k
270              Kilobytes
271
272       mb or m
273              Megabytes
274
275       mbit   Megabits
276
277       kbit   Kilobits
278
279       b or a bare number
280              Bytes.
281
282       Lengths of time can be specified in:
283
284       s, sec or secs
285              Whole seconds
286
287       ms, msec or msecs
288              Milliseconds
289
290       us, usec, usecs or a bare number
291              Microseconds.
292
293

TC COMMANDS

295       The following commands are available for qdiscs, classes and filter:
296
297       add    Add a qdisc, class or filter to a node. For all entities, a par‐
298              ent  must  be  passed,  either by passing its ID or by attaching
299              directly to the root of a device.  When creating a  qdisc  or  a
300              filter,  it  can  be named with the handle parameter. A class is
301              named with the classid parameter.
302
303
304       remove A qdisc can be removed by specifying its handle, which may  also
305              be  'root'.  All  subclasses and their leaf qdiscs are automati‐
306              cally deleted, as well as any filters attached to them.
307
308
309       change Some entities can be modified 'in place'. Shares the  syntax  of
310              'add',  with the exception that the handle cannot be changed and
311              neither can the parent. In other words,  change  cannot  move  a
312              node.
313
314
315       replace
316              Performs  a  nearly atomic remove/add on an existing node id. If
317              the node does not exist yet it is created.
318
319
320       link   Only available for qdiscs and performs a replace where the  node
321              must exist already.
322
323

FORMAT

325       The show command has additional formatting options:
326
327
328       -s, -stats, -statistics
329              output more statistics about packet usage.
330
331
332       -d, -details
333              output more detailed information about rates and cell sizes.
334
335
336       -r, -raw
337              output raw hex values for handles.
338
339
340       -p, -pretty
341              decode  filter  offset and mask values to equivalent filter com‐
342              mands based on TCP/IP.
343
344
345       -iec   print rates in IEC units (ie. 1K = 1024).
346
347
348       -b, -b filename, -batch, -batch filename
349              read commands from provided file or standard  input  and  invoke
350              them.  First failure will cause termination of tc.
351
352
353       -force don't  terminate  tc on errors in batch mode.  If there were any
354              errors during execution of the commands, the application  return
355              code will be non zero.
356
357
358       -OK    in  batch mode, print OK and a new line on standard output after
359              each successfully interpreted command.
360
361

HISTORY

363       tc was written by Alexey N. Kuznetsov and added in Linux 2.2.
364

SEE ALSO

366       tc-basic(8),  tc-bfifo(8),  tc-cbq(8),  tc-cgroup(8),  tc-drr(8),   tc-
367       ematch(8),    tc-flow(8),   tc-fw(8),   tc-htb(8),   tc-pfifo(8),   tc-
368       pfifo_fast(8), tc-red(8), tc-route(8), tc-sfq(8),  tc-tbf(8),  tc-tcin‐
369       dex(8), tc-u32(8),
370       User  documentation  at http://lartc.org/, but please direct bugreports
371       and patches to: <netdev@vger.kernel.org>
372
373

AUTHOR

375       Manpage maintained by bert hubert (ahu@ds9a.nl)
376
377
378
379
380iproute2                       16 December 2001                          TC(8)
Impressum