Tuesday, March 1, 2016

Mapping The New (Serval) World

Humans tend to understand stuff better that they can see, stuff that they can visualize. Having a good map when entering new terrain was and is always important. This is not only true for the real world but also for the digital world. Even without knowledge of the real position of nodes one can still visualize how every thing is connected either through traceroute information or what is present in our routing table.

For this project lets assume the following network setup with 9 nodes involved:

Network Topology

My first approach was to simply parse the output of servals route print command, use pythons networkx library and plot it all with matplotlib:

Visualization using matplotlib


Worked quite nice, was very easy to implement but is really kind of limited when interacting with the graph and also has quite some dependencies. Nevertheless the script can be found here.

While playing around with networkx I found out that it can also output any graph as JSON. This can then be easily parsed by JavaScript libraries such as D3js in your browser. After writing a short prototype in python and testing it I added a route json command to serval to directly output JSON data, eliminating the need for python.


To visualize everything I just merged the official force-directed sample with another sample from the internet plus some minor modifications to prettify stuff and was done with it.

Putting all these pieces together - assuming servald has route json support and is already running plus route-network.html is in the current directory:
$ servald route json > route.json
$ python -mSimpleHTTPServer
Now use a webbrowser and go to http://localhost:8000/route-network.html and you're done!

Visualization using D3

Of course it would be cool to have this route data available as a restful call provided by serval. Then we could easily integrate it into any (Web-)GUI and maybe someone will develop a more sophisticated visualization where one can copy'n'paste SIDs or send MeshMS to specific nodes! Wouldn't that be great?! :)

The scripts, patches, installation instructions and sample data can be found in the serval-vis repository.