txtinfo plugin Howto

For some time we already had - thanks to Lorenz Schori! - a very practical plugin: txtinfo.
In this brief HOWTO we are going to discuss how you can use it to extract information from OLSRd about it's view of the net in a very universal way. The txtinfo plugin can serve as basis for many other visualization plugins. I also want to show you how you can use the watch command to debug your OLSR testbed network.

Building and Setup

As usual, you can compile it with "make libs; make install_libs" and add it to your olsrd.conf file like this:


LoadPlugin "olsrd_txtinfo.so.0.1"
{
# the default port is 2006 but you can change it like this:
#PlParam "port" "8080"
# You can set a single address to allow to connect to txtinfo. If no address
# is specified, then localhost (127.0.0.1) is allowed by default.
#PlParam "accept" "127.0.0.1"
#PlParam "accept" "172.29.44.23"
# if you set it to 0.0.0.0, it will accept all connections
#PlParam "accept" "0.0.0.0"
}

This means the txtinfo plugin will listen to port 2006 and accept connections from localhost. (the "Net" parameter is not currently working).

Getting Information from txtinfo

The txtinfo plugin accepts any connection on a socket, and based on some URL-like commands, it will return tables of status information. You can combine the URL-like commands to get multiple tables of info with the same request.

Using txtinfo with netcat (nc)

So what happens now when you connect to the txt info port? I will connect to it via the well known netcat program and give the txtinfo a command:
...

$ echo "/all" | nc localhost 2006
HTTP/1.0 200 OK
Content-type: text/plain
Table: Links
Local IP	Remote IP	Hyst.	LQ	NLQ	Cost
10.10.0.119	10.10.0.152	0.00	1.000	1.000	
Table: Neighbors
IP address	SYM	MPR	MPRS	Will.	2 Hop Neighbors
10.10.0.152	YES	NO	NO	6	0
Table: Topology
Dest. IP	Last hop IP	LQ	NLQ	Cost
10.10.0.152	10.10.0.119	1.000	1.000
10.10.0.119	10.10.0.152	1.000	1.000
Table: HNA
Destination	Gateway
Table: MID
IP address	Aliases
Table: Routes
Destination	Gateway IP	Metric	ETX	Interface
10.10.0.152/32	10.10.0.152	1	1.000	br0	

It turns a plain text tables of data with an HTTP header so that it can be directly viewed in a web browser. These tables show information about the state of the mesh as this particular node sees it.

Using a web browser, curl or wget

You can use and combine commands into a URL to get the information you want via any browser or software that can do HTTP. Here is an example to get the current links using curl (run on the computer or device that is actually running olsrd):

$ curl http://localhost:2006/links  
Table: Links
Local IP	Remote IP	Hyst.	LQ	NLQ	Cost
172.29.53.58	172.29.62.59	0.00	0.761	1.000	1.313	
172.29.53.58	172.29.207.239	0.00	0.812	1.000	1.231	
172.29.53.58	172.29.56.119	0.00	0.772	1.000	1.294	

Here's another example where we request both links and interfaces with the same request:

$ curl http://localhost:2006/links/interfaces
Table: Links
Local IP	Remote IP	Hyst.	LQ	NLQ	Cost
172.29.53.58	172.29.62.59	0.00	0.748	1.000	1.335	
172.29.53.58	172.29.207.239	0.00	0.769	1.000	1.301	
172.29.53.58	172.29.56.119	0.00	0.744	1.000	1.342	

Table: Interfaces
Name	State	MTU	WLAN	Src-Adress	Mask	Dst-Adress
wlan0	UP	1472	Yes	172.29.53.58	255.255.0.0	172.29.255.255

Available Commands

The output shows the links of the node, its neighbors, the topology table, HNA (Host and Network Association) and MID (Multiple Interface Declaration) tables and the actual routing table.

So what commands does the txtinfo plugin accept?

  • Config: "/config" -> send_what=SIW_CONFIG
  • Gateways: "/gateway" -> send_what=SIW_GATEWAY
  • HNA: "/hna" -> send_what=SIW_HNA
  • Interfaces: "/interface" -> send_what=SIW_INTERFACE
  • Links: "/link" -> send_what=SIW_LINK
  • MID: "/mid" -> send_what=SIW_MID
  • Neighbors: "/neigh" -> send_what=SIW_NEIGH
  • Routes: "/route" -> send_what=SIW_ROUTE
  • Topology: "/topo" -> send_what=SIW_TOPO
  • 2-hop neighbors: "/2hop" -> send_what=SIW_2HOP

This is the same as the "/neigh" and "/link" commands combined:

  • "/neighbours" -> send_what = SIW_NEIGHLINK -> neighbours and links

Then there is "/all" which returns all of the most commonly used commands above (but not every command above). "/all" is the same as "/links/neigh/topo/hna/mid/routes".

Constant Monitoring via the Command Line

Now here comes a very cool trick (courtesy of Henning Rogge):


watch -d -n1 "echo '/all' | nc localhost 2006"

The watch command periodically executes the netcat command and highlights the differences ("-d flag") once per second ("-n1")
You can now brilliantly observe what is happening in your test network.
Every update in the neighbor table will be highlighted.