Re: HTB classifying

Linux Advanced Routing and Traffic Control

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

 



Hello Mpourtounis,

 : When i start downloading from node, its http taffic for examle is
 : really shaped at 500000. When i start downloading via sftp (port 22),
 : its sftp traffic is really shaped at 300000. But, if when there is an
 : http as well as an sftp session at the same time, total bandwidth is at
 : 800000.

You are missing one key piece in your understanding of HTB and that is the
difference between using "rate" and using "ceil".

 : /sbin/tc qdisc add  dev wlan0 root handle 1:0 htb r2q 100
 : /sbin/tc class add dev wlan0 parent 1: classid 1:10 htb rate 500000
 :
 : /sbin/tc class add dev wlan0 parent 1:10 classid 1:11 htb rate 300000
 : /sbin/tc filter add dev wlan0 parent 1:0 protocol ip prio 100 u32 \
 :         match ip src 192.168.2.224/32 \
 :         match ip sport 80 0xffff classid 1:11
 :
 : /sbin/tc class add dev wlan0 parent 1:10 classid 1:12 htb rate 500000
 :  /sbin/tc filter add dev wlan0 parent 1:0 protocol ip prio 100 u32 match \
 :          ip src 192.168.2.224/32 classid 1:12

You have a class structure which looks roughly like this:


  class 1:10, rate 500000 [ ceil 500000 ]
   |
   +-class 1:11, rate 300000 [ ceil 300000 ] (rate M)
    \
     class 1:12, rate 500000 [ ceil 500000 ] (rate L)

Because you have specified a rate in each leaf class (1:11 and 1:12), your
two leaf classes are getting the guaranteed 'rate'.  You have guaranteed
rate M, 300000 (units???) (seems to be 37500bps with my tc) to your class
1:11.  You have guaranteed rate L to your class 1:12.  HTB will dequeue
packets entering this class until rate without examining any other parent
class.  Because each class is getting its guaranteed rate, HTB is
effectively transmitting (dequeuing) packets at 800000 (300000 + 500000).

I believe you wish to do the following.  Note that I have used the same
ratios, but have eliminated some zeroes and changed the units, but simply
for readability.

  class 1:10, rate 500 kbps, ceil 500 kbps
   |
   +-class 1:11, rate 100 kbps, ceil 300 kbps
    \
     class 1:12, rate 400 kbps, ceil 500 kbps

Thes means that classes 1:11 and 1:12 can transmit up to rates 100 kbps
and 400 kbps respectively before HTB starts to calculate borrowing.  For
more on the borrowing model, see [0], [1] and [2].  The rule you are
unwittingly violating is this rule [3].

In short, since HTB will not check any rates or perform any shaping or
borrowing until rate is met (exceeded), you must make sure that the sum of
the rates of your leaf classes does not exceed the parent classes.

As a final note, if you wish to limit your total outgoing bandwidth to
only 500000 and let HTB help a bit with the borrowing, I would recommend
the following model:

  class 1:10, rate 500000, ceil 500000
   |
   +-class 1:11, rate 100000, ceil 300000
    \
     class 1:12, rate 200000, ceil 500000

Best of luck,

-Martin

  [0] http://luxik.cdi.cz/~devik/qos/htb/manual/userg.htm#hsharing
  [1] http://tldp.org/HOWTO/Traffic-Control-HOWTO/classful-qdiscs.html#qc-htb-borrowing
  [2] http://opalsoft.net/qos/DS-28.htm
  [3] http://www.docum.org/docum.org/faq/cache/13.html

P.S. Just a reminder that with the command line "tc", kbps means kilobytes
     per second.  If you want to talk about kilobits per second, use kbit.

-- 
Martin A. Brown --- SecurePipe, Inc. --- mabrown@xxxxxxxxxxxxxx

_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

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