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

NAME

6       tc - show / manipulate traffic control settings
7

SYNOPSIS

9       tc [ OPTIONS ] qdisc [ add | change | replace | link | delete ] dev DEV
10       [ parent qdisc-id | root ] [ handle qdisc-id ] qdisc [  qdisc  specific
11       parameters ]
12
13       tc [ OPTIONS ] class [ add | change | replace | delete ] dev DEV parent
14       qdisc-id [ classid class-id ] qdisc [ qdisc specific parameters ]
15
16       tc [ OPTIONS ] filter [ add | change | replace | delete | get ] dev DEV
17       [  parent qdisc-id | root ] [ handle filter-id ] protocol protocol prio
18       priority filtertype [ filtertype specific parameters ] flowid flow-id
19
20       tc [ OPTIONS ] [ FORMAT ] qdisc show [ dev DEV ]
21
22       tc [ OPTIONS ] [ FORMAT ] class show dev DEV
23
24       tc [ OPTIONS ] filter show dev DEV
25
26
27        OPTIONS := { [ -force ] [ -OK ] -b[atch] [ filename  ]  |  [  -n[etns]
28       name ] | [ -nm | -nam[es] ] | [ { -cf | -c[onf] } [ filename ] ] }
29
30        FORMAT := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -i[ec] |
31       -g[raph] }
32
33

DESCRIPTION

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

QDISCS

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

CLASSES

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

FILTERS

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

CLASSLESS QDISCS

136       The classless qdiscs are:
137
138       choke  CHOKe (CHOose and Keep for responsive flows, CHOose and Kill for
139              unresponsive flows) is a classless qdisc designed to both  iden‐
140              tify  and  penalize  flows that monopolize the queue. CHOKe is a
141              variation of RED, and the configuration is similar to RED.
142
143       codel  CoDel (pronounced "coddle") is  an  adaptive  "no-knobs"  active
144              queue  management  algorithm  (AQM) scheme that was developed to
145              address the shortcomings of RED and its variants.
146
147       [p|b]fifo
148              Simplest usable qdisc, pure First In, First Out behaviour.  Lim‐
149              ited in packets or in bytes.
150
151       fq     Fair  Queue Scheduler realises TCP pacing and scales to millions
152              of concurrent flows per qdisc.
153
154       fq_codel
155              Fair Queuing Controlled Delay is queuing  discipline  that  com‐
156              bines  Fair  Queuing  with the CoDel AQM scheme. FQ_Codel uses a
157              stochastic model to classify  incoming  packets  into  different
158              flows  and  is  used to provide a fair share of the bandwidth to
159              all the flows using the queue. Each such flow is managed by  the
160              CoDel  queuing  discipline.  Reordering within a flow is avoided
161              since Codel internally uses a FIFO queue.
162
163       gred   Generalized Random Early Detection combines multiple RED  queues
164              in  order  to achieve multiple drop priorities. This is required
165              to realize Assured Forwarding (RFC 2597).
166
167       hhf    Heavy-Hitter Filter differentiates between small flows  and  the
168              opposite,  heavy-hitters. The goal is to catch the heavy-hitters
169              and move them to a separate queue with  less  priority  so  that
170              bulk traffic does not affect the latency of critical traffic.
171
172       ingress
173              This  is a special qdisc as it applies to incoming traffic on an
174              interface, allowing for it to be filtered and policed.
175
176       mqprio The Multiqueue Priority Qdisc is  a  simple  queuing  discipline
177              that allows mapping traffic flows to hardware queue ranges using
178              priorities and a configurable priority to traffic class mapping.
179              A  traffic  class  in  this context is a set of contiguous qdisc
180              classes which map 1:1 to a set of hardware exposed queues.
181
182       multiq Multiqueue is a qdisc optimized for  devices  with  multiple  Tx
183              queues.  It  has  been  added  for hardware that wishes to avoid
184              head-of-line blocking.  It will cycle though the bands and  ver‐
185              ify  that  the  hardware  queue  associated with the band is not
186              stopped prior to dequeuing a packet.
187
188       netem  Network Emulator is an enhancement of the Linux traffic  control
189              facilities that allow to add delay, packet loss, duplication and
190              more other characteristics to packets outgoing from  a  selected
191              network interface.
192
193       pfifo_fast
194              Standard  qdisc  for 'Advanced Router' enabled kernels. Consists
195              of a three-band queue which honors Type  of  Service  flags,  as
196              well as the priority that may be assigned to a packet.
197
198       pie    Proportional  Integral  controller-Enhanced  (PIE)  is a control
199              theoretic active queue management scheme. It  is  based  on  the
200              proportional integral controller but aims to control delay.
201
202       red    Random Early Detection simulates physical congestion by randomly
203              dropping packets when nearing configured  bandwidth  allocation.
204              Well suited to very large bandwidth applications.
205
206       rr     Round-Robin  qdisc  with support for multiqueue network devices.
207              Removed from Linux since kernel version 2.6.27.
208
209       sfb    Stochastic Fair Blue is a classless qdisc to  manage  congestion
210              based  on  packet loss and link utilization history while trying
211              to prevent non-responsive flows (i.e. flows that do not react to
212              congestion  marking  or  dropped packets) from impacting perfor‐
213              mance of responsive flows.  Unlike RED, where the marking proba‐
214              bility  has  to be configured, BLUE tries to determine the ideal
215              marking probability automatically.
216
217       sfq    Stochastic Fairness Queueing reorders  queued  traffic  so  each
218              'session' gets to send a packet in turn.
219
220       tbf    The  Token Bucket Filter is suited for slowing traffic down to a
221              precisely configured rate. Scales well to large bandwidths.
222

