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  ]  [  ingress_block
11       BLOCK_INDEX  ]  [  egress_block  BLOCK_INDEX  ]  qdisc [ qdisc specific
12       parameters ]
13
14       tc [ OPTIONS ] class [ add | change | replace | delete ] dev DEV parent
15       qdisc-id [ classid class-id ] qdisc [ qdisc specific parameters ]
16
17       tc [ OPTIONS ] filter [ add | change | replace | delete | get ] dev DEV
18       [ parent qdisc-id | root ] [ handle filter-id ] protocol protocol  prio
19       priority filtertype [ filtertype specific parameters ] flowid flow-id
20
21       tc  [  OPTIONS ] filter [ add | change | replace | delete | get ] block
22       BLOCK_INDEX [ handle filter-id ] protocol protocol prio  priority  fil‐
23       tertype [ filtertype specific parameters ] flowid flow-id
24
25       tc [ OPTIONS ] [ FORMAT ] qdisc show [ dev DEV ]
26
27       tc [ OPTIONS ] [ FORMAT ] class show dev DEV
28
29       tc [ OPTIONS ] filter show dev DEV
30
31       tc [ OPTIONS ] filter show block BLOCK_INDEX
32
33
34       tc [ OPTIONS ] monitor [ file FILENAME ]
35
36
37        OPTIONS  := { [ -force ] -b[atch] [ filename ] | [ -n[etns] name ] | [
38       -nm | -nam[es] ] | [ { -cf | -c[onf] } [ filename ] ] [ -t[imestamp]  ]
39       | [ -t[short] | [ -o[neline] ] }
40
41        FORMAT  := { -s[tatistics] | -d[etails] | -r[aw] | -i[ec] | -g[raph] |
42       -j[json] | -p[retty] | -col[or] }
43
44

DESCRIPTION

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

QDISCS

79       qdisc is short for 'queueing discipline' and it is elementary to under‐
80       standing traffic control. Whenever the kernel needs to send a packet to
81       an interface, it is enqueued to the qdisc configured  for  that  inter‐
82       face.  Immediately  afterwards, the kernel tries to get as many packets
83       as possible from the qdisc, for giving  them  to  the  network  adaptor
84       driver.
85
86       A  simple QDISC is the 'pfifo' one, which does no processing at all and
87       is a pure First In, First Out queue. It does however store traffic when
88       the network interface can't handle it momentarily.
89
90

CLASSES

92       Some qdiscs can contain classes, which contain further qdiscs - traffic
93       may then be enqueued in any of the inner qdiscs, which are  within  the
94       classes.   When the kernel tries to dequeue a packet from such a class‐
95       ful qdisc it can come from any of the classes. A qdisc may for  example
96       prioritize  certain  kinds of traffic by trying to dequeue from certain
97       classes before others.
98
99

FILTERS

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

CLASSLESS QDISCS

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

CONFIGURING CLASSLESS QDISCS

235       In the absence  of  classful  qdiscs,  classless  qdiscs  can  only  be
236       attached at the root of a device. Full syntax:
237
238       tc qdisc add dev DEV root QDISC QDISC-PARAMETERS
239
240       To remove, issue
241
242       tc qdisc del dev DEV root
243
244       The  pfifo_fast qdisc is the automatic default in the absence of a con‐
245       figured qdisc.
246
247

CLASSFUL QDISCS

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

THEORY OF OPERATION

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

NAMING

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

PARAMETERS

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

TC COMMANDS

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

MONITOR

498       The tc utility  can  monitor  events  generated  by  the kernel such as
499       adding/deleting qdiscs, filters or actions, or modifying existing ones.
500
501       The following command is available for monitor :
502
503       file   If the file option is given, the tc does not  listen  to  kernel
504              events,  but  opens  the  given file and dumps its contents. The
505              file has to be in binary format and contain netlink messages.
506
507

OPTIONS

509       -b, -b filename, -batch, -batch filename
510              read commands from provided file or standard  input  and  invoke
511              them.  First failure will cause termination of tc.
512
513
514       -force don't  terminate  tc on errors in batch mode.  If there were any
515              errors during execution of the commands, the application  return
516              code will be non zero.
517
518
519       -o, -oneline
520              output  each  record on a single line, replacing line feeds with
521              the '\' character. This is convenient when  you  want  to  count
522              records with wc(1) or to grep(1) the output.
523
524
525       -n, -net, -netns <NETNS>
526              switches  tc to the specified network namespace NETNS.  Actually
527              it just simplifies executing of:
528
529              ip netns exec NETNS tc [ OPTIONS ] OBJECT { COMMAND | help }
530
531              to
532
533              tc -n[etns] NETNS [ OPTIONS ] OBJECT { COMMAND | help }
534
535
536       -cf, -conf <FILENAME>
537              specifies path to the config file. This option is used  in  con‐
538              junction with other options (e.g.  -nm).
539
540
541       -t, -timestamp
542              When tc  monitor runs,  print timestamp before the event message
543              in format:
544                 Timestamp: <Day> <Month> <DD> <hh:mm:ss> <YYYY> <usecs> usec
545
546
547       -ts, -tshort
548              When tc monitor runs, prints short timestamp  before  the  event
549              message in format:
550                 [<YYYY>-<MM>-<DD>T<hh:mm:ss>.<ms>]
551
552

FORMAT

554       The show command has additional formatting options:
555
556
557       -s, -stats, -statistics
558              output more statistics about packet usage.
559
560
561       -d, -details
562              output more detailed information about rates and cell sizes.
563
564
565       -r, -raw
566              output raw hex values for handles.
567
568
569       -p, -pretty
570              for u32 filter, decode offset and mask values to equivalent fil‐
571              ter commands based on TCP/IP.  In JSON output, add whitespace to
572              improve readability.
573
574
575       -iec   print rates in IEC units (ie. 1K = 1024).
576
577
578       -g, -graph
579              shows  classes  as  ASCII graph. Prints generic stats info under
580              each class if -s option was specified. Classes can  be  filtered
581              only by dev option.
582
583
584        -color
585              Use color output.
586
587
588       -j, -json
589              Display results in JSON format.
590
591
592       -nm, -name
593              resolve  class  name from /etc/iproute2/tc_cls file or from file
594              specified by -cf option. This file is just a mapping of  classid
595              to class name:
596
597                 # Here is comment
598                 1:40   voip # Here is another comment
599                 1:50   web
600                 1:60   ftp
601                 1:2    home
602
603              tc  will  not  fail  if -nm was specified without -cf option but
604              /etc/iproute2/tc_cls file does not exist, which makes it  possi‐
605              ble to pass -nm option for creating tc alias.
606
607

EXAMPLES

609       tc -g class show dev eth0
610           Shows classes as ASCII graph on eth0 interface.
611
612       tc -g -s class show dev eth0
613           Shows classes as ASCII graph with stats info under each class.
614
615

HISTORY

617       tc was written by Alexey N. Kuznetsov and added in Linux 2.2.
618

SEE ALSO

620       tc-basic(8),   tc-bfifo(8),  tc-bpf(8),  tc-cbq(8),  tc-cgroup(8),  tc-
621       choke(8),  tc-codel(8),  tc-drr(8),   tc-ematch(8),   tc-flow(8),   tc-
622       flower(8),  tc-fq(8), tc-fq_codel(8), tc-fw(8), tc-hfsc(7), tc-hfsc(8),
623       tc-htb(8), tc-mqprio(8), tc-pfifo(8), tc-pfifo_fast(8), tc-red(8),  tc-
624       route(8),  tc-sfb(8),  tc-sfq(8), tc-stab(8), tc-tbf(8), tc-tcindex(8),
625       tc-u32(8),
626       User documentation at http://lartc.org/, but please  direct  bugreports
627       and patches to: <netdev@vger.kernel.org>
628
629

AUTHOR

631       Manpage maintained by bert hubert (ahu@ds9a.nl)
632
633
634
635iproute2                       16 December 2001                          TC(8)
Impressum