Saturday, December 20, 2014

Using RPL in Contiki

When working on a sensor network application or an evaluation of a research work, sometimes we need to have a network setup which runs RPL routing protocol on sensor nodes. If we are working on Contiki OS platform, we are lucky to have not only the implementation of RPL protocol but also some sample applications which use RPL. To understand it, the best example would be simple-udp-rpl which resides in the path contiki-2.7/examples/ipv6/simple-udp-rpl of contiki source code. There are two source files inside this directory which draw our attention. First one is unicast-receiver.c file which is the receiver of unicast messages in the RPL routing tree and therefore behaves as the root node. The second file is unicast-sender.c which implements a unicast sending functionality to the root node of the RPL routing tree.

The best way to easily try out RPL on Contiki is to use Cooja simulator. First, we need to start Cooja simulator by moving into the contiki-2.7/tools/cooja directory from a linux terminal and issuing the command ant run. It will start Cooja simulation window and then we need to start a new simulation as usual. When adding motes, first we should add a Sky mote and browse and select unicast-receiver.c file as the program code to run on this mote. This will be our root node of the RPL tree. Then again add few other Sky motes but this time, use the file unicast-sender.c as the application code allowing them to be sender nodes in the RPL tree. To witness how packets from sender nodes traverse through the RPL tree over multiple hops to the root node, it would be better to keep some nodes out of the radio range of root node so that they are only accessible through some other forwarder nodes in the tree. The first figure depicts my node setup in the simulation.

After setting up the simulation with nodes with relevant applications, we can start simulation  by clicking on the Start button of Cooja simulator. After a while all the nodes started up with Contiki OS, we will start to see that every sender node periodically transmits a packet which travel through the RPL tree to the root node. Both sender and receiver nodes prints a string about these events which can be evident from the mote output window of Cooja simulator. Second figure in this article depicts some excerpt from the mote output window with sender and receiver message logs. Even though the RPL implementation of Contiki OS is a bit complicated to understand easily, these two simple sender and receiver applications would be helpful if we need to setup a scenario where we need our nodes to simply communicate using RPL without too much troubles.



  1. good.
    how to print the received sensor readings from sender.

  2. can u explain the coding of RPL implementation..?