CONFIGURING CLASSLESS QDISCS

224       In the absence  of  classful  qdiscs,  classless  qdiscs  can  only  be
225       attached at the root of a device. Full syntax:
226
227       tc qdisc add dev DEV root QDISC QDISC-PARAMETERS
228
229       To remove, issue
230
231       tc qdisc del dev DEV root
232
233       The  pfifo_fast qdisc is the automatic default in the absence of a con‐
234       figured qdisc.
235
236

CLASSFUL QDISCS

238       The classful qdiscs are:
239
240       ATM    Map flows to virtual  circuits  of  an  underlying  asynchronous
241              transfer mode device.
242
243       CBQ    Class  Based Queueing implements a rich linksharing hierarchy of
244              classes.  It contains shaping elements as well  as  prioritizing
245              capabilities. Shaping is performed using link idle time calcula‐
246              tions based on average packet size  and  underlying  link  band‐
247              width. The latter may be ill-defined for some interfaces.
248
249       DRR    The Deficit Round Robin Scheduler is a more flexible replacement
250              for Stochastic Fairness Queuing. Unlike SFQ, there are no built-
251              in  queues -- you need to add classes and then set up filters to
252              classify packets accordingly.  This can be useful e.g. for using
253              RED qdiscs with different settings for particular traffic. There
254              is no default class -- if a packet cannot be classified,  it  is
255              dropped.
256
257       DSMARK Classify packets based on TOS field, change TOS field of packets
258              based on classification.
259
260       HFSC   Hierarchical Fair Service Curve guarantees precise bandwidth and
261              delay allocation for leaf classes and allocates excess bandwidth
262              fairly. Unlike HTB, it makes use of packet dropping  to  achieve
263              low delays which interactive sessions benefit from.
264
265       HTB    The Hierarchy Token Bucket implements a rich linksharing hierar‐
266              chy of classes with an emphasis on conforming to existing  prac‐
267              tices.  HTB facilitates guaranteeing bandwidth to classes, while
268              also allowing specification of upper limits to inter-class shar‐
269              ing.  It contains shaping elements, based on TBF and can priori‐
270              tize classes.
271
272       PRIO   The PRIO qdisc is a non-shaping  container  for  a  configurable
273              number  of  classes which are dequeued in order. This allows for
274              easy prioritization of traffic, where  lower  classes  are  only
275              able to send if higher ones have no packets available. To facil‐
276              itate  configuration,  Type  Of  Service  bits  are  honored  by
277              default.
278
279       QFQ    Quick  Fair  Queueing  is  an O(1) scheduler that provides near-
280              optimal guarantees, and is the first to achieve that goal with a
281              constant  cost also with respect to the number of groups and the
282              packet length. The QFQ algorithm has no  loops,  and  uses  very
283              simple  instructions  and  data  structures that lend themselves
284              very well to a hardware implementation.
285

THEORY OF OPERATION

