bandwidth 1 over N

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Wed May 6 17:43:51 UTC 2009


On Wed, May 06, 2009 at 12:58:56PM -0400, teddy mills wrote:
> 10 computers are sharing a public interface eth0. (5mbits)
> I want all 10 computers to share this interface fairly. (qos)
>
> Assigned the 5mbits bandwidth 1 over N.
> Where N is number of computers that have a dhcp lease and are pingable.
> (otherwise do not give them bandwidth)
>
> ubuntu-server 8.10 router box
>
> eth0 connects to the public interface (5 mbits/sec)
> eth1 (NAT) dhcpcd connects to all 10 computers
>
> What are some ways this can be done ?

So if 5 computers are pingable you want 1mbit for each, even though 4
of the 5 don't currently want any bandwidth?

I think your algorithm is bad. :)

Now if you setup a queue for each one using tc and assign the same
priority to each and the same bandwidth, and set each to have a guarentted
bandwith of 1/10 of the total bandwidth, and full bandwidth as mxaimum,
it probably would actually do a fairly good job of giving each one an
even share, for however many currently want traffic.  Setting asside
some bandwidth for small packets at a higher priority tends to maek http
requests and ssh and such work better.

With shorewall I would do this:
tcdevices:
#INTERFACE	IN-BANDWITH	OUT-BANDWIDTH
eth0		5000kbit	5000kbit

tcclasses:
#INTERFACE	MARK    RATE    CEIL    PRIORITY        OPTIONS
eth0		1	full/10	full	1		
eth0		2	250kbit	full	2		default
eth0		11	250kbit	full	2
eth0		12	250kbit	full	2
eth0		13	250kbit	full	2
eth0		14	250kbit	full	2
eth0		15	250kbit	full	2
eth0		16	250kbit	full	2
eth0		17	250kbit	full	2
eth0		18	250kbit	full	2
eth0		19	250kbit	full	2
eth0		20	250kbit	full	2

tcrules:
#MARK	SOURCE		DEST	PROTO	DEST	SOURCE	USER	TEST	LENGTH	TOS
#				PORT(S)	PORT(S)
11	192.168.1.101	-	all	-	-	-	-	-
12	192.168.1.102	-	all	-	-	-	-	-
13	192.168.1.103	-	all	-	-	-	-	-
14	192.168.1.104	-	all	-	-	-	-	-
15	192.168.1.105	-	all	-	-	-	-	-
16	192.168.1.106	-	all	-	-	-	-	-
17	192.168.1.107	-	all	-	-	-	-	-
18	192.168.1.108	-	all	-	-	-	-	-
19	192.168.1.109	-	all	-	-	-	-	-
20	192.168.1.110	-	all	-	-	-	-	-
1	-		-	all	-	-	-	-	1:100



This means anything smaller than 100 bytes will be given top priority
and have at least 1/10 of the bandwidth.  You could decide the make the
small packet have a maximum of less than full, but lots of small packets
are quite a rare event so probably not needed.

Each machine from 192.168.1.101 to .110 each have a class with at least
250kbit and at most all the bandwidth, but all at identical priority so
that tc should share any leftover bandwidth equally between them.
overall each machine with traffic should get an even share.

The default class (2 in this case) is for anyone not in your list of
10 IPs.  So anyone you didn't add a rule for will all end up sharing
one machine's worth of bandwith.

Doing this without shorewall is a huge pain in the ass and I wouldn't
want to do it.

On top of the above you do at least have to add the interfaces, zones
and policy tables to shorewall or it won't start.  It is quite easy
really.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list