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

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

26
27

DESCRIPTION

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

QDISCS

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

CLASSES

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

FILTERS

84       A  filter  is  used  by  a classful qdisc to determine in which class a
85       packet will be enqueued. Whenever traffic arrives at a class with  sub‐
86       classes,  it needs to be classified. Various methods may be employed to
87       do so, one of these are the filters. All filters attached to the  class
88       are called, until one of them returns with a verdict. If no verdict was
89       made, other criteria may be available. This differs per qdisc.
90
91       It is important to notice that filters reside within qdiscs - they  are
92       not masters of what happens.
93
94

CLASSLESS QDISCS

96       The classless qdiscs are:
97
98       [p|b]fifo
99              Simplest  usable qdisc, pure First In, First Out behaviour. Lim‐
100              ited in packets or in bytes.
101
102       pfifo_fast
103              Standard qdisc for 'Advanced Router' enabled  kernels.  Consists
104              of  a  three-band  queue  which honors Type of Service flags, as
105              well as the priority that may be assigned to a packet.
106
107       red    Random Early Detection simulates physical congestion by randomly
108              dropping  packets  when nearing configured bandwidth allocation.
109              Well suited to very large bandwidth applications.
110
111       sfq    Stochastic Fairness Queueing reorders  queued  traffic  so  each
112              'session' gets to send a packet in turn.
113
114       tbf    The  Token Bucket Filter is suited for slowing traffic down to a
115              precisely configured rate. Scales well to large bandwidths.
116

CONFIGURING CLASSLESS QDISCS

118       In the absence  of  classful  qdiscs,  classless  qdiscs  can  only  be
119       attached at the root of a device. Full syntax:
120
121       tc qdisc add dev DEV root QDISC QDISC-PARAMETERS
122
123       To remove, issue
124
125       tc qdisc del dev DEV root
126
127       The  pfifo_fast qdisc is the automatic default in the absence of a con‐
128       figured qdisc.
129
130

CLASSFUL QDISCS

132       The classful qdiscs are:
133
134       CBQ    Class Based Queueing implements a rich linksharing hierarchy  of
135              classes.   It  contains shaping elements as well as prioritizing
136              capabilities. Shaping is performed using link idle time calcula‐
137              tions  based  on  average  packet size and underlying link band‐
138              width. The latter may be ill-defined for some interfaces.
139
140       HTB    The Hierarchy Token Bucket implements a rich linksharing hierar‐
141              chy  of classes with an emphasis on conforming to existing prac‐
142              tices. HTB facilitates guaranteeing bandwidth to classes,  while
143              also allowing specification of upper limits to inter-class shar‐
144              ing. It contains shaping elements, based on TBF and can  priori‐
145              tize classes.
146
147       PRIO   The  PRIO  qdisc  is  a non-shaping container for a configurable
148              number of classes which are dequeued in order. This  allows  for
149              easy  prioritization  of  traffic,  where lower classes are only
150              able to send if higher ones have no packets available. To facil‐
151              itate  configuration,  Type  Of  Service  bits  are  honored  by
152              default.
153

THEORY OF OPERATION

155       Classes form a tree, where each class has a single parent.  A class may
156       have  multiple  children.  Some  qdiscs  allow  for runtime addition of
157       classes (CBQ, HTB) while others (PRIO) are created with a static number
158       of children.
159
160       Qdiscs  which  allow  dynamic addition of classes can have zero or more
161       subclasses to which traffic may be enqueued.
162
163       Furthermore, each class contains a leaf  qdisc  which  by  default  has
164       pfifo  behaviour  though  another  qdisc can be attached in place. This
165       qdisc may again contain classes, but each class can have only one  leaf
166       qdisc.
167
168       When  a  packet  enters a classful qdisc it can be classified to one of
169       the classes within. Three criteria  are  available,  although  not  all
170       qdiscs will use all three:
171
172       tc filters
173              If  tc filters are attached to a class, they are consulted first
174              for relevant instructions. Filters can match on all fields of  a
175              packet  header,  as  well  as  on  the  firewall mark applied by
176              ipchains or iptables.
177
178       Type of Service
179              Some qdiscs have built in rules for classifying packets based on
180              the TOS field.
181
182       skb->priority
183              Userspace  programs can encode a class-id in the 'skb->priority'
184              field using the SO_PRIORITY option.
185
186       Each node within the tree can have its own  filters  but  higher  level
187       filters may also point directly to lower classes.
188
189       If  classification  did  not  succeed, packets are enqueued to the leaf
190       qdisc attached  to  that  class.  Check  qdisc  specific  manpages  for
191       details, however.
192
193