287       Classes form a tree, where each class has a single parent.  A class may
288       have  multiple  children.  Some  qdiscs  allow  for runtime addition of
289       classes (CBQ, HTB) while others (PRIO) are created with a static number
290       of children.
291
292       Qdiscs  which  allow  dynamic addition of classes can have zero or more
293       subclasses to which traffic may be enqueued.
294
295       Furthermore, each class contains a leaf  qdisc  which  by  default  has
296       pfifo  behaviour, although another qdisc can be attached in place. This
297       qdisc may again contain classes, but each class can have only one  leaf
298       qdisc.
299
300       When  a  packet  enters a classful qdisc it can be classified to one of
301       the classes within. Three criteria  are  available,  although  not  all
302       qdiscs will use all three:
303
304       tc filters
305              If  tc filters are attached to a class, they are consulted first
306              for relevant instructions. Filters can match on all fields of  a
307              packet  header,  as  well  as  on  the  firewall mark applied by
308              ipchains or iptables.
309
310       Type of Service
311              Some qdiscs have built in rules for classifying packets based on
312              the TOS field.
313
314       skb->priority
315              Userspace  programs can encode a class-id in the 'skb->priority'
316              field using the SO_PRIORITY option.
317
318       Each node within the tree can have its own  filters  but  higher  level
319       filters may also point directly to lower classes.
320
321       If  classification  did  not  succeed, packets are enqueued to the leaf
322       qdisc attached  to  that  class.  Check  qdisc  specific  manpages  for
323       details, however.
324
325

NAMING

327       All qdiscs, classes and filters have IDs, which can either be specified
328       or be automatically assigned.
329
330       IDs consist of a major number and a minor number, separated by a  colon
331       -  major:minor.   Both  major and minor are hexadecimal numbers and are
332       limited to 16 bits. There are two special values: root is signified  by
333       major and minor of all ones, and unspecified is all zeros.
334
335
336       QDISCS A  qdisc,  which  potentially can have children, gets assigned a
337              major number, called a 'handle', leaving the minor number names‐
338              pace  available  for  classes. The handle is expressed as '10:'.
339              It is customary to explicitly assign a handle to qdiscs expected
340              to have children.
341
342
343       CLASSES
344              Classes  residing  under a qdisc share their qdisc major number,
345              but each have a separate minor number called  a  'classid'  that
346              has  no  relation  to their parent classes, only to their parent
347              qdisc. The same naming custom as for qdiscs applies.
348
349
350       FILTERS
351              Filters have a three part ID, which is only needed when using  a
352              hashed filter hierarchy.
353
354

PARAMETERS

356       The  following  parameters are widely used in TC. For other parameters,
357       see the man pages for individual qdiscs.
358
359
360       RATES  Bandwidths or rates.  These parameters accept a  floating  point
361              number,  possibly followed by a unit (both SI and IEC units sup‐
362              ported).
363
364              bit or a bare number
365                     Bits per second
366
367              kbit   Kilobits per second
368
369              mbit   Megabits per second
370
371              gbit   Gigabits per second
372
373              tbit   Terabits per second
374
375              bps    Bytes per second
376
377              kbps   Kilobytes per second
378
379              mbps   Megabytes per second
380
381              gbps   Gigabytes per second
382
383              tbps   Terabytes per second
384
385
386              To specify in IEC units, replace the SI prefix (k-, m-, g-,  t-)
387              with IEC prefix (ki-, mi-, gi- and ti-) respectively.
388
389
390              TC  store  rates as a 32-bit unsigned integer in bps internally,
391              so we can specify a max rate of 4294967295 bps.
392
393
394       TIMES  Length of time. Can be specified as a floating point number fol‐
395              lowed by an optional unit:
396
397              s, sec or secs
398                     Whole seconds
399
400              ms, msec or msecs
401                     Milliseconds
402
403              us, usec, usecs or a bare number
404                     Microseconds.
405
406
407              TC  defined  its own time unit (equal to microsecond) and stores
408              time values as 32-bit unsigned integer, thus we  can  specify  a
409              max time value of 4294967295 usecs.
410
411
412       SIZES  Amounts  of  data.  Can  be specified as a floating point number
413              followed by an optional unit:
414
415              b or a bare number
416                     Bytes.
417
418              kbit   Kilobits
419
420              kb or k
421                     Kilobytes
422
423              mbit   Megabits
424
425              mb or m
426                     Megabytes
427
428              gbit   Gigabits
429
430              gb or g
431                     Gigabytes
432
433
434              TC stores sizes internally as 32-bit unsigned integer  in  byte,
435              so we can specify a max size of 4294967295 bytes.
436
437
438       VALUES Other  values  without a unit.  These parameters are interpreted
439              as decimal by default, but you can indicate TC to interpret them
440              as  octal and hexadecimal by adding a '0' or '0x' prefix respec‐
441              tively.
442
443

TC COMMANDS

