Testbed Config

Author: Rodrigo Fonseca (rfonseca at cs.berkeley.edu)

This is the description for a set of tools to interface with static ethernet testbeds. It consists of a *very* simple configuration specification, a perl module and a java class to parse it, and a set of scripts and programs (perl, bash, and java).

Configuration File Format

The configuration file is very simple, and the parser is not very robust. All lines starting with '#' are ignored, as well as blank lines. A line starting with
platform
indicates the platform that the testbed uses. Currently, we assume all motes to be of the same platform. A line starting with
mote
specifies a ... mote! The format is:
mote <id> <ip address> <x> <y> 
.

x and y are used by some other scripts, for example to draw graphs of the testbed, etc.

Utilities

Environment Variables

  TOS_TESTBED_CONFIG - some scripts expect this to point to the testbed configuration file you want to use

Programming motes

testbed-program.pl
is a wrapper to the rsc scripts that reads from a configuration file and allows interaction with the testbed (programming, pinging, etc). It requires an extra argument,
--testbed=
, that indicates the file.

Running Experiments

The format of experiments I am currently running creates a serial forwarder to each mote, which forwards the data to and from port 9100 + mote id. The reason for this is that this indirection is useful if you want to multiplex access to the motes: otherwise, if you connect directly to the mote from the packet logger, you can't open a second connection simultaneously. I use this to log and at the same time send commands to the motes.

Use

 testbed_start_sf.pl 
to start the serial forwarders. It reads the config file from
$TOS_TESTBED_CONFIG
and starts them.

Then start

java net.tinyos.testbed.TestBedPacketLogger <testbed config file> <time> to run(seconds)>
. This will log all packets that the motes send to the UART to a binary file, and to STDOUT in textual format.

The format of the text output is:

   

id and time are decimal numbers, and the other bytes are 0X (hex) representations of the packet bytes.

The format of the binary output is as follows. The byte order is whatever java's DataOutputStream writes.

  short id;
  long  time;
  short packet_length;
  byte[packet_length] packet;

Using the Perl Module

The perl module TinyOS::Util::TestBedConfig is useful for creating simple iterators over the motes in a given testbed configuration. testbed-program.pl, eraselabapp.pl, and resetlabapp.pl provide nice examples os the usage.

1. Make the module accessible:

Place it into a directory, such as /path/to/TinyOS/Util/TestBedConfig.pm Add the directory to you environment variable:
  export PERL5LIB=$PERL5LIB:/path/to/scripts  (bash) or 
setenv PERL5LIB $PERL5LIB:/path/to/scripts

2. Use it

Quick help
   use TinyOS::Util::TestBedConfig;
   $cfg = TinyOS::Util::TestBedConfig->new($config_file);
   $n = cfg->getNumberOfMotes();
Iterating over the motes
   my @mote_array;
   $cfg->getMotes(\@mote_array);
   for $mote (@mote_array) {
      $address = $mote->{'address'};
      $id      = $mote->{'id'};
      $x       = $mote->{'x'};
      $y       = $mote->{'y'}; 
      #do whatever you want
   }
Other calls:
   $moteref = getMote($id);
   getMotes(\@array);
   $n = getNumberOfMotes();
   $platform = getPlatform();
The array of motes returned by getMotes() is an array of hash references with the following keys:

Using the Java Class

The java class, net.tinyos.testbed.TestBedConfig, has a very similar usage. It is used, for example, by TestBedPacketLogger to create the packet listeners. The main method also provides an example.

Method summary

  TestBedConfig.TestBedConfigMote getMote(int i)
  java.util.Iterator getMotesIterator()
  int getNumberOfMotes()

Method summary for

TestBedConfigMote
. This is just a wrapper for the information in the config file about a mote.

Constructor Summary

  TestBedConfig.TestBedConfigMote(int id, java.lang.String address)
  TestBedConfig.TestBedConfigMote(int id, java.lang.String address, double x, double y)

Method Summary

  java.lang.String getAddress()
  int getId()
  double getX()
  double getY()