Re: limiting download speed
> Hello.
>
> My home computer (running Debian sid, kernel 2.4) is connected to a LAN
> and runs Apache to serve web pages and files to other computers in the
> LAN.
>
> Recently admins of the LAN told me to limit total download speed from my
> computer over http. Than means, if one person is downloading from my
> computer, he should get at most N kbps, but if e.g. 3 people are
> downloading from my computer, each one should get at most N/3 kbps.
>
> What is the correct way to do that? Although I am a unix admin, I have
> never solved this before. Seems that I need to configure iproute? Or there
> is a better way? I want to limit only outgoing HTTP traffic; if at the
> same time I am uploading a file to some other computer, there should be no
> local speed limit.
>
> Could someone please help me to do what LAN admins want, or point to
> appropriate documentation?
Well, here is how this may be done using iproute:
dev="$1"
cmd="$2"
if [ $# -ne 2 -o "`echo $dev | cut -c1-3`" != "eth" -o \
\( "$cmd" != "on" -a "$cmd" != "off" \) ]; then
echo "usage bandwidth-limit device [on|off]" >&2
exit 1
fi
if [ $cmd = on ]; then
tc qdisc add dev "$dev" root handle 1:0 cbq bandwidth 10Mbit avpkt 1000
tc class add dev "$dev" parent 1:0 classid 1:1 cbq \
bandwidth 10Mbit rate 10MBit prio 1 cell 8 maxburst 20 avpkt 1000 allot
1514
tc class add dev "$dev" parent 1:0 classid 1:2 cbq bounded \
bandwidth 10Mbit rate 64kbps prio 2 cell 8 maxburst 20 avpkt 1000 allot
1514
tc qdisc add dev "$dev" parent 1:1 handle 11: sfq
tc qdisc add dev "$dev" parent 1:2 handle 12: sfq
tc filter add dev "$dev" parent 1:0 prio 1 \
protocol ip u32 match ip sport 80 0xffff flowid 1:2
elif [ $cmd = off ]; then
tc qdisc del dev "$dev" root handle 1:0 cbq bandwidth 10Mbit avpkt 1000
fi
n
Reply to: