Setting up a Low-Power IPv6/RPL Network

From ContikiWiki

Jump to: navigation, search

One of the defining features of Contiki is that it natively supports the Internet Protocol. This tutorial shows how to set up a Contiki low-power IPv6 network. We will use the Cooja network simulator, but the principles are the same for a network with real hardware.

For simplicity, we use Instant Contiki as the development environment.

Contents

[edit] The easy way: load a ready-made simulation

Before going through the entire process, we will show easy way: loading an already existing simulation in Cooja.

[edit] Start Cooja and open the simulation

Start Cooja by double-clicking on the “Run Cooja” icon. If there is no Run Cooja icon in your Instant Contiki, open a terminal and run

cd contiki/tools/cooja
ant run

Contikirpl-screenshot-1.png

In Cooja, open the File menu, the Open simulation menu item, and click on Browse…

Contikirpl-screenshot-2.png

Go to the directory contiki-2.x/examples/ipv6/rpl-collect and open the file collect-tree-dense-noloss.csc

Contikirpl-screenshot-3.png

[edit] Start the simulation

After Contiki has been compiled and the simulation has loaded, the CollectView window will appear on top of the Cooja window. Click on the Cooja window to bring it to the front.

This simulation is a 25 node network, running IPv6 with RPL routing, where one node is the sink node to which the others periodically send sensor data.

Contikirpl-screenshot-4.png

Click the Start button to start the simulation.

Contikirpl-screenshot-5.png

[edit] View the data from the network

After the simulation time has reached some 70000 ms, data will begin to appear at the sink node. The sink node prints out the received data on its serial port. The CollectView program listens to this (emulated) serial port and displays the data, along with information about the network.

Bring up the CollectView window to see the data. Click the Network Graph tab to see the structure of the IPv6/RPL network. Right-click on the sink node (called 1.1) and click on the Fixed Node Position menu item to fix its position. It is helpful to first uncheck the Update Layout menu item – this will cause the nodes to stop moving around.

Contikirpl-screenshot-6.png

Click on the Network tab to explore the parameters in the network. Click the <All> item on the top left to select all nodes.

Contikirpl-screenshot-7.png

The Node Info tab has more information about the nodes.

Contikirpl-screenshot-8.png

The Power tab shows the power consumption of the nodes in the network.

Contikirpl-screenshot-9.png

[edit] Set up your own simulation

Now that we know how a running simulation looks like, we can set up our own. We will use the same example C code as in the previous simulation, but we will set up the simulation ourselves.

[edit] Create a new simulation

Close the Cooja window that we previously opened. Open a new Cooja.

When Cooja has started, select the New simulation menu item on the File menu.

Contikirpl-screenshot-10.png

Create a new simulation. Give it a nice name.

Contikirpl-screenshot-11.png

[edit] Create the sink node

We now create the sink node.

When the new simulation has opened, click on the Mote Types menu, select the Create mote type menu item, and the Sky Mote Type item.

Contikirpl-screenshot-12.png

Give the mote type a name, and click on the Browse button.

Contikirpl-screenshot-13.png

Go to the directory contiki-2.x/examples/ipv6/rpl-collect and select the udp-sink.c file. This file contains the code for the sink node.

Contikirpl-screenshot-14.png

Click the Compile button to compile the sink code.

Contikirpl-screenshot-15.png

When the Compilation is complete, the Compile button has changed into a Create button. Click this button.

Create one sink node.

Contikirpl-screenshot-16.png

[edit] Create sender nodes

Next, we create the sender nodes. We create a new mote type for this. We use the Sky Mote Type as before.

Contikirpl-screenshot-17.png

The sender node uses the udp-sender.c file from the same directory as the sink node. Click the Compile and Create buttons.

Contikirpl-screenshot-18.png

Create a few nodes – say, 8.

Contikirpl-screenshot-19.png

[edit] Show mote types in simulation visualizer

In the Simulation Visualizer window, open the visualizer skin menu. Select Mote IDs and Mote Type. This will show the node ID of the nodes in the window and will color the nodes differently depending on what mote type they are. In this example, we have two mote types, one sink mote type and one sender mote type.

Contikirpl-screenshot-20.png

[edit] Start the CollectView program

Right click on the sink node. The sink node has node ID 1 and is green. Click the Open mote plugin menu. Select the Collect View menu item.

Contikirpl-screenshot-21.png

This brings up the CollectView window.

Contikirpl-screenshot-22.png

[edit] Start the simulation

Click on the Cooja window in the background and start the simulation.

Contikirpl-screenshot-23.png

[edit] View the data

Let the simulation run for 100000 ms or so, then bring up the CollectView window again. The sensors should now have begun reporting data. The Node Info tab has information about the nodes. As before, explore the other tabs as well.

Contikirpl-screenshot-24.png

Personal tools