Get started with the Cooja simulator

From ContikiWiki

Jump to: navigation, search

Cooja is the Contiki network simulator. With Cooja, it is possible to run Contiki systems without access to any actual hardware. This tutorial will show you how you can use Contiki's simulator Cooja to run two example simulations and how to set up your own simulation.

Before doing this tutorial, you should Install Instant Contiki.

Contents

[edit] Step 1: Start Cooja

First Start Instant Contiki.

To start Cooja, double-click on the "Run Cooja" icon to the right on the screen. This will bring up a terminal window with some text scrolling by. The Cooja Java code may need to be compiled, which may take a few seconds. After a few seconds the Cooja window appears. Maximize the window by double-clicking on the title bar. The screen should now look like this:

Instant-contiki-2.x - VMware Player 2010-11-11 21-03-34.png


NOTE: For InstantContiki2.5 no icons are preloaded on the desktop. To launch Cooja open the terminal and run following commands:

 cd contiki/tools/cooja
 ant run

[edit] Step 2: Run a Hello, World example

This first example shows how to open one of the existing simulation examples in the Contiki code. We begin with the simple Hello, World example. This example has a small network of two nodes. The nodes only print out a Hello, World message and does nothing more. To open the example, go to the Open Simulation menu item on the File menu:

Instant-contiki-2.x - VMware Player 2010-11-11 21-05-41.png

Click on the Browse… item, and a file dialog box appears. Go to the directory contiki/examples/hello-world and open the hello-world-example.csc file:

Instant-contiki-2.x - VMware Player 2010-11-11 21-07-34.png

Opening the simulation will cause Contiki to be compiled. The compilation output is shown in a dialog box on the screen:

Instant-contiki-2.x - VMware Player 2010-11-11 21-09-54.png

There may be a number of compilation warnings displayed. They can be ignored by clicking the Hide compilation warnings button. Close the dialog by clicking the close button:

Instant-contiki-2.x - VMware Player 2010-11-11 21-10-37.png

Start the simulation by clicking the Start button:

Instant-contiki-2.x - VMware Player 2010-11-11 21-11-18.png

After a few seconds, the two nodes have started and printed out their Hello World message. The simulation can now be stopped by pressing the Pause button.

Instant-contiki-2.x - VMware Player 2010-11-11 21-13-46.png

Congratulations! You have just compiled and simulated your first Contiki system!

[edit] Step 3: Run a data collection example

Data collection is the most commonly used sensor network mechanism. With data collection, nodes report data to a sink node. The Contiki distribution contains a quick-start data collection example that does all the collection for you.

Go to the File menu and choose the Open simulation menu item, and the Browse item. Open the example-collect.csc file in the contiki-2.x/examples/rime directory:

Instant-contiki-2.x - VMware Player 2010-11-11 21-16-30.png

Wait for the compilation to finish. The screen now shows the data collection example:

Instant-contiki-2.x - VMware Player 2010-11-11 21-17-50.png

Click the Start button in the Control Panel window. See the collection network form in the Simulation Visualizer.

Instant-contiki-2.x - VMware Player 2010-11-11 21-18-41.png

Instant-contiki-2.x - VMware Player 2010-11-11 21-19-03.png

[edit] Summary

You have now learnt how you can easily compile a "hello world" program and run it in the Cooja simulator. If you want to learn more about how to use the data collection provided by Contiki head over to the Simple Contiki Data Collection on the Tmote Sky. Otherwise continue with the Getting Started tutorial set.

Personal tools