waix.ipac :: WAIX ip accounting
waix.ipac is a set of tools for use on linux routers
to track volume usage for iiNet ADSL accounts
and other ISP users with free WAIX traffic.
It differentiates between peak quota, offpeak quota and WAIX traffic.
Originally implemented for Perth bliink users, it can be modified for
bliink users in other states.
Background and Overview
For a number of years, I was stuck with a 31.2k dialup RIM connection.
However, after moving house several years ago, I got ADSL connected.
While on dialup, I wasn't very concerned about data volume,
although my Smoothwall box
was monitoring the total data volume in and out of my modem, using
ipac-ng.
Once I got an ADSL connection, I had to monitor my data volume, so I'd know when
I would reach my quota (and hence be shaped to 75k).
iiNet's Volume Graphs
show the data, broken down into peak quota, bliinktime quota and bliinkzone.
The iiNet Usage Analyser
application provides an alternative way to view iiNet's volume usage information,
using the data downloaded from iiNet's web server.
I wanted a server-based solution that would monitor my traffic volume in real time, with
more flexible reporting and graphing capabilities.
I had already been using ipac-ng on my linux router
to monitor total traffic volume in and out of each interface, and decided to
implement an ip accounting solution for iiNet traffic using ipac-ng.
waix.ipac is designed to be run on a linux router
that is being used to route all data on your internet connection, thus allowing it to monitor
the bandwidth usage of this traffic as it passes through the linux router.
Note that this initial release of waix.ipac only provides graphing capabilites.
Numerical reporting can be achieved using standard ipac-ng reporting functionality.
Definitions
The following naming conventions are used on this page:
peak quota
|
traffic from non-bliinkzone sources during peak time (7am-12am)
|
bliinktime quota
|
traffic from non-bliinkzone sources during off-peak time (12am-7am)
|
bliinkzone
|
traffic from WAIX sources
|
Depending on which bliink account you have, you are assigned a peak download quota,
and a bliinktime download quota.
If either of these quotas is exceeded in a any month (based on
your anniversary date), then your traffic
is shaped
to 72k, until your next anniversary date.
Refer to iiNet's
bliinkfaq,
what is bliinkzone,
and
what is bliinktime
pages for more details.
Screenshots
Graphs of inbound and outbound traffic are generated, with the inbound
peak quota traffic being differentiated from the bliinktime quota traffic
and bliinkzone traffic.
sample daily graph showing inbound and outbound traffic
(click for full-size image)
Note that inbound traffic is shown as positive traffic on the graph,
and outbound traffic is shown as negative traffic.
This allows both incoming and outgoing traffic to be easily shown on the same axis,
and still be very readable.
Requirements
For performing ip accounting, you'll need:
- a linux box
- a working installation of perl
- a working installation of ipac-ng
- iiNet
bliink ADSL account (or an account with another ISP offering free WAIX traffic)
- the waix.ipac tarball (see the "Downloads" section below)
To generate graphs of your usage, you'll also need:
- a working installation of RRDTool 1.2.x, including the shared RRD perl module
- a working installation of apache
ChangeLog
The changelog for waix.ipac is available
here.
Downloads
waix.ipac-0.5.tar.gz
- version 0.5 (24 August 2009)
waix.ipac-0.4.tar.gz
- version 0.4 (14 April 2006)
waix.ipac-0.3.tar.gz
- version 0.3 (27 November 2004)
waix.ipac-0.2.tar.gz
- version 0.2 (19 January 2004)
waix.ipac-0.1.tar.gz
- version 0.1 (15 January 2004)
index.cgi - page for viewing graphs (rename to
index.cgi)
Installation and Configuration
Download the waix.ipac tarball shown above.
SCP the tarball into the /tmp directory on your linux box,
and from a command prompt, run the following commands to un-tar it:
cd /usr/local
tar zxvf /tmp/waix.ipac-0.5.tar.gz
Edit /usr/local/waix.ipac/fetchwaix.pl and
change the value of $iface so that it's
specifying the interface through which your linux router connects to the internet.
If you run a PPPoE or PPPoA client on your linux router, or are on a
dialup connection, you'll need to change it to ppp0.
I have a DLink DSL-300+ modem, which is connected to eth1
on my linux router, so my file has:
# define internet-connected interface
my $iface="eth1";
If you want/need any additional ipac-ng rules, specify them in
/usr/local/waix.ipac/rules.head
Any existing rules you may already have defined in your existing rules file
should be transferred to rules.head.
Failure to do so will result in all your existing rules being lost.
Note that you'll probably want to modify the ipac-ng rules defined in
/usr/local/waix.ipac/rules.head, and the corresponding lines
in the ParseIpac function in
/usr/local/waix.ipac/makegraphs.pl.
I run waix.ipac on a linux router which is behind my
Smoothwall box, and the
Smoothwall box is connected to my
DLink DSL-300G GenII ADSL modem.
I've defined some additional rules to allow me to correct the internet traffic totals
by subtracting data to/from my Smoothwall box and to/from my ADSL modem.
Note that the fetchwaix.pl script assumes the following
rules configuration in your /etc/ipac-ng/ipac.conf:
rules file = /etc/ipac-ng/rules.conf
If your rules file has a different name, or is in a different location,
you'll need to update the value of $rules
in fetchwaix.pl accordingly.
The script used to compress the subnets requires the NetAddr::IP
and Net::CIDR Perl modules.
To download and install these modules on your linux box, just run the following from
a command prompt, and follow the prompts:
perl -MCPAN -e 'install NetAddr::IP'
perl -MCPAN -e 'install Net::CIDR'
To manually update the ipac rules with the WAIX network addresses, just run
the following script:
/usr/local/waix.ipac/fetchwaix.pl
Rather than having to do this manually,
we'll get the linux box to automatically do it once a day at 9pm (as the list of WAIX
subnets is updated daily at 8pm).
Edit /etc/crontab, and add the following:
# update ipac rules with waix subnet list, daily at at 9pm
00 21 * * * root /usr/local/waix.ipac/fetchwaix.pl >& /dev/null
The makegraphs.pl script needs to be scheduled to run
every 5 minutes, to retrieve ipacsum data, parse it, store it in an RRD database,
and create graphs of the resulting data over the last day, week and month.
Edit /usr/local/waix.ipac/makegraphs, and adjust
any of the parameters defined at the top of the script to suit your
configuration.
In particular, you'll probably want to adjust the
limits defined for the y axis of the graph to suit the speed of your internet
connection:
my $inbound = 60;
my $outbound = 20;
This default configuration specifies a maximum of 20 kbytes/sec for outbound traffic,
and a maximum of 60 kbytes/sec for inbound traffic. These limits are suitable
for a 512/128 kbps internet connection, so adjust them to suit the speeds of your link.
The default configuration in makegraphs.pl is to
treat any traffic between midnight and 8am as offpeak traffic, and any
traffic from 8am to midnight as peak traffic.
If your ISP uses different times, you'll need to modify the time comparisons
in the ParseIpac function.
Due to the method of data collection, running this script manually from the command
prompt is likely to cause inconsistencies in your data.
Note that makegraphs.pl runs fetchipac,
so if you currently have fetchipac being run from
/etc/crontab, remove it now.
Create an output directory for the resulting RRDTool graphs:
mkdir /var/www/html/waix.ipac
Configure cron to run the script every 5 minutes by adding
the following to /etc/crontab:
# update ipac data, build rrdtool graphs
*/5 * * * * root /usr/local/waix.ipac/makegraphs.pl > /dev/null
This script will update the traffic graphs every 5 minutes, with the resulting
graphs being created in /var/www/html/waix.ipac/.
Setting up a webpage to view the graphs is left as an
exercise for the reader.
Now that you're monitoring all your inbound and outbound traffic, you can report
totals over any time period using ipacsum.
See Bandwidth Monitoring with ipac-ng for more details
on reporting ipac-ng data.
How It Works
Here's a very brief description of how waix.ipac works:
fetchwaix.pl
- download list of WAIX subnets from a WAIX router
- clean up and compress subnets (thanks to Stygen's WAIX Only Firewall info, with input by zombie)
- build ipac-ng rules for each subnet
- re-initialise ipac-ng
makegraphs.pl
- run fetchipac to update ipac-ng's database
- use ipacsum to get data for each rule for the last 5 minutes
- parse the resulting output
- insert values into the RRD database
- generate RRDTool graphs
Note that I've tried getting ipac-ng to load network addresses from a textfile, but there's a
bug
which breaks this functionality.
References
Bandwidth Monitoring with ipac-ng
Installing and Using RRDTool
ipac-ng
About RRD Tool
last updated 27 Dec 2012
|