Nodes Serial Link Aggregation

difficulty Difficulty: Medium

duration Duration: 30 minutes

Prerequisites: Submit an experiment with M3 nodes using the web portal / Experiment CLI Client

Description: This document shows how to use the serial_aggregator tool on the ssh frontend. You will learn how to quickly get the output of all your experiment nodes and how to send messages to some of them.

Description

Each node serial link can be accessed via a tcp socket to the node url on port 20000. Here is an example using net cat on node M3 with Id 10 on Grenoble site involved in your running experiment :

user@grenoble~$ nc m3-10 20000

When running experiments with many nodes, you may want to access the serial link of all the nodes of your experiment at once. The presented tool serial_aggregator should relieve the pain of having multiple terminals each connected to one node.

You will have all the nodes output in one terminal, prefixed by a timestamp and the node identifier.

$ harter@grenoble:~$ serial_aggregator
1417086154.415922;Aggregator started
1417086156.031700;m3-11;     iotlab_uid() == 9971
1417086156.039846;m3-11;   platform_uid() == 9971
1417086156.039986;m3-11;node_from_uid(id) == 3:00B
1417086156.040103;m3-11;         node_str == m3-11
1417086157.998551;m3-10;     iotlab_uid() == 8772
1417086157.999130;m3-10;   platform_uid() == 8772
1417086157.999130;m3-10;node_from_uid(id) == 0:000
1417086157.999130;m3-10;Unknown node
1417086162.639063;Stopping                            # Stopping using 'Ctrl+C'

The serial_aggregator is a python script based on the cli-tools and asyncore to aggregate all the nodes serial links.

It’s shipped in the aggregation-tools repository (github:aggregation-tools) and released on all sites as serial_aggregator executable and as a python module to be imported (import iotlabaggregator).

Usage

To  access the serial links, it should be run on the ssh frontends of the sites where the nodes are reserved only.

user@grenoble:~$ serial_aggregator --help
usage: serial_aggregator [-h] [-u USERNAME] [-p PASSWORD]
                            [-i EXPERIMENT_ID] [-l NODES_LIST] [--with-a8]

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --user USERNAME
  -p PASSWORD, --password PASSWORD

Nodes selection:
  By default, select currently running experiment nodes

  -i EXPERIMENT_ID, --id EXPERIMENT_ID
                        experiment id submission
  -l NODES_LIST, --list NODES_LIST
                        nodes list in format: "site,archi,1-5+9". Can be
                        supplied multiple times
  --with-a8             redirect open-a8 serial port.
                        `/etc/init.d/serial_redirection` must be running on
                        the nodes

First, you must  have setup the cli-tools on the server by running:

user@grenoble:~$ iotlab-auth --user <your_username>

It can then be used in different modes:

  • Without parameter to run on the currently running experiment.
  • With -i option to run on the nodes of the specified experiment
  • With -l option to specify the nodes on which to run
user@grenoble:~$ serial_aggregator                                                  # runs on nodes from currently running experiment
user@grenoble:~$ serial_aggregator -i <exp_id>                                      # runs on nodes from experiment number <exp_id>
user@grenoble:~$ serial_aggregator -l grenoble,m3,1-4  -l grenoble,wsn430,1+2+4+8   # runs on nodes from experiment number <exp_id>

Reading messages from the nodes

The received text lines will be printed as timestamp;node-id;received_line. Example:

1417086156.031700;m3-11;     iotlab_uid() == 9971

Sending messages to the nodes

Standard input is continuously read and parsed to allow sending messages to the nodes.

Parsing is done using the function extract_nodes_and_message(line). Its docstring lists all allowed values and formats.

Examples
--------

    ''    -> does not send anything to anyone, allows 'blanking' lines

    ' '   -> sends ' n'   to all nodes
    'msg' -> sends 'msgn' to all nodes

    'm3,1-3+5;message'  -> sends 'messagen' to nodes m3-1, m3-2, m3-3 and m3-5
    'm3-1;message'      -> sends 'messagen' to nodes m3-1

    'csv;message;with;semicolons' -> sends 'csv;message;with;semicolons' to all
                                     nodes as 'csv;' is not a valid
                                     node identifier