445       The following commands are available for qdiscs, classes and filter:
446
447       add    Add a qdisc, class or filter to a node. For all entities, a par‐
448              ent  must  be  passed,  either by passing its ID or by attaching
449              directly to the root of a device.  When creating a  qdisc  or  a
450              filter,  it  can  be named with the handle parameter. A class is
451              named with the classid parameter.
452
453
454       delete A qdisc can be deleted by specifying its handle, which may  also
455              be  'root'.  All  subclasses and their leaf qdiscs are automati‐
456              cally deleted, as well as any filters attached to them.
457
458
459       change Some entities can be modified 'in place'. Shares the  syntax  of
460              'add',  with the exception that the handle cannot be changed and
461              neither can the parent. In other words,  change  cannot  move  a
462              node.
463
464
465       replace
466              Performs  a  nearly atomic remove/add on an existing node id. If
467              the node does not exist yet it is created.
468
469
470       get    Displays a single filter given the interface DEV, qdisc-id, pri‐
471              ority, protocol and filter-id.
472
473
474       show   Displays  all  filters  attached to the given interface. A valid
475              parent ID must be passed.
476
477
478       link   Only available for qdiscs and performs a replace where the  node
479              must exist already.
480
481

OPTIONS

483       -b, -b filename, -batch, -batch filename
484              read  commands  from  provided file or standard input and invoke
485              them.  First failure will cause termination of tc.
486
487
488       -force don't terminate tc on errors in batch mode.  If there  were  any
489              errors  during execution of the commands, the application return
490              code will be non zero.
491
492
493       -OK    in batch mode, print OK and a new line on standard output  after
494              each successfully interpreted command.
495
496
497       -n, -net, -netns <NETNS>
498              switches  tc to the specified network namespace NETNS.  Actually
499              it just simplifies executing of:
500
501              ip netns exec NETNS tc [ OPTIONS ] OBJECT { COMMAND | help }
502
503              to
504
505              tc -n[etns] NETNS [ OPTIONS ] OBJECT { COMMAND | help }
506
507
508       -cf, -conf <FILENAME>
509              specifies path to the config file. This option is used  in  con‐
510              junction with other options (e.g.  -nm).
511
512

FORMAT

514       The show command has additional formatting options:
515
516
517       -s, -stats, -statistics
518              output more statistics about packet usage.
519
520
521       -d, -details
522              output more detailed information about rates and cell sizes.
523
524
525       -r, -raw
526              output raw hex values for handles.
527
528
529       -p, -pretty
530              decode  filter  offset and mask values to equivalent filter com‐
531              mands based on TCP/IP.
532
533
534       -iec   print rates in IEC units (ie. 1K = 1024).
535
536
537       -g, -graph
538              shows classes as ASCII graph. Prints generic  stats  info  under
539              each  class  if -s option was specified. Classes can be filtered
540              only by dev option.
541
542
543       -nm, -name
544              resolve class name from /etc/iproute2/tc_cls file or  from  file
545              specified  by -cf option. This file is just a mapping of classid
546              to class name:
547
548                 # Here is comment
549                 1:40   voip # Here is another comment
550                 1:50   web
551                 1:60   ftp
552                 1:2    home
553
554              tc will not fail if -nm was specified  without  -cf  option  but
555              /etc/iproute2/tc_cls  file does not exist, which makes it possi‐
556              ble to pass -nm option for creating tc alias.
557
558

EXAMPLES

560       tc -g class show dev eth0
561           Shows classes as ASCII graph on eth0 interface.
562
563       tc -g -s class show dev eth0
564           Shows classes as ASCII graph with stats info under each class.
565
566

HISTORY

568       tc was written by Alexey N. Kuznetsov and added in Linux 2.2.
569

SEE ALSO

571       tc-basic(8),  tc-bfifo(8),  tc-bpf(8),  tc-cbq(8),  tc-cgroup(8),   tc-
572       choke(8),   tc-codel(8),   tc-drr(8),   tc-ematch(8),  tc-flow(8),  tc-
573       flower(8), tc-fq(8), tc-fq_codel(8), tc-fw(8), tc-hfsc(7),  tc-hfsc(8),
574       tc-htb(8),  tc-mqprio(8), tc-pfifo(8), tc-pfifo_fast(8), tc-red(8), tc-
575       route(8), tc-sfb(8), tc-sfq(8), tc-stab(8),  tc-tbf(8),  tc-tcindex(8),
576       tc-u32(8),
577       User  documentation  at http://lartc.org/, but please direct bugreports
578       and patches to: <netdev@vger.kernel.org>
579
580

AUTHOR

582       Manpage maintained by bert hubert (ahu@ds9a.nl)
583
584
585
586iproute2                       16 December 2001                          TC(8)
Impressum