All of lore.kernel.org
 help / color / mirror / Atom feed
* [LARTC] Managing downloads
@ 2002-03-21  9:35 Gavin
  2002-03-22 10:59 ` Sebastian 'spax' Pape
  0 siblings, 1 reply; 2+ messages in thread
From: Gavin @ 2002-03-21  9:35 UTC (permalink / raw)
  To: lartc

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]

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

[-- Attachment #2: dl-manage.sh --]
[-- Type: application/octet-stream, Size: 3748 bytes --]

#/bin/bash
#Q rules for internal interface - managing download (incoming) speed

#Delete root qdisc
tc qdisc del dev eth1 root
#Add root qdisc
tc qdisc add dev eth1 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 cell 8

#Classes: (One for each rate)

#Add root class, 5Mbit
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
#Add 512Kbit class - for mail. Isolated, so always guaranteed bandwidth ie. other classess cannot borrow B/W
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
#Add 254Kbit class
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 
#Add 128Kbit class
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
#Add 64Kbit class
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 
#Add 32Kbit class
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 
#Add 16Kbit class
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 
#Add 8Kbit class
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 
#Add 2Mbit class - default for everyone, bounded. Any address in this range not specified above shares what's here. 
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

#Qdiscs: (One for each class)

#Add qdisc for 512Kbit class
tc qdisc add dev eth1 parent 1:3 handle 30: sfq
#Add qdisc for 256Kbit class
tc qdisc add dev eth1 parent 1:4 handle 40: sfq
#Add qdisc for 128Kbit class
tc qdisc add dev eth1 parent 1:5 handle 50: sfq
#Add qdisc for 64Kbit class
tc qdisc add dev eth1 parent 1:6 handle 60: sfq
#Add qdisc for 32Kbit class
tc qdisc add dev eth1 parent 1:7 handle 70: sfq
#Add qdisc for 16Kbit class
tc qdisc add dev eth1 parent 1:8 handle 80: sfq
#Add qdisc for 8Kbit class
tc qdisc add dev eth1 parent 1:9 handle 90: sfq
#Add qdisc for 2Mbit class
tc qdisc add dev eth1 parent 1:10 handle 100: sfq

#Filters: (Match an IP to a rate)


#Add filter: 192.168.230.1 at 512Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.1 flowid 1:3
#Add filter: 192.168.230.2 at 256Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.2 flowid 1:4
#Add filter: 192.168.230.3 at 128Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.3 flowid 1:5
#Add filter: 192.168.230.4 at 64Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.4 flowid 1:6
#Add filter: 192.168.230.5 at 32Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.5 flowid 1:7
#Add filter: 192.168.230.6 at 16Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.6 flowid 1:8
#Add filter: 192.168.230.7 at 8Kbit
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.7 flowid 1:9


#Add filter: catch all
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.230.0/24 flowid 1:10


exit 0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-03-22 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-21  9:35 [LARTC] Managing downloads Gavin
2002-03-22 10:59 ` Sebastian 'spax' Pape

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.