[LARTC] equal bandwith using HTB

Linux Advanced Routing and Traffic Control

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

 



I'd like to set up HTB to share a bandwith equally between machines.
This is my situation:

.                                  +-- Clients (1.2.3.140-147)
.                                [eth1]
Internet -- [comx0] router [br0] --+
.                                [eth0]
.                                  +-- Servers (currently one:1.2.3.135)

br0 is 1.2.3.130 and the net is 1.2.3.128/26.

Internet speed is 512kbit. Clients are connected via a wireless AP
connected to eth1. Servers are connected via an ethernet switch
connected to eth0. We need br0 only because of the phisical topology
(impossible to connect the AP to the same switch used for the servers).

I would like to give 20% rate to the Servers, and 80% rate to the
Clients. I'd like to be sure to share Clients bandwoith equally between
each client. Communication between Clients and Servers should be limited
to 4mbit.

It works more or less, but when a user starts several tcp downloads, he
gets almost all of the bandwith. Of course rates are always respected,
but the remaining not shared equally.

I've tried the following:
DEV=br0
BANDWITH=480
LOCALBW=4mbit

tc qdisc del dev $DEV root

tc qdisc add dev $DEV root handle 1: htb default 1 r2q 1

tc class add dev $DEV parent 1: classid 1:1 htb rate ${BANDWITH}kbit
prio 2 burst 64k cburst 0k
tc class add dev $DEV parent 1: classid 1:2 htb rate ${LOCALBW} prio 1
burst 128k

USERS=8
USERBW=$[8*${BANDWITH}/10]
SERVERBW=$[2*${BANDWITH}/10]
PERUSERBW=$[$USERBW/$USERS]

tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${USERBW}kbit
ceil ${USERBW}kbit prio 4 burst 4k cburst 0k
tc class add dev $DEV parent 1:1 classid 1:11 htb rate ${SERVERBW}kbit
ceil ${BANDWITH}kbit prio 3 burst 32k cburst 0k

declare -i NUM=${USERS}
while [ $NUM -ge 1 ]; do
   tc class add dev $DEV parent 1:10 classid 1:$[139+$NUM] htb rate
${PERUSERBW}kbit ceil ${USERBW}kbit prio 4 burst 10k cburst 10k
   tc filter add dev $DEV parent 1: protocol ip prio 4 u32 match ip dst
1.2.3.$[139+$NUM] flowid 1:$[139+$NUM]
   NUM=$NUM-1
done

tc filter add dev $DEV parent 1: protocol ip prio 1 u32 \
        match ip src 1.2.3.128/26 \
        match ip dst 1.2.3.128/26 flowid 1:2
tc filter add dev $DEV parent 1: protocol ip prio 3 u32 \
        match ip dst 1.2.3.135 flowid 1:11
tc filter add dev $DEV parent 1: protocol ip prio 5 u32 \
       match ip dst 0.0.0.0/0 flowid 1:10

Best regards,
Slapic
-- 
Pilatus-Comp Ltd. HUNGARY * The Linux Expert * pilatuscomp@linux.co.hu
http://www.linux.co.hu * Phone: +36-1-2481816 * Fax: +36-1-2481817





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