Java Freimap Projekt

Aus wiki.freifunk.net
Zur Navigation springenZur Suche springen
Freimap
Freimap Screenshot
Developer freimap team
First released
Latest preview version
Release date and age
Frequently updated yes
Programming language JAVA (JDK 1.6)
Platform Cross-platform (Linux, BSD)
Language Multilingual
Status active
Genre
License GNU General Public License, LGPL
Website
Download

Freimap is an Open Source visualization and analysis framework for (mostly) mesh networks, such as for example Freifunk.net. It can read many a different data source and display them as different layers. The network can be browsed and queried in real time, and a time bar allows to trace back to past events. Some statistics of the topology and network traffic may also be generated. Service Discovery is a new feature of Freimap. This means that at Run Time the user can choose, from the settings menu, what kind of datasource he/she wants to use when the application starts. The Freimap software has a menu where the user can choose different functions. The software itself runs in Java, and smoothly at that. It reads data from various sources in the network or a database. There are a lot of possible Datasources that will be implemented including MySql DataSource, OLSRD DataSource, latlon.js DataSource and XML.


ServiceDiscovery

Service Discovery enables the usage of mdns plugin of olsr. It is developed by Stefano Pilla who started it as a Summer of Code project.

Development Process

The freimap base has not been made with an IDE like Netbeans or Eclipse so the first work is to port old freimap to the new IDE. Netbeans is used here as it has a simple and really intuitive GUI Builder and you can make a lot of things in a simple way. Stefano: "However during the porting to Netbeans IDE I have had to modify a lot of things because there was not the possibility to change software GUI with netbeans GUI Builder with the current implementation of the software." (find info about Netbeans GUI Builder here: http://www.netbeans.org/features/java/swing.html)

The “new Freimap” is able to capture the map from OpenStreetMap with the package of JXMpakit (JXMapViewer). The JXMapViewer is an open source (LGPL) Swing component created by the developers at SwingLabs (http://www.swinglabs.com). At its core, the JXMapViewer is a special JPanel that knows how to load map tiles from an image server. All of the details of how to convert coordinates to pixels, cache tiles, and stitch them together on screen are nicely hidden inside JXMapViewer's API. All you need to do is add it to your Swing application the way you would with any other JPanel.

Integrated Components

JmDNS is a Java implementation of multi-cast DNS and can be used for service registration and discovery in local area networks like Freifunk network. JmDNS is fully compatible with Apple's Bonjour (Rendezvous). The Zeroconf working group is working towards zero configuration IP networking. Multi-cast DNS and DNS service discovery provide a convient ways for devices and services to register themselves, and to discover other network-based services without relying on centrally administered services. Java as a language is not appropriate for low-level network configuration, but it is very useful for service registration and discovery. JmDNS provides easy-to-use pure-Java mDNS implementation that runs on most JDK1.4 compatible VMs. The code is released under the LGPL license so that it can be freely incorporated into other products and services.

JmDNS

import javax.jmdns.JmDNS; JmDNS jmdns = new JmDNS(); System.out.println(”Host: “ + jmdns.getHostName()); System.out.println(”Interface: “ + jmdns.getInterface()); ServiceInfo si[] = jmdns.list(”_http._tcp.local.”); jmdns.addServiceTypeListener(new MyServiceTypeListener());


Encapsulates info about a JmDNS Service

import javax.jmdns.ServiceInfo;

System.out.println(”Host: “ + jmdns.getHostName() ); System.out.println(”Interface: “ + jmdns.getInterface()); ServiceInfo si[] = jmdns.list(”_http._tcp.local.”); System.out.println(”Service 0 : “ + si[ 0 ].getServer() + “--” + si[ 0 ].getPort() + “--” + si[ 0 ].getNiceTextString() );

ServiceListener Additions, Removals

ServiceTypeListener New service type discovery

Both listen for ServiceEvents


How to Setup Freimap with Olsrd

Pre-Requisite

To build olsrd you need to have all the regular development tools installed. This includes gcc, make, glibc, makedep etc. To install to a directory different from /(/etc, /usr/bin) use DESTDIR=targetdir. To use other compilers set CC=yourcompiler.

Download OLSRd

Download OLSRDaemon from https://hg.ninux.org/hg/olsrd-0.5.6-mdns/archive/tip.tar.bz2

Build and Install

To build:

make

To install(as root):

make install

To make plugins (needed)

make libs

To install plugins

make install_libs

To delete object files run:

make clean

Optionally, to clean all generated files:

make uberclean

basic config

Before running olsrd you must edit the default configuration file /etc/olsrd.conf adding at least what interfaces olsrd is to run on.

Options in the config file can also be overridden by command line options. See the manual pages olsrd(8) and olsrd.conf(5) for details.

The binary is named 'olsrd' and is installed in (PREFIX)/usr/sbin. You must have root privileges to run olsrd!

running

To run olsrd just type:

olsrd -f /etc/olsrd.conf

If debug level is set to 0 olsrd will detach and run in the background, if not it will keep running in your shell:

olsrd -f /etc/olsrd.conf -d #

where # = 0..7

http info

The http info plugin gives information via a small embedded http server.

It should be enabled by default and listen on http://127.0.0.1:8000

Configuration is done below the line

LoadPlugin "olsrd_httpinfo.so.0.1"

in /etc/olsrd.conf

dot plugin

The dot plugin gives a topology graph in the dot format, which is used by graphviz.

it's output is also needed for freimap.

For minimal configuration, insert following into olsrd.conf:

LoadPlugin "olsrd_dot_draw.so.0.3"
{
}

To test, do a

telnet 127.0.0.1 2004

and you should get dot output.

there is a small perl script in lib/dot_draw/misc to draw the topology.

nameservice plugin

The name is a bit misleading, as it has grown from a bit nameservice to be a instrument for flooding many information in the mesh:

  • my hostname
  • hostnames in my attached network
  • address of my dns server
  • geopositions
  • mac addresses
  • services

minimal config:

LoadPlugin "olsrd_nameservice.so.0.3"
{
        PlParam "name" "demovpn.olsr"
        PlParam "lat" "52.524"
        PlParam "lon" "13.31"
        PlParam "latlon-file" "/var/run/latlon.js"

}

Please change lat and lon according to your place, it does not need to be super precise in you case but it would be very nice if its at least pointing to your city.


mdns plugin

The mdns plugin relays mDNS (aka bonjour, avahi, howl, ...) through the mesh via the flooding mechanisms provided by olsr.

It has been developed by http://ninux.org


How it works

To discover services in the network applications exchange multicast DNS packets. This means that we are able to discover services offered in the network within our multicast domain. In a wireless mesh network, the usage of wireless interfaces in ad-hoc mode and the OLSR routing protocol prevent multicast messages to be distributed all over the network. The key idea is to extend the multicast domain of the networks that do not directly partecipate in the OLSR mesh cloud but that are fully routable and announced via HNA.

This task is achieved in the following way: 1. the local router picks up from the local non-OLSR (HNA) network mDNS messages and encapsulates them in a new type of OLSR messages 2. the OLSR infrastructure is exploited for the transport of these messages 3. remote routers decapsulate mDNS messages from received OLSR messages and send them over their attached non-OLSR networks.

The plugin captures the traffic (only IPv4 if OLSR is running IPv4 and only IPv6 if OLSR is running IPv6) and encapsulates this traffic in OLSR messages that are forwarded to all the other nodes in the mesh.

Other nodes running the plugin will decapsulate the packets and will send them to the interfaces specified in the configuration file.


Configuration

For minimal configuration add these lines to olsrd config file:

LoadPlugin "olsrd_mdns.so.1.0.0" 
{ 
           PlParam     "NonOlsrIf"  "eth0" 
           PlParam     "NonOlsrIf"  "eth1" 
}

Where eth0 and eth1 are the names of the interfaces where you want to capture traffic (and decapsulate incoming traffic).

Note that this interfaces MUST NOT talk OLSR and also the subnets on this interfaces must be announced with an appropriate HNA entry.

To receive mDNS messages on an host running olsrd, then put "lo" as NonOlsrIf.

Old Freimap

prerequisite

install:
* git (git-core)
* java (sun-java6-jdk)


Documentation

http://relet.net/trac/freimap/wiki/Documentation

Download it

git clone git://relet.net/freimap

Compile it

cd into src dir and make

./compile

Configuration file

mv config.yaml.example config.yaml


This is an example of config.yaml:

---
version: svn
subversion: 60

backgrounds:
  openstreetmap:
    type: openstreetmap
    # use blank, images or openstreetmap
    delay: 0
    filter: dark
    cachedir: ./gfx/cache


datasources:
  nodes-in-berlin:
    class: net.relet.freimap.LatLonJsDataSource
    url: "file:/var/run/latlon.js"

  olsrd-localhost:
    class: net.relet.freimap.OlsrdDataSource
    host: localhost
    port: 2004
    nodesource: nodes-in-berlin


More info: http://relet.net/trac/freimap/wiki/Configuration

New Freimap

Freimap with Service discovery (and other Datasource) is a new kind of Freimap software. The difference are for example the absence of config.yaml because the application could automatically find the corrent config. At Run Time the user can choose, from the settings menu, what kind of datasource want use when the application start. Now Freimap software has a menu in which user can made a lot of choice for example

From a File Menu: Open and Save Files, exit from Application

From Edit Menu: Go to Default postion, add a nodes to the map, take a snapshot, Apply filter, Find a node, Preferences of Application. The last one is to implement.

From the View Menu: Hide/Show Nodes, Links, Minimap, Zoom Buttons, Node info, List of nodes

From Help menu: show who works to the project and a guide from Freimap


There are a lot of possible Datasources:

MySql DataSource

OLSRD DataSource (must be implemented)

latlon.js DataSource

Xml Datasource

The software can also open and save xml, txt and js files for add waypoints (nodes) to the map and save it with a multiple selection...if the user adds a waypoint from the contest menu he can choose to delete or save it in a file for future consultation. Another important tools could be “Find Node”. When an user want to find a node he can search it by name, by ip or by lat lon. If user know Lat Lon he can go in a particolar position with the tools “Go Here” in the edit menu. If the lat lon is a position of a node the software automatically select the node. (must be implemented)

It has been developed in three Layer:

1) Datasource 2) "Layer" 3) MainLayer

