Difference between revisions of "Cooja Simulator"

From Contiki
Jump to: navigation, search
(Running Cooja Simulator)
(Running Cooja Simulator)
Line 30: Line 30:
 
[[File:cooja-1.png|center|450px]]
 
[[File:cooja-1.png|center|450px]]
  
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.
+
=== Creating a new simulation ===
 +
 
 +
In the 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.
  
 
[[File:cooja-2.png|center|400px]]
 
[[File:cooja-2.png|center|400px]]
Line 50: Line 52:
  
 
=== Creating a new mote type ===
 
=== Creating a new mote type ===
 +
 +
You need to create a new mote type before starting any simulation. You can do this in the menu '''Motes''' > '''Add motes''' > '''Create new motes type'''. Let's select '''Sky mote''' in order to create a mote of the same type as the used Tmote Sky.
 +
 +
The window that shows up (see below) asks for the '''Description''' of the new mote type and the '''Contiki process / Firmware'''. You can name your mote type as ''First mote type'' and you can select the firmware that will be used during the simulation using the ''Browse'' button. After selecting the desired firmware you can test the compilation click the ''Compile'' button. In this example we will use the Hello World fimware, typically located at ''/contiki/examples/hello-world/hello-world.c''. If the compiling process is successed, you will see a final message: ''LD hello-world.sky'' in the Compilation output tab.
 +
 +
  
 
[[Contiki_tutorials | Back to Contiki Tutorials]]
 
[[Contiki_tutorials | Back to Contiki Tutorials]]

Revision as of 21:02, 24 March 2014

Back to Contiki Tutorials

Introduction

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.

Relevant Directories

  • /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:[1].

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.

Cooja-1.png

Creating a new simulation

In the 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.

Cooja-2.png

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.

Cooja-3.png

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.

Creating a new mote type

You need to create a new mote type before starting any simulation. You can do this in the menu Motes > Add motes > Create new motes type. Let's select Sky mote in order to create a mote of the same type as the used Tmote Sky.

The window that shows up (see below) asks for the Description of the new mote type and the Contiki process / Firmware. You can name your mote type as First mote type and you can select the firmware that will be used during the simulation using the Browse button. After selecting the desired firmware you can test the compilation click the Compile button. In this example we will use the Hello World fimware, typically located at /contiki/examples/hello-world/hello-world.c. If the compiling process is successed, you will see a final message: LD hello-world.sky in the Compilation output tab.


Back to Contiki Tutorials