Linux TC Speed limit

Source: Internet
Author: User

TC is a Linux-brought module that can be used to control the speed of the network.

Common command formats


TC [Qdisc/class/filter] [add/del/replace] Dev Nic name other parameters


The TC speed limit is primarily the sending of packets to different types of queues, which are then controlled by the queue. The speed limit queue mainly consists of two kinds: one is the non-class queue, which includes Pfifo_fast (FIFO), TBF (token bucket filter), SFQ (random fair queue), ID (forward random packet loss), and so on. The other is the classification queue, in which the concept of class (Class) and filter (filter) is drawn.

The direct relationship between the three Qdisc,class,filter is as follows:

Every time you create a class, there is a default Qdisc, which qdisc on the class as a child node. Filter hangs on the queue, and the primary decision is to let the packet pass to the child node class.


Suppose you have the following requirements:

The WEB server's traffic control is 5MBPS,SMTP traffic control on 3Mbps. And the two should not exceed 6Mbps, allowing the borrowing of bandwidth between each other.


  #tc  qdisc add dev eth0 root handle 1:0 cbq bandwidth  100mbit avpkt 1000 cell 8    #tc  class add dev eth0  parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate 6Mbit  weight      0.6mbit prio 8 allot 1514 cell 8  maxburst 20 avpkt 1000 bounded      This section is set by convention to  1:0,  and binding class  1:1.  that means the entire bandwidth cannot exceed  6Mbps.    #tc  class add dev eth0  parent 1:1 classid 1:3 cbq bandwidth 100Mbit rate 5Mbit  weight     0.5mbit prio 5 allot 1514 cell 8  maxburst 20 avpkt 1000    #tc  class add dev eth0 parent  1:1 classid 1:4 cbq bandwidth 100mbit rate 3mbit weight     0.3mbit  prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000       set up  2  classes  .  Notice how we adjust the  weight  parameters according to the bandwidth  .  two classes are not configured as "bounded",   But they are all connected    to the class  1:1   ,  and  1:1  set the "bounded" .  so the total bandwidth of two classes will not exceed   6mbps.  Don't forget  ,  the main number of the same  CBQ  sub    class must be the same as the  CBQ  own number  !     #tc  QDISC ADD DEV ETH0 PARENT 1:3 HANDLE 30: SFQ     #tc  qdisc add dev eth0 parent 1:4 handle 40:  sfq      By default  ,  two classes have a  FIFO  queue rule  .  But let's change it to  SFQ.   Queue  ,  to ensure that each traffic is treated fairly  .    #tc  filter add dev eth0  Parent 1:0 protocol ip prio 1 u32 match ip sport 80 0xffff flowid      1:3    #tc  filter add dev eth0 parent 1:0  protocol ip prio 1 u32 match ip sport 25 0xffff flowid      1:4


This article is from the "12117048" blog, please be sure to keep this source http://12127048.blog.51cto.com/12117048/1858148

Linux TC Speed limit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.