README.txt
david/scripts
David Rowe 14 April 2010

Some work in progress scripts for mesh networks and node tuning.

munin-node
----------

munin-node is a hacked version of the munin-node script that comes
with the muninlite opkg.  It has been hacked to plot batman scores for
all nodes in the mesh.  It automatically generates data for new nodes,
so you don't have to change anything when new nodes appear.  

This version of munin-node is designed to run on the Supernode, as you
really only need one node to list all of the nodes in the mesh.
However it might also be useful to run munin on other mesh nodes to
gather long term stats, e.g. tracking memory leaks, CPU load issues
etc.  It could be extended to count phone calls, test SIP trunks or
whatever.

It has been tested on Nanostation 2's running Antoine's supernode
images.  Haven't tested on an actual MP01 yet.

1/ To install you need a Supernode with an Internet connection:

    root@OpenWrt:~# opkg update
    root@OpenWrt:~# opkg install muninlite
    root@OpenWrt:~# cd /etc/rc.d
    root@OpenWrt:~# ln -s ../init.d/xinetd S93xinetd
    root@OpenWrt:~# /etc/init.d/xinetd

2/ Then scp the munin-node script in this directory to /usr/sbin on the
Supernode, replacing the default munin-node script.

3/ Test via telnet from a x86 that can access the Supernode, e.g.:

    david@dilivt1:~$ telnet supernode 4949

    Trying 10.130.1.1...
    Connected to supernode.
    Escape character is '^]'.
    list# munin node at OpenWrt

    mp_3 mp_8 mp_7 mp_6 mp_4 mp_5 mp_2 cpu if_eth0 if_ath0 if_err_eth0 if_err_ath0
    load memory processes uptime interrupts irqstats
    fetch mp_3
    mp_3.value 246
    .
    quit

4/ Set up munin on your x86 box:

    # apt-get install munin

5/ Edit /etc/munin/munin.conf:

    # a simple host tree

    [supernode.localdomain]
        address 10.130.1.1

6/ Wait 5 minutes and point your web browser at http://localhost/munin

node_tune.sh
------------

Run this script while installing a mesh node.  Connect a PC to the
node using Ethernet.  The output tells you which nodes can be seen and
their signal strengths in dBm.

This is just a starting point, it needs some work.  For example:

1/ Print batman score back to the Supernode.

2/ ping the adjacent nodes at a high rate.  Lots of data flowing to these
   nodes was found to be necessary to make the signal strength numbers update
   quickly.  Otherwise they change very slowly.  The default busybox ping
   doesn't support fast pings (like the -i 0.1 option).

3/ Print ping stats for a long (-s 1400) packet, for example send 10
   pings then report the average and variance.  As the signal strength
   increases it was found that ping stats improved a lot for large
   packets.  This is a key indicator of link quality, as large packets
   are very sensitive to interference (e.g. hidden node issues).

4/ Integrate with an Asterisk application to play tones.  One tone for
   each adjacent node, higher tone is a higher signal strength.  The
   easiest way would be a script like this running as a daemon that
   did all the text processing and saved the signal strength results
   in a file.  The asterisk application could then read the file and
   play tones based on the number and magnitude of the signal
   strengths.

graphwifi.sh 
------------

Also calls graphwifi.pl, scan.m

Runs "iwlist ath0 scan" (e.g. on a Supernode) and graphs the networks
found.  Used for deternining how busy the Wifi spectrum is.

-> wifi-channels.png is an example output from a NS2 Supernode running
   on a 20m tower at Fongtil HQ in Dili, East Timor.  The NS2 is
   pointing over the UN compound into the center of Dili, a busy Wifi
   environment.

Ideas for improvements:

1/ Use passwordless login.

2/ Set it up to graph continuously by piping data to octave to make an
animated display as APs come and go.

3/ Set up continuous update over a web server.





