[LARTC] Managing downloads

Linux Advanced Routing and Traffic Control

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

 



This is a multi-part message in MIME format.

------=_NextPart_000_002F_01C1D0D4.F4777C40
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello,

thanks for the help I've received here, I think I've cracked my problem.  I
have a tiny (5MBit) satellite downlink to share between several thousand
clients, and I wanted to give higher paying clients more speed.

I tried WRR, but after three days meddling with kernels etc, gave up.  The
attached script uses CBQ to do the following:

Create classes for various speeds (512Kbit -> 8Kbit), and assign IP
addresses to each class

Create a default class, limited to 2Mbit, which everyone else will share
equally (SFQ)

I've tested it quite a bit, and it seems to work.  However, I really don't
know the details of tc etc, so it's possible that this is total rubbish.  If
it is, could someone point this out?

Also, does anyone know a good way of filtering by MAC address, rather than
by IP address?

Gavin

------=_NextPart_000_002F_01C1D0D4.F4777C40
Content-Type: application/octet-stream;
	name="dl-manage.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="dl-manage.sh"

#/bin/bash=0A=
#Q rules for internal interface - managing download (incoming) speed=0A=
=0A=
#Delete root qdisc=0A=
tc qdisc del dev eth1 root=0A=
#Add root qdisc=0A=
tc qdisc add dev eth1 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 =
cell 8=0A=
=0A=
#Classes: (One for each rate)=0A=
=0A=
#Add root class, 5Mbit=0A=
tc class add dev eth1 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate =
5Mbit weight 0.5Mbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 =
bounded=0A=
#Add 512Kbit class - for mail. Isolated, so always guaranteed bandwidth =
ie. other classess cannot borrow B/W=0A=
tc class add dev eth1 parent 1:1 classid 1:3 cbq bandwidth 100Mbit rate =
512Kbit weight 51.2Kbit prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000 =
isolated=0A=
#Add 254Kbit class=0A=
tc class add dev eth1 parent 1:1 classid 1:4 cbq bandwidth 100Mbit  rate =
256Kbit weight 25.6Kbit prio 5 allot 1514  cell 8 maxburst 20 avpkt 1000 =0A=
#Add 128Kbit class=0A=
tc class add dev eth1 parent 1:1 classid 1:5 cbq bandwidth 100Mbit  rate =
128Kbit weight 12.8Kbit prio 5 allot 1514  cell 8 maxburst 20 avpkt 1000=0A=
#Add 64Kbit class=0A=
tc class add dev eth1 parent 1:1 classid 1:6 cbq bandwidth 100Mbit  rate =
64Kbit weight 6.4Kbit prio 5 allot 1514  cell 8 maxburst 20 avpkt 1000 =0A=
#Add 32Kbit class=0A=
tc class add dev eth1 parent 1:1 classid 1:7 cbq bandwidth 100Mbit  rate =
32Kbit weight 3.2Kbit prio 5 allot 1514  cell 8 maxburst 20 avpkt 1000 =0A=
#Add 16Kbit class=0A=
tc class add dev eth1 parent 1:1 classid 1:8 cbq bandwidth 100Mbit  rate =
16Kbit weight 1.6Kbit prio 5 allot 1514  cell 8 maxburst 20 avpkt 1000 =0A=
#Add 8Kbit class=0A=
tc class add dev eth1 parent 1:1 classid 1:9 cbq bandwidth 100Mbit  rate =
8Kbit weight 0.8Kbit prio 5 allot 1514  cell 8 maxburst 20 avpkt 1000 =0A=
#Add 2Mbit class - default for everyone, bounded. Any address in this =
range not specified above shares what's here. =0A=
tc class add dev eth1 parent 1:1 classid 1:10 cbq bandwidth 100Mbit  =
rate 2Mbit weight 0.2Mbit prio 5 allot 1514  cell 8 maxburst 20 avpkt =
1000 bounded=0A=
=0A=
#Qdiscs: (One for each class)=0A=
=0A=
#Add qdisc for 512Kbit class=0A=
tc qdisc add dev eth1 parent 1:3 handle 30: sfq=0A=
#Add qdisc for 256Kbit class=0A=
tc qdisc add dev eth1 parent 1:4 handle 40: sfq=0A=
#Add qdisc for 128Kbit class=0A=
tc qdisc add dev eth1 parent 1:5 handle 50: sfq=0A=
#Add qdisc for 64Kbit class=0A=
tc qdisc add dev eth1 parent 1:6 handle 60: sfq=0A=
#Add qdisc for 32Kbit class=0A=
tc qdisc add dev eth1 parent 1:7 handle 70: sfq=0A=
#Add qdisc for 16Kbit class=0A=
tc qdisc add dev eth1 parent 1:8 handle 80: sfq=0A=
#Add qdisc for 8Kbit class=0A=
tc qdisc add dev eth1 parent 1:9 handle 90: sfq=0A=
#Add qdisc for 2Mbit class=0A=
tc qdisc add dev eth1 parent 1:10 handle 100: sfq=0A=
=0A=
#Filters: (Match an IP to a rate)=0A=
=0A=
=0A=
#Add filter: 192.168.230.1 at 512Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.1 flowid 1:3=0A=
#Add filter: 192.168.230.2 at 256Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.2 flowid 1:4=0A=
#Add filter: 192.168.230.3 at 128Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.3 flowid 1:5=0A=
#Add filter: 192.168.230.4 at 64Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.4 flowid 1:6=0A=
#Add filter: 192.168.230.5 at 32Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.5 flowid 1:7=0A=
#Add filter: 192.168.230.6 at 16Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.6 flowid 1:8=0A=
#Add filter: 192.168.230.7 at 8Kbit=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.7 flowid 1:9=0A=
=0A=
=0A=
#Add filter: catch all=0A=
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
192.168.230.0/24 flowid 1:10=0A=
=0A=
=0A=
exit 0=0A=

------=_NextPart_000_002F_01C1D0D4.F4777C40--



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