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
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Sat, Aug 27, 2005 at 09:38:11AM -0400, 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.
Why don't you try proftpd ? It has integrated bandwidth control.
Not perfect, but then again, unless you are setting up a separated machine to run bandwidth control, this is as good as it gets.
[]s
- -- Rodrigo Barbosa rodrigob@suespammers.org "Quid quid Latine dictum sit, altum viditur" "Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)
Rodrigo Barbosa wrote:
Why don't you try proftpd ? It has integrated bandwidth control.
Not perfect, but then again, unless you are setting up a separated machine to run bandwidth control, this is as good as it gets.
For a number of reasons, vsftpd is the only choice for me. vsftpd also has some limiting capabilities built-in and, as I understand it, if it's run from xinetd you can do it as well. But this is not the configuration I need here. But thanks for the reply.
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
Maciej Żenczykowski wrote:
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
Thanks. Now how would I make this script limit outbound ftp to a total of 96K?
I'm not sure how to determine whether a given network packet is an FTP packet or not...
the ftp-data connection has no strictly specified TCP ports - it can be a normal TCP connection between a random port on your computer and a random port on someone else. (most ftpd's do not use the ftpdata tcp port for anything instead using unpriviledged random high port numbers)
... MaZe.
On Wed, 2005-08-31 at 06:07 +0200, Maciej Żenczykowski wrote:
I'm not sure how to determine whether a given network packet is an FTP packet or not...
the ftp-data connection has no strictly specified TCP ports - it can be a normal TCP connection between a random port on your computer and a random port on someone else. (most ftpd's do not use the ftpdata tcp port for anything instead using unpriviledged random high port numbers)
You can adjust this with vsftpd and cbq (and htb I'm sure) so that's not an issue. The problem I am having is that scripts which used to work on the old system, and _should_ work fine now just don't do any limiting. It's like they're not even there.
I'm willing to give root access to my box to anyone who thinks they might be able to fix this.