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:
% avrora -platform=mica2 -seconds=5.0 blink.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading blink.od...[OK: 1.082 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
0 318 Red: on
0 320 Yellow: on
0 322 Green: on
0 364 Red: off
0 366 Yellow: off
0 368 Green: off
0 7208139 Red: on
0 14408142 Red: off
0 21608143 Red: on
0 28808142 Red: off
0 36008143 Red: on
==============================================================================
Simulated time: 36864000 cycles
Time for simulation: 0.812 seconds
Total throughput: 45.399014 mhz
% _
|
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 CntToRfm.nc -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.
% avrora -simulation=sensor-network -seconds=5.0 -nodecount=1,1 CntToRfm.od RfmToLeds.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading CntToRfm.od...[OK: 1.912 seconds]
Loading RfmToLeds.od...[OK: 0.643 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
1 2028 Red: on
0 2376 Red: on
1 2030 Yellow: on
0 2378 Yellow: on
1 2032 Green: on
0 2380 Green: on
1 2074 Red: off
0 2422 Red: off
1 2076 Yellow: off
0 2424 Yellow: off
0 2426 Green: off
1 2078 Green: off
1 2619084 Red: on
1 4505293 Red: off
1 4505308 Green: on
1 6111948 Red: on
1 7942861 Red: off
1 7942877 Green: off
1 7942890 Yellow: on
1 9761484 Red: on
1 11644621 Red: off
1 11644636 Green: on
1 13546188 Red: on
1 15241933 Red: off
1 15241949 Green: off
1 15241963 Yellow: off
1 17152716 Red: on
1 18830029 Red: off
1 18830044 Green: on
1 20777676 Red: on
1 22458061 Red: off
1 22458077 Green: off
1 22458090 Yellow: on
1 24421068 Red: on
1 26190541 Red: off
1 26190556 Green: on
1 27855564 Red: on
1 29806285 Red: off
1 29806301 Green: off
1 29806315 Yellow: off
1 31538892 Red: on
1 33163981 Red: off
1 33163996 Green: on
1 35047116 Red: on
==============================================================================
Simulated time: 36864000 cycles
Time for simulation: 3.250 seconds
Total throughput: 22.68554 mhz
Throughput per node: 11.34277 mhz
% _
|
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.
% avrora -simulation=sensor-network -monitors=packet -seconds=5.0 -nodecount=1,1 CntToRfm.od RfmToLeds.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading CntToRfm.od...[OK: 2.032 seconds]
Loading RfmToLeds.od...[OK: 0.673 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
1 2028 Red: on
0 2376 Red: on
1 2030 Yellow: on
0 2378 Yellow: on
1 2032 Green: on
0 2380 Green: on
1 2074 Red: off
0 2422 Red: off
1 2076 Yellow: off
0 2424 Yellow: off
1 2078 Green: off
0 2426 Green: off
1 452664 Packet sent: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:...
0 456060 Packet sent: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:...
1 2619084 Red: on
0 2628637 Packet sent: 33:CC:FF:FF:04:7D:03:01:00:00:8F:A7:A7:A7:
1 4505293 Red: off
1 4505308 Green: on
0 4514845 Packet sent: 33:CC:FF:FF:04:7D:03:02:00:00:DF:FE:FE:FE:
1 6111948 Red: on
0 6121501 Packet sent: 33:CC:FF:FF:04:7D:03:03:00:00:EF:C9:C9:C9:
1 7942861 Red: off
1 7942877 Green: off
1 7942890 Yellow: on
0 7952413 Packet sent: 33:CC:FF:FF:04:7D:03:04:00:00:7F:4C:4C:4C:
1 9761484 Red: on
0 9771037 Packet sent: 33:CC:FF:FF:04:7D:03:05:00:00:4F:7B:7B:7B:
1 11644621 Red: off
1 11644636 Green: on
0 11654173 Packet sent: 33:CC:FF:FF:04:7D:03:06:00:00:1F:22:22:22:
1 13546188 Red: on
0 13555741 Packet sent: 33:CC:FF:FF:04:7D:03:07:00:00:2F:15:15:15:
1 15241933 Red: off
1 15241949 Green: off
1 15241963 Yellow: off
0 15251485 Packet sent: 33:CC:FF:FF:04:7D:03:08:00:00:1E:39:39:39:
1 17152716 Red: on
0 17162269 Packet sent: 33:CC:FF:FF:04:7D:03:09:00:00:2E:0E:0E:0E:
1 18830029 Red: off
1 18830044 Green: on
0 18839581 Packet sent: 33:CC:FF:FF:04:7D:03:0A:00:00:7E:57:57:57:
1 20777676 Red: on
0 20787229 Packet sent: 33:CC:FF:FF:04:7D:03:0B:00:00:4E:60:60:60:
1 22458061 Red: off
1 22458077 Green: off
1 22458090 Yellow: on
0 22467613 Packet sent: 33:CC:FF:FF:04:7D:03:0C:00:00:DE:E5:E5:E5:
1 24421068 Red: on
0 24430621 Packet sent: 33:CC:FF:FF:04:7D:03:0D:00:00:EE:D2:D2:D2:
1 26190541 Red: off
1 26190556 Green: on
0 26200093 Packet sent: 33:CC:FF:FF:04:7D:03:0E:00:00:BE:8B:8B:8B:
1 27855564 Red: on
0 27865117 Packet sent: 33:CC:FF:FF:04:7D:03:0F:00:00:8E:BC:BC:BC:
1 29806285 Red: off
1 29806301 Green: off
1 29806315 Yellow: off
0 29815837 Packet sent: 33:CC:FF:FF:04:7D:03:10:00:00:DC:D3:D3:D3:
1 31538892 Red: on
0 31548445 Packet sent: 33:CC:FF:FF:04:7D:03:11:00:00:EC:E4:E4:E4:
1 33163981 Red: off
1 33163996 Green: on
0 33173533 Packet sent: 33:CC:FF:FF:04:7D:03:12:00:00:BC:BD:BD:BD:
1 35047116 Red: on
0 35056669 Packet sent: 33:CC:FF:FF:04:7D:03:13:00:00:8C:8A:8A:8A:
==============================================================================
Simulated time: 36864000 cycles
Time for simulation: 3.198 seconds
Total throughput: 23.054409 mhz
Throughput per node: 11.5272045 mhz
=={ Monitors for node 0 }=====================================================
Bytes sent: 904
Packets sent: 20
=={ Monitors for node 1 }=====================================================
Bytes sent: 67
Packets sent: 1
% _
|
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.
[
Home |
Download |
Get Started |
Online CVS |
JavaDoc API ]
Copyright (c) 2004-2005, UCLA Compilers Group
The Avrora logo background is Copyright (c) 1996 Jan Curtis, used with permission.
|