LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author] [stats]
  From: Alan Kennington <akenning@topology.org>
  To  : LinuxSA <linuxsa@linuxsa.org.au>
  Date: Wed, 6 Jun 2001 20:56:30 +0930

Re: Setting Quota on Internet Traffic.

On Wed, Jun 06, 2001 at 07:13:43PM +0930, Craig Keogh wrote:
> 
> Soon, I hope to get broadband internet. I plan to use a linux host as my
> internet gateway and host a small local area network of personal computers.
> 
> Recently, telstra have imposed a 3 GB limit per month on broadband
> connections.
> How can I impose a quota on 3 users of the internet, each 1 GB ?
> 
> Quota has to include all traffic, http, ftp, icq and online games.
> 
> Squid has been suggested to me, but from the documentation I have found no
> reference to setting a hard quota.
> 

Craig,

There's a little problem with this.
What do you really want the quota system to do?
If someone gets to their quota in 3 weeks of the calendar
month, do you want their bit-rate to be dropped to 0 kbits/sec
until midnight on the last day of the month?

First you should specify what the quota system should do exactly.
Here's a reaonsable spec:

The aggregate of the 3 users is to be given "credit" for 
1 GByte / (30 * 24 * 3600 seconds) = 3086 bits/second.

That's not much.
But if accumulated over time, it mounts up to your 1 GB, obviously.

Now you need some subsystem to keep track of usage and enforce
the limit. But if they use very little for 3 weeks, do you want them
to be able to use 1 GB in the last week of the month?

The usual answer to these questions if to use token buckets.
With such a system, users are allowed to accumulate credit
upt to a limit.
So suppose you allow credit to be accumulated for a whole day.
That's credit for about 33 MBytes.
So you need a token bucket with
credit rate = 3 kbits/sec
bucket size = 33 MBytes.

To enforce this, use the "tc" command.
Here's a manual for iproute2+tc:
http://snafu.freedom.org/linux2.2/iproute-notes.html
And here's the section for "tc":
http://snafu.freedom.org/linux2.2/iproute-notes.html#syntc

I think you need something like 

tc qdisc tbf ....

There's more to it than that. You have to read the manuals.

Cheers,
Alan Kennington.

--------------------------------------------------------------------
    name: Dr. Alan Kennington
  e-mail: akenning@topology.org
 website: http://www.topology.org/
    city: Adelaide, South Australia
  coords: 34.88051 S, 138.59334 E
timezone: UTC+0930 http://www.topology.org/timezone.html
 pgp-key: http://www.topology.org/key_ak2.asc

-- 
LinuxSA WWW: http://www.linuxsa.org.au/  IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
  mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject


Index: [thread] [date] [subject] [author] [stats]
Return to the LinuxSA Mailing List Information Page