Re: Can i attach another qdisc under classes or root qdisc?

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings,

 : now, i'm learning and try to read a lot of article about tc 
 : command in linux for setting traffic shaper. but i'm doubt about 
 : In the theory about tc command ... In general, we define class 
 : under root qdisc but Is it can be possible ???? If we define 
 : another qdisc under root qdisc, Can i do it? because i have just 
 : read tc command syntax and i found this point ...

[ snip mangled "tc qdisc help" output ]

 : from above syntax at [handle][root /ingress/ ****parent CLASSID] 
 : Is "parent CLASSID" mean we can define qdisc under class???? so 
 : this is my assumption about that. and Could you advise me about 
 : Is it can do for real????

If I understand your question correctly, the answer is "yes".  It is 
possible to have nested qdiscs.  Note that you can nest qdiscs if 
you are using a classful qdisc [0].  See also my list at the bottom 
of this message.

 : //first .. define root qdisc
 :
 : tc qdisc add dev eth0 root handle 1: fifo

Bzzzt!  Sadly, you can't do this.  A fifo qdisc is a classless 
qdisc, meaning that it cannot have any children.  (Poor barren 
thing!)

 : //second ... define class under root qdisc but algorithm's not same like root qdisc algorithm
 :
 : tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
 : tc class add dev eth0 parent 1: classid 1:2 hfsc rate 100kbps ceil 100kbps

Well, you can't quite mix and match classes without having a parent 
qdisc of the type you want.  An HTB parent qdisc can have any number 
of children arranged in a tree structure below the parent.

Similarly, an HFSC class structure needs to attach to an HFSC qdisc 
itself.  Note, though, you cannot simply change the class name from 
htb to hfsc and supply the same parameters.  HTB uses the rate and 
ceil parameters, but HFSC uses different parameters (rt, sc and ul).

 : //later attach qdisc to those classes
 :
 : tc qdisc add dev eth0 parent 1:1 classid 10:11 htb rate 100kbps ceil 100kbps
 : tc qdisc add dev eth0 parent 1:2 classid 10:21 hfsc rate 100kbps ceil 100kbps

OK, now, let's pretend that you have a classful qdisc (e.g. HTB) 
with two classes, 1:1 and 1:2, AND that you have a good reason for 
adding a nested qdisc to one of these classes.  If that were the 
case, then you could add the qdiscs to the parent classes in the 
following fashion:

  # -- create a new qdisc, attached inside an existing class
  #    hierarchy below class 1:1
  #
  $qdisc_add parent  1:1 handle  10:0 htb
  #
  # -- add a class to our newly created qdisc, and set the
  #    rate and ceil parameters
  #
  $class_add parent 10:0 classid 10:1 htb rate 100kbps ceil 100kbps

Note, that you'd still need filters.

If I were you, I'd review the documentation for both HTB and HFSC 
after understanding the entire Linux traffic control model.  Here's 
a crash course, starting at the root qdisc:

  1. The qdisc can be 
     - classless (e.g., FIFO, SFQ, ESFQ, TBF, GRED)
     - classful (e.g., HTB, HFSC, CBQ, PRIO)
  2. If the qdisc is classful, keep reading.  If the root qdisc is 
     classless, stop here.
  3. You may add classes to your classful qdisc.  If your qdisc is 
     HTB, you can only add HTB classes.  If your qdisc is CBQ, you 
     can only add CBQ classes.  If your qdisc is HFSC...
  4. Now, you may attach a brand-new classful or classless qdisc to 
     one of your existing classes.  Repeat from step 1 for each new 
     qdisc.
  5. You may add filters to any of your classes (best starting 
     behaviour is to add them to 1:0)

Very complex hierarchies are quite possible, even if not always 
understandable or advisable.

Best of luck,

-Martin

 [0] http://tldp.org/HOWTO/Traffic-Control-HOWTO/classful-qdiscs.html

     (N.B., this documentation was written without any reference to 
      HFSC, a newer classful qdisc.  You may also use HFSC with 
      child qdiscs.)

-- 
Martin A. Brown
http://linux-ip.net/
_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux