Help with shaping incoming bandwith + NAT
Hello there. I would like some help with getting bandwith shaping to work, I'm sure that my questions are not that bright but I haven't been able to find any clues anywhere else. I have a Linux box ('server') acting as a NAT/firewall which is connected to the net (via eth1) with a 128 Kbps cable modem. I also have another 4 networked computers which are connected to the server via eth0. I would like to shape the *incoming* network bandwidth so that all of the computers have a minimum incoming throughput and are able to borrow unused bandwidth (so HTB seemed like a first pick choice). The problem here is that I can't seem to get it 100 % straight. My most successful attempt has been setting up a htb queue as root in eth1, something like this:
8<----------------8<----------------8<----------------8<----------------
ADD="tc class add dev eth0"
MAXRATE=128kbit
SHARERATE=28kbit
BURST=2k
ROOT_HANDLE=1
## root qdisc
tc qdisc add dev eth0 root handle $ROOT_HANDLE: htb default 99
## main node
$ADD parent $ROOT_HANDLE: classid $ROOT_HANDLE:1 htb rate $MAXRATE ceil $MAXRATE burst $BURST
## children
POLICY="htb rate $SHARERATE ceil $MAXRATE burst $BURST"
$ADD parent $ROOT_HANDLE:1 classid $ROOT_HANDLE:17 $POLICY $ADD parent $ROOT_HANDLE:1 classid $ROOT_HANDLE:11 $POLICY $ADD parent $ROOT_HANDLE:1 classid $ROOT_HANDLE:12 $POLICY $ADD parent $ROOT_HANDLE:1 classid $ROOT_HANDLE:13 $POLICY
## default node
$ADD parent $ROOT_HANDLE:1 classid $ROOT_HANDLE:99 htb rate 1kbps ceil $MAXRATE burst $BURST
## secondary node
$ADD parent $ROOT_HANDLE: classid $ROOT_HANDLE:2 htb rate 11mbit
8<----------------8<----------------8<----------------8<----------------
and the adequate filters (the traffic which goes to the internal network PCs is sent to :11, :12, :13 or :17, according to the destination IP, and the traffic from the server to the internal network is sent to :2 so that it is not limited). The filters seem to be working fine.
The problem here is that, theoretically, each computer in the network should be able to claim 28 kbps (= about 3.5 kbyte/s) for itself no matter how busy the link is. However, this just won't happen. The script *seems* to have a positive effect, so that I can surf the net somewhat faster while my pal is massively downloading files, but the minimum bandwidth is not enforced (not even remotely!). For instance, now I know that another computer in the network is downloading from a very fast site (my ISP internal news server). I begin downloading from kernel.org the latest source, divide the download in 10 simultaneous pieces, and withing 10 seconds the bandwidth is all mine (the d/l speed in the other computer is about .5 kbyte/s). Theoretically, it should get at least its assigned 3.5 kbyte/s, and, furthermore, the load should be balanced so that we have a rate of about 7.5 kbyte/s (the total bandwidth is 16 kbyte/s) for each of the computers.
I would like to know what am I doing wrong. Would switching to CBQ or any other queuing discipline be an option? I have experimented with the ingress qdisc, but as it doesn't seem possible to attach queues to that qdisc it doesn't work the way I want it to. I'm running 2.4.18 with the HTB patch applied and the tc binary found in the HTB homepage.
Thanx in advance :)
PS: If you can, please CC your reply to [email protected]. I'm subscribed to the 'digest' list so if you don't I won't be able to read your reply 'til tomorrow ;)
Signature · 15 lines
José Manuel López-Cepero - SiGMA - [email protected] RedHatLinux7.1 --- "¿Sabes una cosa que me hace mucha ilusión que me hayas regalado, pero que a la vez me da mucho miedo? Tu inocencia." -- José Manuel López-Cepero - SiGMA - [email protected] RedHatLinux7.1 --- "¿Sabes una cosa que me hace mucha ilusión que me hayas regalado, pero que a la vez me da mucho miedo? Tu inocencia." _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/