Lesson 9: Debugging

Last Updated on October 24, 2005 3:23 PM .

Agilla programs can be debugged using TOSSIM. There are two ways to do this: 1) using a default agent, or 2) via injection. When simulating an agent, the agent's execution trace is printed to the screen.

Default Agent

A default agent simulation involves modifying <agilla>/components/AgentMgrM.nc to automatically load an agent upon boot. The advantage of this method is it does not use the agent migration components, allowing you to debug an agent even if the interface between the AgentInjector and Agilla is broken. The disadvantage, however, is that you can only simulate one type of agent in the network at a time (unless you make further modifications to AgentMgrM). To simulate Agilla using a default agent, first launch the agent injector in "no connect" mode using the following command:

java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector -nc

The Agent Injector GUI will appear. Open the agent you want to simulate. In the picture below, 3Blink is loaded.

Go to the Debug menu and select Print Debug Code. This will print some NesC code to the shell as shown below.

Copy the code and open <agilla>/components/AgentMgrM.nc. Search for "event result_t SimTimer.fired()". Paste the code within this method body. Then search for "#define INCLUDE_DEFAULT_AGENT" and make sure it is defined to be 1.

Compile Agilla by typing make pc. Then run the simulation: build/pc/main.exe -b=0 1. You should see the following output:

This shows the initialization and execution of the 3Blink agent. Each line starts with "0: VM (0:0):". The first integer is the mote ID, the second is the agent ID, and the third is the agent's program counter.

Injection

The Agent Injector can be used to inject agents into an Agilla network being simulated by TOSSIM. First open <agilla>/components/AgentMgrM.nc and find the line containing #define INCLUDE_DEFAULT_AGENT. Make sure it is defined to be 0. This will prevent the default agent from being executed.

Compile Agilla for TOSSIM by typing make pc.

TOSSIM uses a different byte packing, requiring that the Java classes encapsulating TOS active message be re-generated using mig. Open <java>/edu/wustl/mobilab/agilla/Makefile and set MIG = -target=pc java. Then recompile the AgentInjector using make.

This will take some time as it needs to re-generate all of the Java message files. Once done, open two shells. In one shell, start TOSSIM:

cd $TOSROOT/contrib/wustl/apps/Agilla
build/pc/main.exe -b=0 26

where 26 is the number of nodes to simulate. In the other prompt, execute the following commands:

cd $TOSROOT/tools/java; java net.tinyos.sf.SerialForwarder -comm tossim-serial &
java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector -comm tossim-serial -d &

The first command starts the Serial Forwarder running. The second command launches the AgentInjector application in simulation mode. The serial forwarder is necessary because it connects the AgentInjector with TOSSIM. The AgentInjector should look like:

Notice that the upper-right status bar indicates that it is connected to "tossim-serial". Now you can open and inject agents into the sensor network being simulated.

Note: After simulating, be sure to revert the AgentInjector's makefile to define MIG = mig java!

 

 

This work is supported by the ONR MURI Project CONTESSA and the NSF under grant number CCR-9970939.