Mobility of Nodes in Cooja

From Contiki
Revision as of 19:56, 8 November 2014 by Ppdeshpa (Talk | contribs) (VANET Simulation on Cooja)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to Contiki Tutorials


This tutorial teaches you how to enable mobility in Cooja Simulator. This feature can be used to simulate and test mobile ad-hoc network protocols in the Cooja Simulator. After following all the steps mentioned in this tutorial you will be able to sucessfully simulate mobile nodes in your Cooja simulator.

You Will Learn

  • How to download and enable mobility plugin in Cooja
  • How to use the plugin

Downloading the Plugin

The mobility plugin for cooja can be found at this URL

Create a new directory at

cd contiki/tools/cooja/apps

mkdir mobility

Download and Save all the files into this mobility folder

Now, you have successfully downloaded all the files needed for this plugin

--Note you need to replicate the directory and file structure at the given URL--

--You have to create directories and save files individually from the URL--

The next thing we need to do is enable this plugin in Cooja

Building the plugin

Navigate to

cd contiki/tools/cooja/apps/mobility

sudo ant jar

This will build the plugin

Enabling the Mobility Plugin in Cooja

Start Cooja Simulator

cd contiki/tools/cooja

sudo ant run

In Cooja,

Settings > External Tools Path…


Edit Settings Screen will pop-up



This field is used to specify paths to all the plugins in Cooja Simulator

Here you have to add a path to the downloaded plugin. We do this for linking the plugin with Cooja Simulator

Now, we need to append the plugin’s path to the existing plugin paths

Go the end of this field DEFAULT_PROJECTDIRS

Insert ‘ ; ‘ symbol

Add the plugin’s path


Click Save

Close Cooja Simulator and Start it again.

cd contiki/tools/cooja/

sudo ant run

Now go to

Settings>Cooja Extensions

Cooja Extensions Window will pop-up.

Scroll down to mobility select it and click on “Apply for the session”


Under the Tools tab in Cooja you should see a new “Mobility…” option now


Testing the Plugin

Start a new simulation

File > New Simulation


Add a test mote to your simulation to test the new plugin

Motes > Add Mote > Create a new mote type > Sky Mote …


Compile a simple hello-world.c code on this mote. Now create the mote

Now, we will test our plugin on this mote

Under Tools tab click on mobility

Tools > Mobility


Browse and Navigate to



We have instructed our mobility plugin to get the positional information from this positions.dat file

Click Open

A small window will pop-up as shown below


Now, Click on “Start Simulation”


Voila! Your mote will start start moving according to the specified positions.dat file

Positions.dat File structure

Position.dat file contains this information

#node time(s) x y

0 0.0 0 10

0 1.0 10 10

0 2.0 10 0

0 3.0 0 0

0 4.0 0 10

The first column specifies the node number

The second column is the time-stamp

The third column is the x-coordinate

The fourth column is the y-coordinate

#node time(s) x y

0 0.0 0 10

This line means node 0 (mote 1) at 0.0sec will be at position co-ordinates (0, 10)

Note: Here node 0 is the 'mote 1’ on your cooja simulator

If you specify node 1 in the first column it is for 'mote 2'

So positions.dat node (n) is actually mote (n+1) on Cooja Simulator

Changing positions.dat file or plugin files

Changing positions.dat file

If you want to change the position.dat file. Replace position.dat file with the new file

Under Tools>Mobility

Add the required number of nodes in the simulator and start your simulation.

The new positions will be loaded now and the nodes will start moving according to new position specifications.

Changing core plugin files

If you want to change the core plugin files for your requirements.

After implementing your changes and modifying files. You need to execute

sudo ant clean

sudo ant jar

Inside the

contiki/tools/cooja/apps/mobility folder

VANET Simulation on Cooja

I have simulated mobile nodes scenario for Vehicular Ad-Hoc Networks (VANETs)

Here is a youtube link:


This Mobility Plugin is listed in the official Contiki wiki and can be found at these links

Back to Contiki Tutorials

Edited by: Pratyush Deshpande