This tutorial aims at introducing the Cooja Simulator and guiding the reader in a simple debugging exercise. We are going to work with Hello World example for the debugging process. You can also study the Hello_World tutorial to get familiar with its source code.
You Will Learn
- How to run Cooja Simulator.
- How to debug an application using Cooja Simulator.
- /contiki/tools/cooja/ - This folder has Cooja Simulator source code. You can run Cooja inside this directory.
- /contiki/examples/hello-world/ - This has the source code of Hello World example.
Running Cooja Simulator
Cooja Simulator is a network simulator specifically designed for Wireless Sensor Networks. A summary of how Cooja executes binaries of different platforms (different types of nodes) and a few details about its structure can be found here:.
The simples way of running Cooja is executing it inside its own directory (we will see later how to execute Cooja from any working directory):
cd contiki/tools/cooja ant run
We you execute Cooja the following window pops up.
In File menu you can start a new simulation or open an existing one. At this moment we will start a new one. You should select: File > New simulation... The following window should show up.
In the Simulation name box you should enter an identifier for the new simulation, and in Advanced settings you can choose parameters of the simulation such as Radio medium, node startup delay and random seed generation. We are going to create a simulation called "First Cooja Sim", as shown above.
After creating a new simulation, Cooja's window is filled with the main simulating tools, as shown in the next image.
Here we briefly describe the functionalities of each tool:
* Network - Shows the location of each node in the network. Can be used to visualize the status of each node, including LEDs, mote IDs, addresses, lof outputs, etc. Initially this window is empty and we need to populate it with our sensors. * Simulation Control - This panel is used to Start, Pause, Reload or execute Steps of the simulation. It shows the time of execution and the speed of simulation. It means that we can run the events several times faster than it would take in real-time execution. * Notes - This is a simple notepad for taking notes about the simulation. * Mote output - Shows all output of serial interface of the nodes. It is possible to enable one window of Mote output for each node in the simulation. * Timeline - Simulation timeline where messages and events such as channel change, LEDs change, log outputs, etc are shown.
In addition to the default tools, it is possible to exhibit other tools such as Breakpoints, Radio messages, Script editor, Buffer view and Mote duty cycle, which can be enable in the Tools menu.