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 [-s | -d ] qdisc show [ dev DEV ]
20
21       tc [-s | -d ] class show dev DEV
22
23       tc filter show dev DEV
24
25

DESCRIPTION

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

QDISCS

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

CLASSES

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

FILTERS

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

CLASSLESS QDISCS

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

CONFIGURING CLASSLESS QDISCS

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

CLASSFUL QDISCS

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

THEORY OF OPERATION

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

NAMING

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

UNITS

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

TC COMMANDS

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

HISTORY

293       tc was written by Alexey N. Kuznetsov and added in Linux 2.2.
294

SEE ALSO

296       tc-cbq(8), tc-htb(8), tc-sfq(8), tc-red(8), tc-tbf(8), tc-pfifo(8), tc-
297       bfifo(8), tc-pfifo_fast(8), tc-filters(8)
298
299

AUTHOR

301       Manpage maintained by bert hubert (ahu@ds9a.nl)
302
303
304
305
306iproute2                       16 December 2001                          TC(8)
Impressum