Avrora

From TinyOS Wiki
Revision as of 05:43, 22 April 2009 by Yangfan (talk | contribs) (What is Avrora?)
Jump to: navigation, search

What is Avrora?

Avrora is an open-source cycle-accurate simulator for embedded sensing programs. The current release (version 1.7.160) of Avrora is written in Java. It can emulate two typical platforms, Mica2 and MicaZ, and run AVR elf-binary or assembly codes for both platforms. The main Avrora web page contains a lot of good information but is not actively maintained; most of the information is also available when running avrora with a -help option. Avrora development has moved to Sourceforge.

Installing Avrora

Avrora works fine on Linux and Windows. The main prerequisite is a Java 4 or newer development environment. Download the latest CVS snapshot:

cvs -d:pserver:anonymous@avrora.cvs.sourceforge.net:/cvsroot/avrora login
cvs -z3 -d:pserver:anonymous@avrora.cvs.sourceforge.net:/cvsroot/avrora co -P avrora

The following will assume that you have set $AVRORA to be the absolute path to this avrora directory.

Build Avrora:

cd $AVRORA
make avrora

There should not be any error messages.

Add $AVRORA/bin to your CLASSPATH. Ensure that you can run Avrora:

java avrora.Main

The output should be a bunch of usage information. On Cygwin the colors may not show up properly in which case you'll want to invoke Avrora using the -colors=false command line option.

Simulating TinyOS Applications

It is assumed that you have TinyOS 2.x installed and can build applications. First simulator a trivial single-node network:

cd $TOSROOT/apps/Blink
make micaz
mv build/micaz/main.exe Blink.elf
java avrora.Main -platform=micaz -simulation=sensor-network -seconds=3 -monitors=leds Blink.elf

The output should be something like this:

Avrora [Beta 1.7.107] - (c) 2003-2007 UCLA Compilers Group

Loading Blink.elf...[OK: 0.068 seconds]
=={ Simulation events }=======================================================
Node          Time   Event
------------------------------------------------------------------------------
   0       8006682  off off on  
   0       8006684  off on  on  
   0       8006686  on  on  on  
   0       8006688  on  on  off 
   0       8006690  on  off off 
   0       8006692  off off off 
   0       9793689  off off on  
   0      11579289  off off off 
   0      11579762  off on  off 
   0      13364889  off on  on  
   0      15150489  off on  off 
   0      15150962  off off off 
   0      15151490  on  off off 
   0      16936089  on  off on  
   0      18721689  on  off off 
   0      18722162  on  on  off 
   0      20507289  on  on  on  
==============================================================================
Simulated time: 22118400 cycles
Time for simulation: 1.337 seconds
Total throughput: 16.543306 mhz

Next simulate a collection of nodes:

cd $TOSROOT/apps/RadioCountToLeds
make micaz
mv build/micaz/main.exe RadioCountToLeds.elf
java avrora.Main -platform=micaz -simulation=sensor-network -seconds=10 \
  -monitors=leds,packet -nodecount=3 -stagger-start=1000000 RadioCountToLeds.elf

It is not clear in what situations the stagger-start option is needed. Sometimes, without this option, simulations can fail to start due to all nodes being in lock-step.

The output will be voluminous and should end up with something like this:

   0      72595584  <==== 00.00.00.0F.A7.0F.41.88.22.22.00.FF.FF.01.00.3F.06.00.23.CE.BB  0.660 ms
   1      73169483  on  off on  
   1      73169491  on  on  on  
   1      73169500  off on  on  
   1      73355979  ----> 00.00.00.0F.A7.0F.41.88.23.22.00.FF.FF.01.00.3F.06.00.24.62.C1  0.660 ms
   0      73356225  <==== 00.00.00.0F.A7.0F.41.88.23.22.00.FF.FF.01.00.3F.06.00.24.CE.B3  0.660 ms
   2      73356225  <==== 00.00.00.0F.A7.0F.41.88.23.22.00.FF.FF.01.00.3F.06.00.24.CE.B3  0.660 ms
==============================================================================
Simulated time: 73728000 cycles
Time for simulation: 4.349 seconds
Total throughput: 50.85859 mhz
Throughput per node: 16.952862 mhz
=={ Packet monitor results }==================================================
Node     sent (b/p)          recv (b/p)    corrupted (b)   lostinMiddle(p)
------------------------------------------------------------------------------
   0       756 / 36            1491 / 71               0       0
   1       756 / 36            1491 / 71               0       0
   2       735 / 35            1491 / 71               0       0

The important bit is at the bottom, where the packet monitor is telling us that all 3 nodes have both transmitted and received packets.

TODO

Add sections on:

  • Talking to Avrora using the serial forwarder.
  • What monitors are available and how to use them.
  • Troubleshooting.