Datasource take all the information about mesh network from static datasource like XML or JS files or from dynamic Datasource like OLSR Plugin. Layer is the layer in which you can find all the methods for the manipulation of the data. "Mainlayer" is responsible for the graphic representation of informations provided by previous "Layer".

For Service Discovery the situation are that now when you right click on a node you can go in a Contest Menu where you can click “Service Discovery”. Now mdns works fine but in this way you can select all service in the network. My idea is to find a way to select only the service of a node when you click “service discovery menu”. In general, clients are not interested in finding *every* service on the network, just the services that the client knows how to talk to. However, for problem diagnosis and network management tools, it may be useful for network administrators to find the list of advertised service types on the network, even if those service names are just opaque identifiers and not particularly informative in isolation. For this reason, a special meta-query is defined. A DNS query for PTR records with the name "_services._dns-sd._udp.<Domain>" yields a list of PTR records, where the rdata of each PTR record is the two-label name of a service type, e.g. "_http._tcp." These two-label service types can then be used to construct subsequent Service Instance Enumeration PTR queries, in this <Domain> or others, to discover a list of instances of that service type. A Service Type Enumeration PTR record's rdata SHOULD contain just two labels, without any additional "<Domain>" suffix. Clients processing received Service Type Enumeration PTR records with more than two labels SHOULD interpret the first two labels as a service type and silently ignore any additional labels in the PTR rdata. My solution is to implement the research of all services when application starts and add all found services in a HashMap where the key is the name of the node (or FQID, or ID) and the values is an array with all the found services. When user click on a service discovery menu the services is searched in this HashMap. The problems at this point are:


