= 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. [[PageOutline(2-4,Table of Contents,inline)]] == 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 and other Contiki related resources. == Operating System (ubuntu) == If you have fresh copy of Ubuntu operating system, to install msp430 tool chain perform the following steps. $ gksudo gedit /etc/apt/sources.list --> remove all # before source lists $ sudo ldconfig $ sudo apt-get update $ 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 === [[Image(setup.JPG, 50%, center)]] ==== Initial Steps to setup the Bridge ==== Open the 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 Reboot/logout and login back on the system ==== Build a bridge ==== 1. Disable the WLAN before building the bridge. 2. 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 3. Install radvd in your Ubuntu Linux * $ sudo apt-get install radvd 4. 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 10; MaxRtrAdvInterval 15; AdvDefaultLifetime 45; prefix aaaa::/64 { AdvOnLink on; AdvAutonomous on; AdvPreferredLifetime 4294967295; AdvValidLifetime 4294967295; }; }; }}} 5. 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). 6. Enable WLAN === Setting up the IPv6 GOGO6 Tunnel === To setup the IPv6 tunnel, there are following steps needs to be performed: I. Create an account on the [http://gogonet.gogo6.com] to access the Greenet6 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 can be used in go6.conf file, when we setting the ipv6 tunnel. * Download the gogoCLIENT for your System, In our case we have Ubuntu so 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. II. 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 2. Compile the gogoCLIENT. /temp/gw6c-6_0_1$ make all 3. 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 4. 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. 5. 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 Whole gw6c.conf file is at the end of this document. 6. Run the gw6c client * /usr/local/gw6c/bin$ sudo ./gw6c This command let the bridge run in the background process. You can open new terminal to program the node with the sensei-application. 7. 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) }}} 8. 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 **Note: The tun is the IPv6 interface with the global address, which provide IPv6 interface to access the external world: [2001:5c0:1400:b::6213] == 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 2. Copy binaryws/ and sensei/ folders from svn (node-contiki/apps/) to contiki-2.4/apps/ * /Sensei-WP5$ cp -r node-contiki/apps/sensei/ ../contiki2.4/apps/ * /Sensei-WP5$ cp -r node-contiki/apps/binaryws ../contiki2.4/apps/ 3. Copy cxmac files in order to enable nodes mobility * /Sensei-WP5$ cp node-contiki/core/net/mac/cxmac.* ../contiki2.4/core/net/mac/ 4. 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/ 5. Compile and program a node * contiki-2.4/examples/sensei$ make sensei.upload 6. 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 === This section describes 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 = binaryws sensei #folders that you want to include from contiki-2.4/apps/ DEFAULT_TARGET=sky CONTIKI = ../.. include $(CONTIKI)/Makefile.include }}} ==== /apps/binaryws ==== If the binaryws folder already exists, you can skip the following steps: 1. Create a directory in /apps/binaryws 2. The binaryws directory should contains libBWS.c and libBWS.h file. 3. If there is no Makefile.binaryws in the /binaryws folder, create a file “Makefile.binaryws” in the binaryws folder. 4. Then into /apps/binaryws/Makefile.binaryws file write your source file as follows: binaryws_src = libBWS.c **Note that libBWS.c should have a line: #include "libBWS.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. 2. Then into /apps/binaryws/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, usually between 5 and 15 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/rssi Where, 0212-7400-10c5-51f7 is the EUI-64 address of the node. }}} **p – Parameter resource **a – Actuator resources **s – Sensor resources