Showing posts with label rpl. Show all posts
Showing posts with label rpl. Show all posts

Monday, June 2, 2014

Border Router with Raspberry Pi for LLN with TelosBs

This tutorial aims to create a IPv6 Low-power and Lossy Network (LLN) of TelosB motes with a Rapsberry Pi (RPi) as a border router (LBR) to connect to other IPv6 networks. RPi is configured for routing traffic from the LLN to other IPv6 networks by creating a TUN network interface. An alternative to setup a LLN is to configure a bridge (TAP) as in Cetic-6LBR (https://github.com/cetic/6lbr/)

We are going to have two IPv6 networks associated to two network interfaces of the LBR RPi as shown in Fig.1.

Fig.1: Deployment


LBR
- eth0: bbbb::1/64 (Physical Ethernet interface to normal IPv6 network)
- tun0: aaaa::1/64 (TUN interface to LLN)

IPv6 Network:
- bbbb::2

LLN:
- aaaa::212:7400:13cb:44 (slip-radio)
- aaaa::212:7400:13cb:101a
- aaaa::212:7400:13ca:f3ac

1. LLN Network (see here)

- Flash radio-slip mote (contiki-2.7/examples/ipv6/slip-radio) to use as an IEEE 802.15.4 interface
- Flash other TelosB for LLN nodes (e.g., contiki-2.7/examples/ipv6/udp-server)

2. IPv6 Network
- Configure a machine with bbbb::/64 address (example with a Linux)
# sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet6 static
address bbbb::2
netmask 64
gateway bbbb::100 (border router address)

(you may need to deactivate other network interfaces to check if it works properly)

3. RPi Border Router
Prepare RPi OS
- Download Raspbian

- Create a boot disk using SD card (>4G) using Win32 DiskImager
(Check here for Raspbian essentials)

- Plug radio-slip mote to RPi, recognized as /dev/ttyUSB0

- Enable IPv6 module?

# sudo modprobe ipv6
or to automatically enable it at boot, add ipv6 on a line at the end of /etc/modules.

- Enable IPv6 forwarding
# sudo sysctl -w net.ipv6.conf.all.forwarding=1

or edit /etc/sysctl.conf uncomment the line: net.ipv6.conf.all.forwarding=1

- Configure IPv6 address for eth0
# sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet6 static
address bbbb::1
netmask 64

- Download contiki-2.7 source
- Go to examples/ipv6/native-border-router
- Fix source and build 
# vi border-router.c, line 161: remove ; (contiki 2.7 bug)
# vi slip-config.c, line 76: change -1 to 255 (RPi kernel??)
# make

- Run border router
# sudo modprobe ipv6 (optional)
# sudo sysctl -w net.ipv6.conf.all.forwarding=1 (optional)
# sudo ./border-router.native -L -v6 aaaa::1/64 (debug, ttyUSB0, 115200)

Autostart the border-router.native by adding it to /etc/rc.local (optional)
path_to_border-router.native aaaa::1/64

ex: /home/pi/contiki-2.7/examples/ipv6/native-border-router/border-router.native aaaa::1/64 &

4. Test

From IPv6 network computer ping to LLN
Ping: ping6 aaaa::212:7400:13cb:101a
Web browser: aaaa::212:7400:13cb:44

Thursday, March 6, 2014

Contiki OS: RPL Network Setup 2

One mote can be used as a wireless interface (IEEE 802.15.4), host machine as Border Router to  bridge the wireless IPv6 network (e.g., LLN) to outside network, and the Internet.

InstantContiki 2.7 or any machine with Contiki-2.7 and TI MSP430 toolchain (See here)

1. slip-radio (mote 1 as an IEEE 802.15.4 interface)
#cd contiki-2.7/examples/ipv6/slip-radio
#make TARGET=sky
#sudo make TARGET=sky slip-radio.upload

2. UDP servers or any IPv6 service (motes 2..n)
#cd contiki-2.7/examples/ipv6/rpl-udp
#make TARGET=sky
#sudo make TARGET=sky udp-server.upload

3. Host machine (Linux)
 #cd contiki-2.7/examples/ipv6/native-border-router
#make [TARGET=native]
#sudo ./border-router.native -L -v6 aaaa::1/64
*default: -s ttyUSB0 (serial device) -B 115200 (baud rate) -t tun0 (name of interface)

Cooja:  sudo ./border-router.native -a 127.0.0.1 -v6 aaaa::1/64
(enable Serial  Socket Server in the Cooja node used as the wireless interface)

[Contiki 2.7 Release Error] border-router.c:161:28: error: expected ‘)’ before ‘;’ token. 
Just delete the ';'

4. Test
ping6 aaaa::212:7400:13cb:44 (mote 1, wireless interface)
ping6 aaaa::212:7400:13ca:fee4 (mote 2)
ping6 aaaa::212:7400:13cb:34fa (mote 3)

Firefox: http://[aaaa::212:7400:13cb:44]

Sunday, February 9, 2014

Contiki OS: RPL Network Setup 1

One mote can be used as a Border Router to bridge the wireless IPv6 network (e.g., LLN) to a PC via serial link. By which, the IPv6 network traffic can reach outside network, and the Internet.

InstantContiki 2.7 or any machine with Contiki-2.7 and TI MSP430 toolchain (See here)

1. Border router (mote 1)
#cd contiki-2.7/examples/ipv6/rpl-border-router
#make TARGET=sky
#sudo make TARGET=sky border-router.upload

2. UDP servers (motes 2..n) or any IPv6 service
#cd contiki-2.7/examples/ipv6/rpl-udp
#make TARGET=sky
#sudo make TARGET=sky udp-server.upload

3. Host machine 

- Linux using tunslip6 (with mote 1 connected as ttyUSB0)

#cd contiki-2.7/tools
#make tunslip6
#sudo ./tunslip6 -s /dev/ttyUSB0 aaaa::1/64

Cooja: sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64
(enable Serial  Socket Server in the Cooja node used as the wireless interface)

- Windows using wpcapslip6 (with mote 1 connected as COM5)
Run cmd (Admin)
ifconfig /all --> find a working network interface (e.g.,Virtual Box Network Interface), MAC address: 00-50-56-C0-00-01
cd tools\stm32w\wpcapslip6
wpcapslip6 -s /dev/com5 -b aaaa:: -a aaaa::1/64 00-50-56-C0-00-01 (COM5 is where the mote is connected, check in Device Manager)

4. Test
ping6 aaaa::212:7400:13cb:44 (mote 1, border router)
ping6 aaaa::212:7400:13ca:fee4 (mote 2)
ping6 aaaa::212:7400:13cb:34fa (mote 3)


Firefox: http://[aaaa::212:7400:13cb:44]