1) Two or more nodes has the same name …for this reason I prefer to implement a hashmap where the key is an IP or another unique ID

2) When you are behind NAT the application (but also mdns-plugin of OLSR) doesn’t work fine. In this case the only solution is to remove NAT when possibile.


The HashMap must be refreshed everytime but we have to find a method for refresh hashmap only when the user ask for node’s services and it must refresh only services of requested node. However it must be a method that do not request a lot of traffic. I think that now the best solution is to recall "_services._dns-sd._udp.<Domain>" everytime you need a refresh of a services HashMap.

This is easy to implement but the GSoC deadline has not afforded me to conclude this work. I hope that I can continue to work to this project because I’ve a really good ideas for new Freimap.

However now main goals of Freimap are:

• Database output (into MySql Database) • OLSR plugin for Freimap • Service Control Module for freimap • Mesh Node Status Monitoring / SNMP DataSource for freimap • Topology visualization / B.A.T.M.A.N and olsrd routing decision recovery for freimap • Implement Draws of Link (now I’m working on this “bug”, I've a problem to traslate x y position from JMapViewer to X Y of JTable)

You can find more info about this new features in the Ideas page: http://wiki.freifunk.net/Ideas

Database output for Freimap feature

Also this year, we have participated with a Freifunk project on the Freimap Software to the Google Summer of Code 2010.

Freimap is an Open Source visualization and analysis framework for (mostly) mesh networks, such as for example Freifunk.net. It can read many a different data source and display them as different layers in a map. The network can be browsed and queried in real time, and a time bar allows to trace back to past events. Some statistics of the topology and network traffic may also be generated. From the last Google Summer of Code 2009, Service Discovery is a new feature.

The software itself runs in Java, and smoothly at that. It reads data from various sources in the network, a database, a file or from a Live Stream (OLSR Routing Protocol, B.A.T.M.A.N., etc).

This year I've added this feature: the ability of Freimap to store all visualized data in a MySQL Database.

HOW IT WORKS

In the current version, Freimap can take data from different datasource:

  1. a file for a simple visualization: js, xml, txt files (static)
  2. a MySQL database (static)
  3. Live stream from an OLSR Daemon (dynamic)

If you want to store Live stream with the new "Database output for Freimap" feature you have to follow 2 simple steps. These steps are been simplified with a wizard that appear when you make a choice in the main GUI page.


The first step is a simple Wizard in which you have to insert some basics information such as:

  1. MySQL Database information: IP/Hostname and port
  2. MySQL Database credentials of an user that have a rw permission
  3. Position of the OLSRd config file
  4. Position of the LatLon.js file of the NameService Plugin
  5. The port of the dotDraw plugin

Once you have entered all the information you can choose a previous "Freimap" Database or to "Create a new Freimap Database". When you choose a database from a list of available database the application automatically detect if the selected schema contains Freimap data. This choice read the data from the selected database and continue to store new live data in the same tables. With the second choice you can create a new database. This choice means that you can destroy an old database or you can create a completely new one.


ISSUES AND ...TO DO

There is a lot of work to do to improve Freimap Software.

For example, as discussed in the OLSR-Dev Mailing List, there is a needs to make a simple web interface for the config file (now an xml file) in which you can change the base settings of the "Database output for Freimap" feature.

Another thing to do is to find a method to update and generate in a the fastest way a new "layer id" for the recovery of the correct layer when requested.

We have to add the possibility to read and store live data from and in two or more database (also schemas). This can be useful when you want to simulate in the same environment two networks with two different routing protocol (BATMAN and OLSR)

Actually the database information crosses the network in plain text. This means that we have to find a method to encrypt Freimap network data.


External Links