wiki:node-contiki

Version 44 (modified by petsku, 13 years ago) (diff)

--

Node-contiki

This guide describes how to setup an IPv6 tunnel and configure a Linux for routing traffic to and from a sensor network running Contiki and IPv6/6LoWPAN. This guide is best suited for Ubuntu Linux.

Table of Contents

  1. Introduction
  2. Operating System (Ubuntu)
  3. Enabling connectivity between sensor network and IPv6 network
    1. Download Contiki-2.4
    2. Bridge overview
      1. Initial Steps to setup the Bridge
      2. Build a bridge
    3. Setting up the IPv6 GOGO6 Tunnel
  4. Download the Code from SVN
  5. Program Tmote Sky node with contiki-2.4 and Sensei components
    1. Program Tmote Sky node with binary file
    2. Link files in Contiki using Makefiles
      1. contiki-2.4/examples/sensei-example/
      2. /apps/coap
      3. /apps/sensei
  6. Run the Gateway
  7. Test the SENSEI Components over the Web
  8. Attachements

Introduction

This guide describes the steps how to program contiki-2.4 with sensei components to a node.

NOTE: The information related to the bridge and Contiki OS is taken from Contiki website (www.sics.se/contiki/) and other Contiki related resources.

Operating System (Ubuntu)

If you have fresh copy of Ubuntu operating system, install the following packets.

$ sudo apt-get install subversion wireshark radvd

Download the (msp430-tmote-tools-contiki) folder from http://www.ee.oulu.fi/~ikram/

Install msp430-tools:
sudo dpkg -i msp430tools-*.deb
sudo nano /home/sensei/.profile
export PATH=$PATH:/opt/msp430/bin:/opt/msp430/lib

Enabling connectivity between sensor network and IPv6 network

Download Contiki-2.4