Practical tutorial

You can now replay the first tutorial using the serial_aggregator to interact with the nodes in a single terminal.

Replay steps 1 to 9 of the tutorial Submit an experiment with M3 nodes using the web portal using more nodes:

  • Nodes selection: Archi = m3:at86rf231 / Site = grenoble / Number = 10 / Mobile = no

 

  1. Connect to the SSH frontend of Grenoble
    my_computer$ ssh <login>@grenoble.iot-lab.info
  2. Interact with the nodes. Connect to all nodes using serial_aggregator
    <login>@grenoble:~$ serial_aggregator
    1417707651.307328;Aggregator started
    1417707651.710586;m3-2;
    1417707651.711210;m3-2;
    1417707651.711310;m3-2;IoT-LAB Simple Demo program
    1417707651.711399;m3-2;Type command
    1417707651.712371;m3-2;    h:    print this help
    1417707651.712477;m3-2;    t:    temperature measure
    1417707651.713344;m3-2;    l:    luminosity measure
    1417707651.713444;m3-2;    p:    pressure measure
    1417707651.722638;m3-2;    s:    send a radio packet
    1417707651.722750;m3-2;    b:    send a big radio packet
    1417707651.722841;m3-2;    e:    toggle leds blinking
    1417707651.722926;m3-2;
    1417707651.723009;m3-2; Type Enter to stop printing this help
    
    # Hit "Space+Enter" to stop the flood.
  3. Test some commands to get sensors measures (t, l, p)
    # Type 'l' + enter to send 'l' to all nodes
    l
    1417707771.347801;m3-5;cmd > Luminosity measure: 4.8828125E-1 lux
    1417707771.347801;m3-5;
    1417707771.347844;m3-2;cmd > Luminosity measure: 4.8828125E-1 lux
    1417707771.347941;m3-2;
    1417707771.348187;m3-7;cmd > Luminosity measure: 7.324219E-1 lux
    1417707771.348652;m3-7;
    1417707771.348775;m3-4;cmd > Luminosity measure: 4.8828125E-1 lux
    1417707771.348866;m3-4;
    1417707771.348969;m3-3;cmd > Luminosity measure: 7.324219E-1 lux
    1417707771.349059;m3-3;
    1417707771.349171;m3-289;cmd > Luminosity measure: 4.8828125E-1 lux
    1417707771.349259;m3-289;
    1417707771.349361;m3-288;cmd > Luminosity measure: 7.324219E-1 lux
    1417707771.349448;m3-288;
    1417707771.349600;m3-6;cmd > Luminosity measure: 7.324219E-1 lux
    1417707771.349690;m3-6;
    1417707771.349811;m3-9;cmd > Luminosity measure: 7.324219E-1 lux
    1417707771.349897;m3-9;
    1417707771.349996;m3-8;cmd > Luminosity measure: 4.8828125E-1 lux
    1417707771.350082;m3-8;
  4. Test packet sending. As we want only one node to send a radio packet, we will specify its id before the message, using this format: <node-id>;<message>You will see the other nodes receiving the message.
    m3-2;s
    1417708038.478605;m3-2;cmd > 
    1417708038.478860;m3-2;radio > Packet sent
    1417708038.479028;m3-6;cmd > 
    1417708038.479174;m3-4;cmd > 
    1417708038.479442;m3-3;cmd > 
    1417708038.479565;m3-2;
    1417708038.479672;m3-289;cmd > 
    1417708038.479795;m3-288;cmd > 
    1417708038.480001;m3-7;cmd > 
    1417708038.480116;m3-5;cmd > 
    1417708038.480319;m3-9;cmd > 
    1417708038.480531;m3-8;cmd > 
    1417708038.480865;m3-9;radio > Got packet from 9982. Len: 16 Rssi: -69: 'Hello World!: 1'
    1417708038.480962;m3-9;
    1417708038.481413;m3-7;radio > Got packet from 9982. Len: 16 Rssi: -76: 'Hello World!: 1'
    1417708038.481513;m3-7;
    1417708038.481620;m3-5;radio > Got packet from 9982. Len: 16 Rssi: -56: 'Hello World!: 1'
    1417708038.481707;m3-5;
    1417708038.481843;m3-3;radio > Got packet from 9982. Len: 16 Rssi: -42: 'Hello World!: 1'
    1417708038.481931;m3-3;
    1417708038.482042;m3-8;radio > Got packet from 9982. Len: 16 Rssi: -81: 'Hello World!: 1'
    1417708038.482128;m3-8;
    1417708038.482262;m3-6;radio > Got packet from 9982. Len: 16 Rssi: -64: 'Hello World!: 1'
    1417708038.482351;m3-6;
    1417708038.486606;m3-4;radio > Got packet from 9982. Len: 16 Rssi: -55: 'Hello World!: 1'
    1417708038.486802;m3-4;
    1417708038.487167;m3-289;radio > Got packet from 9982. Len: 16 Rssi: -61: 'Hello World!: 1'
    1417708038.487324;m3-289;
    1417708038.487610;m3-288;radio > Got packet from 9982. Len: 16 Rssi: -64: 'Hello World!: 1'
    1417708038.487917;m3-288;
  5. Now try to send a ‘big packet’ from another node
    m3-4;b
    1417708181.538321;m3-4;cmd > 
    1417708181.538482;m3-4;radio > Big packet sent
    1417708181.538663;m3-4;
    1417708181.543271;m3-7;cmd > 
    1417708181.543410;m3-6;cmd > 
    1417708181.543527;m3-5;cmd > 
    1417708181.543651;m3-3;cmd > 
    1417708181.544045;m3-2;cmd > 
    1417708181.544158;m3-289;cmd > 
    1417708181.544547;m3-289;radio > Got packet from 9176. Len: 60 Rssi: -67: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.544667;m3-289;
    1417708181.544784;m3-288;cmd > 
    1417708181.544872;m3-288;radio > Got packet from 9176. Len: 60 Rssi: -64: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.544958;m3-288;
    1417708181.545061;m3-9;cmd > 
    1417708181.545148;m3-9;radio > Got packet from 9176. Len: 60 Rssi: -76: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.545233;m3-9;
    1417708181.545333;m3-8;cmd > 
    1417708181.545419;m3-8;radio > Got packet from 9176. Len: 60 Rssi: -74: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.545503;m3-8;
    1417708181.545634;m3-7;radio > Got packet from 9176. Len: 60 Rssi: -67: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.545724;m3-7;
    1417708181.545824;m3-6;radio > Got packet from 9176. Len: 60 Rssi: -52: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.545911;m3-6;
    1417708181.546010;m3-5;radio > Got packet from 9176. Len: 60 Rssi: -49: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.546096;m3-5;
    1417708181.546196;m3-3;radio > Got packet from 9176. Len: 60 Rssi: -43: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.546282;m3-3;
    1417708181.546379;m3-2;radio > Got packet from 9176. Len: 60 Rssi: -55: 'Big Hello World!: 0 012345678901234567890123456789012345678'
    1417708181.546480;m3-2;

Advanced usage

Here follow some advanced usage ideas.

Simply running from your computer

You can run the serial_aggregator directly from your computer using ssh. The input and output will be directly available on your computer.

my_computer$ ssh <login>@grenoble.iot-lab.info "serial_aggregator -i <exp_id>"

Give access as a tcp socket

Using socat, you can easily wrap it in a tcp socket to, for example, connect a graphical application on it:

my_computer$ socat tcp-listen:20000,fork,reuseaddr exec:'ssh <login>@grenoble.iot-lab.info "serial_aggregator -i <exp_id>"'

And then connect to it

my_computer$ nc localhost 20000
p  # type 'p' + Enter
1417708815.191377;m3-9;Pressure measure: 9.85E2 mabar
1417708815.199245;m3-7;Pressure measure: 9.845237E2 mabar
1417708815.199423;m3-7;
1417708815.199607;m3-6;Pressure measure: 9.848386E2 mabar
1417708815.199768;m3-6;
...

Note: Every time you connect and disconnect, the serial_aggregator program will start and stop, so the connections will take a few seconds to get ready.