NAMING

195       All qdiscs, classes and filters have IDs, which can either be specified
196       or be automatically assigned.
197
198       IDs consist of a major number and a minor number, separated by a colon.
199
200
201       QDISCS A qdisc, which potentially can have children,  gets  assigned  a
202              major number, called a 'handle', leaving the minor number names‐
203              pace available for classes. The handle is  expressed  as  '10:'.
204              It is customary to explicitly assign a handle to qdiscs expected
205              to have children.
206
207
208       CLASSES
209              Classes residing under a qdisc share their qdisc  major  number,
210              but  each  have  a separate minor number called a 'classid' that
211              has no relation to their parent classes, only  to  their  parent
212              qdisc. The same naming custom as for qdiscs applies.
213
214
215       FILTERS
216              Filters  have a three part ID, which is only needed when using a
217              hashed filter hierarchy.
218

UNITS

220       All parameters accept a floating point number, possibly followed  by  a
221       unit.
222
223       Bandwidths or rates can be specified in:
224
225       kbps   Kilobytes per second
226
227       mbps   Megabytes per second
228
229       kbit   Kilobits per second
230
231       mbit   Megabits per second
232
233       bps or a bare number
234              Bytes per second
235
236       Amounts of data can be specified in:
237
238       kb or k
239              Kilobytes
240
241       mb or m
242              Megabytes
243
244       mbit   Megabits
245
246       kbit   Kilobits
247
248       b or a bare number
249              Bytes.
250
251       Lengths of time can be specified in:
252
253       s, sec or secs
254              Whole seconds
255
256       ms, msec or msecs
257              Milliseconds
258
259       us, usec, usecs or a bare number
260              Microseconds.
261
262

TC COMMANDS

264       The following commands are available for qdiscs, classes and filter:
265
266       add    Add a qdisc, class or filter to a node. For all entities, a par‐
267              ent must be passed, either by passing its  ID  or  by  attaching
268              directly  to  the  root of a device.  When creating a qdisc or a
269              filter, it can be named with the handle parameter.  A  class  is
270              named with the classid parameter.
271
272
273       remove A  qdisc can be removed by specifying its handle, which may also
274              be 'root'. All subclasses and their leaf  qdiscs  are  automati‐
275              cally deleted, as well as any filters attached to them.
276
277
278       change Some  entities  can be modified 'in place'. Shares the syntax of
279              'add', with the exception that the handle cannot be changed  and
280              neither  can  the  parent.  In other words, change cannot move a
281              node.
282
283
284       replace
285              Performs a nearly atomic remove/add on an existing node  id.  If
286              the node does not exist yet it is created.
287
288
289       link   Only  available for qdiscs and performs a replace where the node
290              must exist already.
291
292

FORMAT

294       The show command has additional formatting options:
295
296
297       -s, -stats, -statistics
298              output more statistics about packet usage.
299
300
301       -d, -details
302              output more detailed information about rates and cell sizes.
303
304
305       -r, -raw
306              output raw hex values for handles.
307
308
309       -p, -pretty
310              decode filter offset and mask values to equivalent  filter  com‐
311              mands based on TCP/IP.
312
313
314       -iec   print rates in IEC units (ie. 1K = 1024).
315
316
317

HISTORY

319       tc was written by Alexey N. Kuznetsov and added in Linux 2.2.
320

SEE ALSO

322       tc-cbq(8),  tc-drr(8),  tc-htb(8), tc-sfq(8), tc-red(8), tc-tbf(8), tc-
323       pfifo(8), tc-bfifo(8), tc-pfifo_fast(8),
324       User documentation at http://lartc.org/, but please  direct  bugreports
325       and patches to: <netdev@vger.kernel.org>
326
327

AUTHOR

329       Manpage maintained by bert hubert (ahu@ds9a.nl)
330
331
332
333
334iproute2                       16 December 2001                          TC(8)
Impressum