Download Contiki-2.4 release source code (contiki-2.4.zip) from (http://www.sics.se/contiki/download.html) and extract it with a command:

$ unzip contiki-2.4.zip

Bridge overview

Initial Steps to setup the Bridge

Open a terminal on Ubuntu.

IPv6 forwarding must be enabled before running the bridge. $ sudo nano /etc/sysctl.conf

Uncomment the line which contains: net.ipv6.conf.default.forwarding=1

Logout of the Ubuntu and log back in.

Build a bridge

  1. Disable the WLAN before building the bridge.
  1. First you will need to program a TelosB/Tmote Sky, or similar node with a IEEE 802.15.4 compliant bridge. The bridge is available in contiki-2.4/tools/sky/uip6-bridge/uip6-bridge-tap.c and you upload the code with the following steps:
  • $ cd contiki-2.4/tools/sky/uip6-bridge
  • $ make uip6-bridge-tap.upload
  1. Create a file /etc/radvd.conf and copy the following lines to that file
interface tap0 {
     AdvSendAdvert on;
     AdvLinkMTU 1280;
     AdvCurHopLimit 128;
         AdvReachableTime 360000;
         MinRtrAdvInterval 3;
         MaxRtrAdvInterval 5;
         AdvDefaultLifetime 15;
         prefix aaaa::/64
     {
         AdvOnLink on;
         AdvAutonomous on;
         AdvPreferredLifetime 4294967295;
         AdvValidLifetime 4294967295;
     };
};
  1. Build a bridge
  • $ cd contiki-2.4/tools/sky/uip-bridge
  • $ make connect

  • $ shift+ctrl+t (opens a new terminal tap)
  • $ make bridge

Now the bridge node and the Linux should be a router for your IPv6 enabled sensor nodes. Make sure you have some nodes (JCreate, Tmote Sky, Raven LCD, etc) with some IPv6 software and then try to ping some of your nodes with ping6 and see what happens! Notice that you have to add %tap0 after the IPv6 address, in order to use the right interface, e.g.:

  • $ ping6 fe80::0212:7400:10cf:a5c9%tap0

Note: if you run "tcpdump -i tap0" you will see the IP addresses of your nodes when they ask for routers (Router Solicitation).

  1. Enable WLAN

Setting up the IPv6 GOGO6 Tunnel

To setup the IPv6 tunnel, following steps need to be performed:

Create an account on the http://gogonet.gogo6.com to access the Freenet6 website. Follow the link: http://gogonet.gogo6.com/page/freenet6-tunnelbrokerdownloadthegogoCLIENT

To get a static IPv6 address or get a /56 network you need to get an account on the Freenet6 server. Create your account at this page: http://gogonet.gogo6.com/page/freenet6-registration. Remember that this username and password is used in go6.conf file, when configuring the IPv6 tunnel.

Download the gogoCLIENT for your System. This tutorial assumes Ubuntu is used, hence download the Client 6.0 Source Code (Linux/Unix?/MacOS/BSD). http://gogonet.gogo6.com/page/download-1

Follow the HEX_DC_0005_Gateway6_Client_Guide.pdf (page-61) contained in the gw6c package for the installation on your Ubuntu machine. But for simplicity the steps are as follow.

Complete the following steps to install the gogoCLIENT from the source code:

  1. Retrieve the source code (*.tgz or *.zip) and decompress it to a temporary directory.

/temp$ tar –xf gw6c-6_0-RELEASE-src.tar

  1. Compile the gogoCLIENT.

/temp/gw6c-6_0_1$ make all

  1. To install the gogoCLIENT in the /usr/local/gw6c directory with the necessary files, run the following command:

/gw6c-6_0_1$ make installdir=/usr/local/gw6c install

  1. Executing the gogoCLIENT requires the files listed below:
  • The gw6c binary file (gw6c) located in the bin directory.
  • A sample gw6c.conf file.
  • The template subdirectory containing the operating system scripts.
  1. In order to run the IPv6 tunnel as DNS, setup gw6c.conf file; the setting for the usr/local/gw6c/bin/gw6c.conf

Suppose we create an account with username.

username: sensei-oulu
password: *******

$ sudo nano gw6c.conf

Change the following configurations:

userid=sensei-oulu
passwd=*******
server=authenticated.freenet6.net
auth_method=any

Other configurations: leave as default

Note: Whole gw6c.conf file is at the end of this document.

  1. Run the gw6c client
  • /usr/local/gw6c/bin$ sudo ./gw6c

Leave IPv6 tunnel running, and open a new terminal to program the node with the sensei-application.

  1. To verify whether the gw6c created another interface with IPv6 address; use the command
  • $ifconfig -> The output should be similar to this:
    tun     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
              inet6 addr: 2001:5c0:1400:b::6213/128 Scope:Global
              UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1280  Metric:1
              RX packets:53 errors:0 dropped:0 overruns:0 frame:0
              TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:3048 (3.0 KB)  TX bytes:2632 (2.6 KB)
    
  1. Verify that a domain name corresponds to IPv6 address
  • $ nslookup 2001:5c0:1400:b::6213

In this case, output should give sensei-oulu.broker.freenet6.net -address

Download the Code from SVN

$ svn --username [username]  co https://svn-batch.grid.pub.ro/svn/Sensei-WP5/

[The above command if ask for some security certificate exchange; Accept it [yes]]
[otherwise it prompt for the password for svn access]
Enter your password.

If you have a working copy of Sensei-WP5/ already, you can just updated it:

  • /Sensei-WP5$ svn up

Copy the latest version of the gateway on your machine for experiment.

  • $ cp –r /Sensei-WP5/gateway/ ../

Program Tmote Sky node with contiki-2.4 and Sensei components

  1. Download and install Contiki-2.4 as instructed in Section 3.1

Note: If you want to program a node with source code, please continue to step 2. If you don't need source code or you don't have access to the Sensei SVN, you can program a node with binary file with less steps. If you choose to program a node with binary file, please move to Section "Program Tmote Sky node with binary file".

  1. Copy coap/ and sensei/ folders from svn (node-contiki/apps/) to contiki-2.4/apps/
  • /Sensei-WP5$ cp -r node-contiki-coap/apps/sensei/ ../contiki-2.4/apps/
  • /Sensei-WP5$ cp -r node-contiki-coap/apps/coap ../contiki-2.4/apps/
  1. Copy sicslowmac files in order to enable nodes mobility
sicslowmac.c
sicslowmac.h

/Sensei-WP5$ cp node-contiki/core/net/mac/sicslowmac.* ../contiki2.4/core/net/mac/

  1. Change MAC driver in Contiki

contiki-2.4$ gedit platform/sky/contiki-conf.h

Replace a line
#define MAC_CONF_DRIVER cxmac_driver
with
#define MAC_CONF_DRIVER sicslowmac_driver

  1. Copy sensei-example/ folder from svn (node-contiki/examples/sensei-example) to

contiki-2.4/examples/

  • /Sensei-WP5$ cp -r node-contiki/examples/sensei-example ../contiki2.4/examples/
  1. Compile and program a node
  • contiki-2.4/examples/sensei$ make sensei.upload

Program Tmote Sky node with binary file

  1. Make a new folder to examples/

contiki-2.4/examples$ mkdir sensei

  1. Download binary file and Makefile from a website and put them to the sensei folder, which was created in the previous step
  • www.ee.oulu.fi/~ikram/sensei.sky
  • www.ee.oulu.fi/~ikram/Makefile
  1. Program a node
  • contiki-2.4/examples/sensei$ make sensei.upload


Note: In case you want to put debug prints into the code, you can see them in serial dump

  • contiki-2.4/examples/sensei$ ../../tools/sky/serialdump-linux -b115200 /dev/ttyUSB0


Link files in Contiki using Makefiles

If you download the code from SVN, then you do not need to follow this subsection. This section simply explain the steps how to link multiple files in Contiki OS using Makefiles.

contiki-2.4/examples/sensei-example/

There are at least two files in /examples/sensei-example/ : sensei.c and Makefile

Makefile should include following lines:

all: sensei
APPS = coap sensei		#folders that you want to include from contiki-2.4/apps/
DEFAULT_TARGET=sky 
CONTIKI = ../.. 
include $(CONTIKI)/Makefile.include 

/apps/coap

If the coap folder already exists, you can skip the following steps:

  1. Create a directory in /apps/coap
  2. The coap directory should contains coap.c and coap.h file.
  3. If there is no Makefile.coap in the /coap folder, create a file “Makefile.coap” in the coap folder.
  4. Edit the /apps/coap/Makefile.coap file write your source file as follows:

coap_src = coap.c

Note that coap.c should have a line: #include "coap.h"

/apps/sensei

If the sensei folder already exists, you can skip the following steps:

  1. Create a directory in /apps/sensei

The sensei directory should contain the following files.

	Makefile.sensei 
	actuator.c 
	actuator.h 
	parameter.c 
	parameter.h 
	rai.c 
	rai.h 
	rpi.c 
	rpi.h 
	sensor.c 
	sensor.h 
	subscription.c 
	subscription.h

If there is no Makefile.sensei in the /sensei folder, create a file "Makefile.sensei" in the sensei folder.

  1. Then into /apps/sensei/Makefile.sensei file write your source file as follows:
    sensei_src = rai.c rpi.c actuator.c sensor.c parameter.c subscription.c
    

Run the Gateway

It is assumed that the bridge is working as background process on the system. Do the following steps to run the gateway.

  • If you do not have any one these packages, install them first.
$sudo apt-get install g++ libssl-dev libxml2-dev

>> Install socket++ library

$ cd gateway/lib/Socket-2.3.7
gateway/lib/Sockets-2.3.7$ make clean
gateway/lib/Sockets-2.3.7$ make 
gateway/lib/Sockets-2.3.7$ sudo make install

$ sudo ip6tables –F 	(disables IPv6 tables – firewall setting for IPv6)

>> Compile gateway code

/gateway$ make

  • In case of errors in the compilation process:
    /gateway$ cd src/
    /gateway/src/$ nano Makefile
    
    >> Remove local/ from libxml2 path: Change
    
    INCLUDES = -I/usr/local/include/Sockets -I./plugin-skeleton -I./libBWS -I/usr/local/include/libxml2
    
    to
    
    INCLUDES = -I/usr/local/include/Sockets -I./plugin-skeleton -I./libBWS -I/usr/include/libxml2
    

Save Makefile and try to make gateway again

/gateway$ ./bin/sensei-gateway -p 8000 -s sensei-oulu.broker.freenet6.net -d oulu.fi -w island
  • Last command starts the gateway, keep it running in the terminal.

Turn on the node(s) that you programmed in Section 3.5. Node sends its resource description after it receives router advertisements. This time depends on radvd.conf settings, in this tutorial it was set between 3 and 5 seconds. Gateway prints the resource description when it is received.

Test the SENSEI Components over the Web

Open a browser; be sure that your browser supports IPv6 address.

Test the following URL: You can see all the available resources available at this address. http://sensei-oulu.broker.freenet6.net:8000

To access the available resource; use the following address, e.g.,

http://sensei-oulu.broker.freenet6.net:8000/0212-7400-10c5-51f7/p/battery

http://sensei-oulu.broker.freenet6.net:8000/0212-7400-10c5-51f7/a/led1

http://sensei-oulu.broker.freenet6.net:8000/0212-7400-10c5-51f7/s/temp

Where, 0212-7400-10c5-51f7 is the EUI-64 address of the node. 

p – Parameter resource

a – Actuator resources

s – Sensor resources

Attachements

  1. gogoc.conf
#-----------------------------------------------------------------------------
# $Id: gw6c.conf.in,v 1.10 2009/03/13 01:14:37 carl Exp $
#-----------------------------------------------------------------------------

##########################      READ ME!      ################################
#
# Welcome to the Gateway6 Client configuration file.
# In order to use the client, you need to modify the 'userid', 'passwd' and 
# 'server' parameters below depending on which of these situations applies:
# 
# 1. If you created a Freenet6 account, enter your userid and password below. 
#    Change the server name to "broker.freenet6.net" and auth_method to 'any'.
# 2. If you would like to use Freenet6 without creating an account, 
#    do not make any modifications and close this file. 
# 3. If this software was provided by your ISP, enter the userid, password and 
#    server name provided by your ISP below. 
#


########################## BASIC CONFIGURATION ################################

#
# User Identification and Password:
#   Specify your user name and password as provided by your ISP or Freenet6.
#   If you plan to connect anonymously, leave these values empty.
#   NOTE: Change auth_method option if you are using a username/password.
#
#   userid=<your_userid>
#   passwd=<your_password>
#
userid= mobile-island1
passwd=*******

#
# Gateway6 Server:
#   Specify a Gateway6 server name or IP address (provided by your ISP or 
#   Freenet6). An optional port number can be added; the default port number 
#   is 3653.
#  
#   Examples:
#     server=hostname # FQDN
#     server=A.B.C.D  # IPv4 address
#     server=[X:X::X:X] # IPv6 address
#     server=hostname:port_number  
#     server=A.B.C.D:port_number
#     server=[X:X::X:X]:port_number
#
#   Freenet6 account holders should enter authenticated.freenet6.net,
#   otherwise use anonymous.freenet6.net.
#   Your ISP may provide you with a different server name. 
#
#server=anonymous.freenet6.net
server=authenticated.freenet6.net

#
# Authentication Method:
#
#  auth_method=<{anonymous}|{any|passdss-3des-1|digest-md5|plain}>
#
#   anonymous:      Sends no username or password
#
#   any:            The most secure method will be used. 
#   passdss-3des-1: The password is sent encrypted.
#   digest-md5:     The password is sent encrypted.
#   plain:          Both username and password are sent as plain text.
#
# Recommended values:
#   - any:          If you are authenticating a username / password.
#   - anonymous:    If you are connecting anonymously.
#
#auth_method=anonymous
auth_method=any


########################## ROUTING CONFIGURATION ##############################
# Use these parameters when you wish the client to act as a router and provide 
# IPv6 connectivity to IPv6-capable devices on your network.

#
# Local Host Type:
#   Change this value to 'router' to enable IPv6 advertisements.
#
#   host_type=<host|router>
#
host_type=host

#
# Prefix Length:
#   Length of the requested prefix. Valid values range between 0 and 64 when 
#   using V6*V4 tunnel modes, and between 0 and 32 when using V4V6 tunnel mode.
#
#   prefixlen=<integer>
#
prefixlen=64

#
# Advertisement Interface Prefix:
#   Name of the interface that will be configured to send router advertisements. 
#   This is an interface index on Windows (ex: 4) and a name on Linux
#   and BSD (ex: eth1 or fxp1). 
#
#   if_prefix=<interface name>
#
if_prefix=

#
# DNS Server: 
#   A DNS server list to which the reverse prefix will be delegated. Servers
#   are separated by the colon(:) delimiter.
#
#   Example: dns_server=ns1.domain:ns2.domain:ns3.domain
#
dns_server=


######################### ADVANCED CONFIGURATION ##############################

#
# Gateway6 Client Installation Directory:
#   Directory where the Gateway6 Client will be installed. This value has been 
#   set during installation.
#
gw6_dir=/usr/local/gw6c

#
# Auto-Retry Connect, Retry Delay and Max Retry Delay:
#  When auto_retry_connect=yes, the Gateway6 Client will attempt to reconnect
#  after a disconnection occurred. The time to wait is 'retry_delay' and that
#  delay is doubled at every 3 failed consecutive reconnection attempt.
#  However, the wait delay will never exceed retry_delay_max.
#
#
#   auto_retry_connect=<yes|no>
#   retry_delay=<integer: 0..3600>
#   retry_delay_max=<integer: 0..3600>
#
#   Recommended values: "yes", 30, 300
#
auto_retry_connect=yes
retry_delay=30
retry_delay_max=300

#
# Keepalive Feature and Message Interval:
#   Indicates if and how often the client will send data to keep the tunnel 
#   active.
#
#   keepalive=<yes|no>
#   keepalive_interval=<integer>
#
#   Recommended values: "yes" and 30
#
keepalive=yes
keepalive_interval=30

#
# Tunnel Encapsulation Mode:
#   v6v4:    IPv6-in-IPv4 tunnel.
#   v6udpv4: IPv6-in-UDP-in-IPv4 tunnel (for clients behind a NAT).
#   v6anyv4: Lets the broker choose the best mode for IPv6 tunnel.
#   v4v6:    IPv4-in-IPv6 tunnel.
#
#   Recommended value: v6anyv4
#
tunnel_mode=v6anyv4

#
# Tunnel Interface Name:
#   The interface name assigned to the tunnel. This value is O/S dependent.
#
#   if_tunnel_v6v4 is the tunnel interface name for v6v4 encapsulation mode
#   if_tunnel_v6udpv4 is the tunnel interface name for v6udpv4 encapsulate mode
#   if_tunnel_v4v6 is the tunnel interface name for v4v6 encapsulation mode
#
#   Default values are set during installation.
#
if_tunnel_v6v4=sit1
if_tunnel_v6udpv4=tun
if_tunnel_v4v6=sit0

#
# Local IP Address of the Client:
#   Allows you to set a specific address as the local tunnel endpoint.
#
#   client_v4=<auto|A.B.C.D (valid ipv4 address)>
#   client_v6=<auto|X:X::X:X (valid ipv6 address)>
#     auto: The Gateway6 Client will find the local IP address endpoint.
#
#   Recommended value: auto
#
client_v4=auto
client_v6=auto

#
# Script Name:
#   File name of the script to run to install the tunnel interface. The 
#   scripts are located in the template directory under the client 
#   installation directory. 
#
#   template=<checktunnel|freebsd|netbsd|openbsd|linux|windows|darwin|cisco|solaris>
#
#   Default value is set during installation.
# 
template=linux

#
# Proxy client: 
#   Indicates that this client will request a tunnel for another endpoint, 
#   such as a Cisco router. 
#
#   proxy_client=<yes|no>
#
#   NOTE: NAT traversal is not possible in proxy mode. 
#
proxy_client=no


############################ BROKER REDIRECTION ###############################

#
# Broker List File Name:
#   The 'broker_list' directive specifies the filename where the broker
#   list received during broker redirection will be saved. 
#
#   broker_list=<file_name>
#  
broker_list=tsp-broker-list.txt

#
# Last Server Used File Name:
#   The 'last_server' directive specifies the filename where the address of
#   the last broker to which a connection was successfully established will 
#   be saved.
#
#   last_server=<file_name>
#
last_server=tsp-last-server.txt

#
# Always Use Last Known Working Server:
#   The value of the 'always_use_same_server' directive determines whether the 
#   client should always try to connect to the broker found in the 
#   'last_server' directive filename. 
#
#   always_use_same_server=<yes|no>
#
always_use_same_server=no


#################################### LOGGING ##################################

#
# Log Verbosity Configuration:
#   The format is 'log_<destination>=level', where possible values for 
#   'destination' are:
#
#   - console  (logging to the console [AKA stdout])
#   - stderr   (logging to standard error)
#   - file     (logging to a file)
#   - syslog   (logging to syslog [Unix only])
#
#   and 'level' is a digit between 0 and 3. A 'level' value of 0 disables 
#   logging to the destination, while values 1 to 3 request increasing levels 
#   of log verbosity and detail. If 'level' is not specified, a value of 1 is 
#   assumed.
#
#   Example:
#     log_file=3   (Maximal logging to a file)
#     log_stderr=0 (Logging to standard error disabled)
#     log_console= (Minimal logging to the console) 
#
#   - Default configuration on Windows platforms:
#
#     log_console=0
#     log_stderr=0
#     log_file=1
#
#   - Default configuration on Unix platforms:
#
#     log_console=0
#     log_stderr=1
#     log_file=0
#     log_syslog=0
#
#log_console=
#log_stderr=
#log_file=
#log_syslog=

#
# Log File Name:
#   When logging to file is requested using the 'log_file' directive, the name
#   and path of the file to use may be specified using this directive.
#
#   log_filename=<file_name>
#
log_filename=gw6c.log

#
# Log File Rotation:
#   When logging to file is requested using the 'log_file' directive, log file 
#   rotation may be enabled. When enabled, the contents of the log file will 
#   be moved to a backup file just before it reaches the maximum log file size 
#   specified via this directive.
#
#   The name of the backup file is the name of the original log file with 
#   '.<timestamp>' inserted before the file extension. If the file does not 
#   have an extension, '.<timestamp>' is appended to the name of the original
#   log file. The timestamp specifies when the rotation occurred.
#
#   After the contents of the log file have been moved to the backup file, the 
#   original file is cleared, and logging resumes at the beginning of the file. 
#
#   log_rotation=<yes|no>
#
log_rotation=yes

#
# Log File Rotation Size:
#   The 'log_rotation_size' directive specifies the maximum size a log file may 
#   reach before rotation occurs, if enabled. The value is expressed in 
#   kilobytes.
#
#   log_rotation_size=<16|32|128|1024>
#
log_rotation_size=32

#
# Deletion of rotated log files:
#   The 'log_rotation_delete' directive specifies that no log backup will be
#   kept. When rotation occurs, the file is immediately wiped out and a new 
#   log file is started.
#
#   log_rotation_delete=<yes|no>
#
log_rotation_delete=no

#
# Syslog Logging Facility [Unix Only]:
#   When logging to syslog is requested using the 'log_syslog' directive, the 
#   facility to use may be specified using this directive.
#
#   syslog_facility=<USER|LOCAL[0-7]>
#
syslog_facility=USER


# end of gw6c.conf
#------------------------------------------------------------------------------

Attachments (8)

Download all attachments as: .zip