Skip to content

Testing 6LoWPAN on Ethernet based devices

Martine Lenders edited this page Nov 2, 2015 · 4 revisions

Introduction

6LoWPAN was designed to enable IPv6 over IEEE 802.15.4 networks. There are RFCs and drafts in the work for other low power and/or lossy link-layers, but for testing purposes it makes sense to also enable 6LoWPAN traffic on established link-layers as Ethernet. For this purpose wireshark included a ZEP (Zigbee Encapsulation Protocol) dissector which encapsulates IEEE 802.15.4 packets in UDP packets:

.                   .
+-------------------+
|      6LoWPAN      |
+-------------------+
|        UDP        |
+-------------------+
|     IPv4/IPv6     |
+-------------------+
|        L2         |
+-------------------+

Usage

TL;DR

Compile

$ cd examples/gnrc_networking
$ export USEMODULE="gnrc_zep gnrc_nomac"
$ export CFLAGS=-DGNRC_NETIF_NUMOF=2
$ make all term

Usage

zep_init <IPv6-over-Ethernet dst>
ping6 <IPv6-over-IEEE-802.15.4 dst>

Compile an example application

To use ZEP with RIOT you need to include the gnrc_zep module and increase the maximum number of interfaces GNRC_NETIF_NUMOF. The following examples are based on the gnrc_networking example application on Board: native. Be aware that you need to creat one TAP device for each virtual node as described in Virtual riot network before you can run the terminal emulation.

$ cd examples/gnrc_networking
$ export USEMODULE="gnrc_zep gnrc_nomac"
$ export CFLAGS=-DGNRC_NETIF_NUMOF=2
$ make all term
Building application "gnrc_networking" for "native" with MCU "native".

[...]
   text	   data	    bss	    dec	    hex	filename
 161685	    576	 140640	 302901	  49f35	/home/user/RIOT-OS/RIOT/examples/gnrc_networking/bin/native/gnrc_networking.elf
/home/user/RIOT-OS/RIOT/examples/gnrc_networking/bin/native/gnrc_networking.elf tap0 
RIOT native uart0 initialized.
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

kernel_init(): This is RIOT! (Version: 2014.12-1863-g14144-zep/feat/initial)
kernel_init(): jumping into first task...
UART0 thread started.
uart0_init() [OK]
RIOT network stack example application
All up, running the shell now

ZEP initialization

Since the ZEP device needs an IPv6 destination to send the encapsulated IEEE 802.15.4 frames to, it can't be initialized automatically. So if you type ifconfig you will just see your netdev2_tap interface (we denote the TAP interface's name in front of the RIOT shell prompt here to distinguish between the different nodes)

tap0> ifconfig
ifconfig
Iface  8   HWaddr: 62:c7:30:0d:6a:2c 
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::60c7:30ff:fe0d:6a2c/64  scope: local
           inet6 addr: ff02::1:ff0d:6a2c/128  scope: local [multicast]

To initialize the ZEP interface you need to acquire the IPv6 address of the netdev2_tap interface of the target node (fe80::6450:32ff:fed5:ce81 in our case):

$ PORT=tap1 make term
/home/user/RIOT-OS/RIOT/examples/gnrc_networking/bin/native/gnrc_networking.elf tap1 
RIOT native uart0 initialized.
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

kernel_init(): This is RIOT! (Version: 2014.12-1863-g14144-zep/feat/initial)
kernel_init(): jumping into first task...
UART0 thread started.
uart0_init() [OK]
RIOT network stack example application
All up, running the shell now
tap1> ifconfig
ifconfig
Iface  8   HWaddr: 66:50:32:d5:ce:81 
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::6450:32ff:fed5:ce81/64  scope: local
           inet6 addr: ff02::1:ffd5:ce81/128  scope: local [multicast]

We can use this information to initialize ZEP on both interfaces:

tap0> zep_init fe80::6450:32ff:fed5:ce81
zep_init fe80::6450:32ff:fed5:ce81
tap0> ps 
ps
	pid | name                 | state    Q | pri | stack ( used) | location   
	  1 | idle                 | pending  Q |  15 |  8192 ( 1100) | 0x80751a0 
	  2 | main                 | running  Q |   7 | 16384 ( 2932) | 0x80711a0 
	  3 | uart0                | bl rx    _ |   6 |  8192 (  928) | 0x808f1c0 
	  4 | pktdump              | bl rx    _ |   6 | 16384 (  944) | 0x80844a0 
	  5 | 6lo                  | bl rx    _ |   3 |  8192 (  944) | 0x80884c0 
	  6 | ipv6                 | bl rx    _ |   4 |  8192 ( 1120) | 0x8082260 
	  7 | udp                  | bl rx    _ |   5 |  8192 (  944) | 0x808a6e0 
	  8 | tapnet               | bl rx    _ |   4 |  8192 ( 1392) | 0x8080240 
	  9 | zep_app              | bl rx    _ |   2 |  8192 (  976) | 0x8091660 
	 10 | zep_l2               | bl rx    _ |   4 |  8192 (  960) | 0x808d120 
	    | SUM                  |            |     | 98304 (12240) 
tap0> ifconfig
ifconfig
Iface  8   HWaddr: 62:c7:30:0d:6a:2c 
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::60c7:30ff:fe0d:6a2c/64  scope: local
           inet6 addr: ff02::1:ff0d:6a2c/128  scope: local [multicast]
           
Iface 10   HWaddr: 70:6e  Channel: 17  NID: 0x2300 
           Long HWaddr: 02:59:6a:45:00:59:70:37
           6LO 
           Source address length: 2
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::ff:fe00:706e/64  scope: local
           inet6 addr: ff02::1:ff00:706e/128  scope: local [multicast]
           

We see that 2 new threads are started: zep_app and zep_l2. zep_app handles the application layer on top of UDP and provides a virtual network device, which zep_l2 wraps as an interface (Iface 10).

The same needs to be done on the other node:

tap1> zep_init fe80::60c7:30ff:fe0d:6a2c
zep_init fe80::60c7:30ff:fe0d:6a2c
tap1> ifconfig
ifconfig
Iface  8   HWaddr: 66:50:32:d5:ce:81 
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::6450:32ff:fed5:ce81/64  scope: local
           inet6 addr: ff02::1:ffd5:ce81/128  scope: local [multicast]
           
Iface 10   HWaddr: 85:c7  Channel: 17  NID: 0x2300 
           Long HWaddr: 02:59:6a:45:00:59:85:9e
           6LO 
           Source address length: 2
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::ff:fe00:85c7/64  scope: local
           inet6 addr: ff02::1:ff00:85c7/128  scope: local [multicast]
           

You should now be able to send packets via 6LoWPAN to the other node:

tap0> ping6 fe80::ff:fe00:85c7
ping6 fe80::ff:fe00:85c7
12 bytes from fe80::ff:fe00:85c7: id=83 seq=1 hop limit=64 time = 0.2795 ms
12 bytes from fe80::ff:fe00:85c7: id=83 seq=2 hop limit=64 time = 0.795 ms
12 bytes from fe80::ff:fe00:85c7: id=83 seq=3 hop limit=64 time = 0.755 ms
--- fe80::ff:fe00:85c7 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 0.034345 s
rtt min/avg/max = 0.755/0.1448/0.2795 ms
tap0> ncache
ncache
IPv6 address                    if  L2 address                state       type
------------------------------------------------------------------------------
fe80::ff:fe00:85c7              10  85:c7                     REACHABLE   -
fe80::6450:32ff:fed5:ce81        8  66:50:32:d5:ce:81         REACHABLE   -

tap1> ncache
ncache
IPv6 address                    if  L2 address                state       type
------------------------------------------------------------------------------
fe80::60c7:30ff:fe0d:6a2c        8  62:c7:30:0d:6a:2c         REACHABLE   -
fe80::ff:fe00:706e              10  70:6e                     REACHABLE   -
Clone this wiki locally
You can’t perform that action at this time.