[CentOS] CBQ and/or HTB help needed

Maciej Żenczykowski maze at cela.pl
Sun Aug 28 16:59:02 UTC 2005


OK, here's a very simple (working!) example script which simply limits 
upload to 15 Mbps.

htb.sh:

#!/bin/bash
#Some note from HTB documentation:
#Usage: ... qdisc add ... htb [default N] [r2q N]
# default  minor id of class to which unclassified packets are sent {0}
# r2q      DRR quantums are computed as rate in Bps/r2q {10}
# debug    string of 16 numbers each 0-3 {0}
#  ... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]
#                        [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
# rate     rate allocated to this class (class can still borrow)
# burst    max bytes burst which can be accumulated during idle period 
{computed}
# ceil     definite upper class rate (no borrows) {rate}
# cburst   burst but for ceil {computed}
# mtu      max packet size we create rate map for {1600}
# prio     priority of leaf; lower are served first {0}
# quantum  how much bytes to serve from leaf at once {use r2q}

set() {
   for i in 0; do
#   MAX=16000kbit
#   MAX=$[15*1024]kbit == 15360kbit < 16000 kbit
     MAX=15mbit
     tc qdisc del dev eth$i root
     tc qdisc add dev eth$i root handle 1:0 htb default 1 r2q 100
     tc class add dev eth$i parent 1:0 classid 1:1 htb rate $MAX
#   tc class add dev eth$i parent 1:0 classid 1:1 htb \
#     rate 15mbit burst $[1514 mtu 1514 quantum 1514
   done
}

show() {
   for i in 0 1; do
     tc -s qdisc list dev eth$i; tc -s class list dev eth$i
   done
}

$1


Call as ./htb.sh set or ./htb.sh show

Limits output on eth0 to 15mbit on set and shows settings on eth0 and eth1 
on show.

If you need a full fledged script (4*n+20 rules from a server doing HTB 
per user in an apartment LAN) than mail me...

Cheers,
MaZe.



On Sat, 27 Aug 2005, Joe Klemmer wrote:

> 	Ok, this has been kicking my @$$ for weeks.  I'm trying to get some 
> kind of bandwidth shaping working on my server.  I need to throttle ftp down 
> so as not to suck up all the available bandwidth.  I had cbq working on the 
> old server (an ancient RH 6.2 box) so I figured I'd just move the config over 
> and get cbq.init from sf.net and it should work. Unfortunately it doesn't. 
> At least it doesn't work to the extent that no throttling of ftp is being 
> done.  So next I thought I'd try htb (as someone here mentioned it as an 
> alternative).  After printing out the entire section on bandwidth management 
> from the lartc documentation I still can't seem to get anything working.  I 
> think I'm at the "forest/trees" point where I've been banging my head against 
> this so much I'm missing something obvious.
>
> 	So, if anyone out there could lend a hand (or more precisely a pair 
> of eyes) I would be greatly appreciative.  To save list bandwidth, send 
> replies to me and once I get things working I'll post a summery, with full 
> credit attribution, to the list.
>
> Thanks in advance,
> Joe
>
>



More information about the CentOS mailing list