UserPreferences

OlsrTopologyVisualization


often it is very good for the understanding of a mesh network to have the ability to show the network topology graphically. newer versions of OLSR (<=0.4.6) have a plugin which outputs the topology in the [WWW]dot file format on localhost(!) port 2004/tcp. the [WWW]graphviz tools can then be used to draw the graphs. for now you can only get the topology of the local machine!

first install the following packages

you have to compile the libraries seperately and install them

make libs
make install_libs

to load the plugin add the following line to /etc/olsrd.conf

LOAD_PLUGIN     olsrd_dot_draw.so.0.1

then restart olsr and check if you get output on port 2004

telnet localhost 2004
after a while you should get some text output

now you can use the following script to automatically draw a new picture of the topology to the screen when something changes:

#!/usr/bin/perl

use IO::Socket;

$TOPPATH = "/tmp";
$NAME = "topology";
$FILENAME = "$TOPPATH/$NAME.dot";
$EXT = "png";

`touch $TOPPATH/$NAME.$EXT`;

$remote = IO::Socket::INET->new(
                        Proto    => "tcp",
                        PeerAddr => "localhost",
                        PeerPort => "2004",
                    )
                  or die "cannot connect to daytime port at localhost";

$f;

system "display -backdrop -size 1024x800 -geometry 1024x800 -update 5 $TOPPATH/$NAME.$EXT &";

while ( <$remote> ) {

        $line = $_;
        $f = $f . $line;

        if ( $line =~ /}/i ) {
                print "* ";
                open DOTFILE, ">$FILENAME";
                print DOTFILE $f;
                close DOTFILE;
                $f = "";

                `neato -Tpng -Gsize=9,6 -Gbgcolor=black -Gsplines=true -Nstyle=filled -Nfontsize=15 -Ncolor=white -Nfillcolor=white -Nfontname=verdana -Ecolor=grey -Elen=4 -Earrowsize=2 $FILENAME -o $TOPPATH/$NAME.new`;

                `mv $TOPPATH/$NAME.new $TOPPATH/$NAME.$EXT`;
                `cp $TOPPATH/$NAME.dot $TOPPATH/$NAME-\$(date +'%Y-%m-%d-%H-%M-%S').dot`;
        }
}

it is also here: Upload new attachment "oslrd_dot_file.pl"