Analyse of a real 6LoWPAN network using a Contiki-based sniffer module

From Contiki
Jump to: navigation, search

Back to Contiki Tutorials


  • This tutorial is an introduction to IP-based sensor networks with Contiki.
  • Contiki has supported IP networking, through the uIP TCP/IP stack, since its first released in 2003. In 2008, Cisco released the world's smallest IPv6 stack, called uIPv6, for Contiki.
  • 6LoWPAN: is an acronym of IPv6 over Low power Wireless Personal Area Networks. The 6LoWPAN group has defined encapsulation and header compression mechanisms that allow IPv6 packets to be sent to and received over IEEE 802.15.4 based networks.
  • Basics of working with IPv6:
+ First thing to know is the fact that IPv6 addresses contain several zeros that can be shortened in several forms, such as-
FE80:0000:0000:0000:0000:0000:0000:F123 = FE80:0:0:0:0:0:0:F123 = FE80::F123
+ Additionally, the huge address space of IPv6 allows devices to have serverl addresses used for various purposes (for example, local communication, global communication)
The loopback address (::1) is a similar address than in IPv4 used to check the status of the interface (is good for checking if you have enabled IPv6 in your OS).
The local-link addresses (FE80::/10) is used to communicate with devices in the same link (however, the link can be extended with Layer 2 switches).
The global addresses (everything else) are used for communicating devices globally.
6LoWPAN Wireless Sensor Network

You will learn

This tutorial will walk you through the steps of setting up Contiki to sniff real time 6LoWPAN packets and visualize a wireless sensor network (WSN) in an interactive environment of Foren6. You will deploy Collect-view application on Tmote-Sky motes and sniff the packets on particular RF channel (1-26) (Note: In Contiki RF Channel range from 11-26) on a Tmote-Sky. Thus you should have atleast 3 Tmote-sky motes and system with Ubuntu/Mac OS on it. You will install Foren6 and learn how to integrate a Tmote-sky sniffer with real-time diagnosis tool.

Foren6: A 6LoWPAN Diagnosis tool

Real layout of WSN

Foren6 is an effort to provide a noReal layout of WSNn-intrusive 6LoWPAN network analysis tool. It leverages passive sniffer devices to reconstruct a visual and textual representation of network information to support real-world Internet of Things applications where other means of debug (cabled or network-based monitoring) are too costly or impractical.

  • Foren6 uses sniffers to capture 6LoWPAN traffic and renders the network state it in a GUI.
  • Foren6 captures all RPL-related information and identifies abnormal behaviors.
  • Multiple sniffers can be combined for extended coverage.
  • Rewind the packet capture history, replay a previous packet trace and navigate through different overlays to pinpoint problems.

Installation guide for Contiki and Foren6


  • System with Linux/MacOS X
  • For the purpose of this tutorial it is assumed that you already have a working Contiki 2.7 environment set up on your system and have access to at least 3 Tmote-Sky motes. Otherwise follow this link -

Foren6 Installation:

  • Dependencies
sudo apt-get install -y libqt4-dev qt4-qmake cmake make libexpat1-dev tshark libpcap0.8-dev libc6-dev g++ gcc
  • Get the Source
git clone
  • Install Foren6
cd foren6
sudo make install

Configuring the sniffer for real time capture

  • Setting user permissions:
On Linux, you should configure permissions for the user to access the USB serial devices – it is much better practice then launching Foren6 as root. To grant access to a user account, add that user to the 'dialout’ group:
sudo adduser <username> dialout
Then, restart your session to apply the modifications.
  • Programming the sniffer:
Download the sniffer source
git clone
cd contiki
git checkout sniffer
  • Connect Tmote-sky and upload the sniffer application
make TARGET=sky savetarget sniffer.upload

Setting up the experiment

  • Follow the below tutorial and program one Tmote-sky as udp-sink and 2 as udp-senders.
  • Place the nodes in the environment and connect the sniffer mote to your machine.
  • Launch Foren6 and select the sniffer as input device:
Foren6: Manage Sniffers
+ Open the 'Manage Sources’ dialog by clicking the Manage Sources button in the Toolbar or from the 'File’ menu.
+ In this dialog, remove any existing entries in the top section by selecting each individual element and hitting the 'Remove’ button.
+ Next, add a new source by specifying the three fields as shown below:
  • Target: type the path to the USB device (example: /dev/ttyUSB0)
Tip: You can find out about the device by the command $ ls /dev/
  • Channel: the integer value of the Channel you want to snif (1 to 26)
Tip: To find out the channel the collect-view Tmote-sky platform is using, go to the file contiki/platform/sky/contiki-conf.h and search for the following
#ifndef RF_CHANNEL
#define RF_CHANNEL              26
#endif /* RF_CHANNEL */
By default it is generally 26, but may vary between 11-26.
  • Type: select snif
+ Click the Add button when the above information is entered. If the device is found by the application, it will appear in the list of available device. If your device exists but you get an error at this point, is it likely that the user running Foren6 does not have permission to access that serial device. See the above instructions to grant user permissions, or launch the foren6 application as root (not recommended) or use the command- sudo chmod 777 /dev/ttyUSBx.
+ Hit the Close button to return to the main window.
  • Click the Start button to capture packets.
  • Timeline should start ticking and new packets will appear in the Event Window. If the packets are properly formatted, the network visualiser will display the sniffed nodes, and connect them to form a reconstructed RPL graph based on the sniffed information.


  • The left pane is Node information window contains information such as 802.15.4 Mac address, IPv6 addresses, RPL configuration, RPL operational data, Statistics, Errors and Routing table.
  • Window tool-bar can help you add dockable packet dissector and dockable event widget in the Foren6 GUI.
  • By default the background is white, but you can load layouts of your environment and manually place the motes in its location.
Foren6 Rank Depth

  • Real time network visualization in Foren6 with Overlay Rank Depth.
Foren6 Node Traffic 1
Foren6 Node Traffic 2
  • Real time network visualization in Foren6 with Overlay Node Traffic.


  • Foren6 is a powerful 6LoWPAN diagnosis tool. We can exploit it to understand the working of RPL and how control messages flows in the WSN.
  • Other features like Overlays in Foren6 allow to customize the network visualizer according to a certain metric or parameter. This helps in understanding and debugging the network.
  • As tcpdump is powerful tool in wired networks, packet sniffing can be considered as equivalent tool in WSN.

Future Scope

  • You can also use Cooja (Network Simulator) to analyze an network. In Cooja use "Radio Message with a 6LoWPAN analyzer with pcap export" to store the packet capture in pcap format. Thus you can then use Wireshark or Foren6 to visualize the network and debug it.
Tip: You will find the pcap file in contiki/tools/cooja/build/radiolog-xxxxxxx.pcap
  • Use multiple sniffers and experiment to visualize the real time flow of packets in wireless sensor networks. This will increase robustness and coverage area of the network.

Understanding 6LoWPAN network: More about Foren6, Video:

Back to Contiki Tutorials