Using Avrora for Sensor Network Research

One of the main goals of developing Avrora is to enable sensor network research by providing an accurate and scalable simulator for the actual hardware platform on which sensor programs run. Avrora has a nearly complete implementation of the mica2 hardware platform, including a nearly complete ATMega128L implementation, and an implementation of the CC1000 AM radio.

The architecture of Avrora allows multiple Simulator objects to be instantiated and run. Avrora can then simulate an entire network of nodes by periodically synchronizing the simulator instances to preserve the timing interactions between them. Nodes can send and receive bytes over the CC1000 radio.

Single node Simulation - Blink

You can simulate your sensor network program in isolation on one node or as part of a network. Simulating a single node can allow you to test crucial parts of your program before you run it in a network simulation. You can debug, test, profile, and analyze the program in isolation. You can simulate a sensor network program for the mica2 platform by simply specifying the -platform=mica2 option on the command line.

An example of running the Blink program:

Multiple-node Simulation

Avrora is also capable of running a complete sensor network simulation with full timing accuracy, allowing programs to communicate via the radio using the software stack provided in TinyOS. It does this with a complete simulation of the CC1000 AM radio. Let's go through an example of running a multiple-node simulation.

Step 1 - Compile the TinyOS programs

Suppose we want to run the CntToRfm and the RfmToLeds TinyOS programs in simulation and measure the sleeping behavior. First we compile the programs to an ELF file for the mica2 hardware platform, and then run avr-objdump on each to produce a file readable by Avrora. For more information, see the page on objdump.

% make mica2
    compiling CntToRfm to a mica2 binary
ncc -o build/mica2/main.exe -Os -board=micasb -target=mica2 -I%T/lib/Counters 
-Wall -Wshadow -DDEF_TOS_AM_GROUP=0x7d -Wnesc-all -finline-limit=100000 
-fnesc-cfile=build/mica2/app.c -lm 
    compiled CntToRfm to build/mica2/main.exe
            9224 bytes in ROM
             384 bytes in RAM
avr-objcopy --output-target=srec build/mica2/main.exe build/mica2/main.srec
% avr-objdump -zhD build/mica2/main.exe > CntToRfm.od

Step 2 - Test Simulation

Now, having done that for both applications, we are ready to run. Let's try running two nodes for 10 simulated seconds, with one node running CntToRfm and the other running RfmToLeds.

Notice that in order to select a multi-node simulation, we will need to specify the simulation option with the value sensor-network. This tells Avrora to the simulation type is a sensor network, rather than the default, single node simulation.

Step 3 - Attach Monitors to Simulation

Now that we can run the nodes in simulation, let's attach a monitor to analyze the network behavior. Luckily, there is already a built-in monitor in Avrora to do this! We can simply add the -monitors=packet option to enable this monitor, which displays the packets sent by each node.

Profiling Multiple-node Simulations

As we saw in the example, profiling of multiple-node simulations is as easy as it is for single node simulation. All the flexibility that is afforded by the monitor organization is preserved in multiple node simulations. Therefore, building new monitors and using the default monitors work in exactly the same way, by specifying the -monitors option. Most of the monitors that work for single node simulation, such as profiling execution or memory accesses, work equally well for multiple-node simulation. This allows you to use Avrora to profile your applications across the entire sensor network--a feature not available in any other simulator. For more information on building your own monitors see the page on monitoring.

More Command Line Options

Help for each option in this action is available simply by running Avrora with the -help sensor-network parameter, and is also available in the online help.