Setup a RIOT OS 6LowPAN border router

5 Apr

After playing around with the gnrc_networking example in the last post the next step is to setup a border router. Border routers are the communication pieces in between a 6LowPAN network and normal LAN/WAN. Because normal computers/hardware don’t bring IEEE 802.15.4 capable radios with them you need to change one development board into a slip radio. The host system communicates over serial with the slip (serial line ip) radio and therefore is able to send and receive messages to the IEEE 802.15.4 network.

Prerequisites:

The needed prerequisites can of course vary based on your goals. A minimal setup would be in this case:

  • ARM GNU GCC Toolchain
  • UART/COM Port

Building the border router image

The slip radio / border router image is also located in the `examples` directory of the RIOT folder. It is called `gnrc_border_router` and can be built with:

git clone https://github.com/RIOT-OS/RIOT.git
cd RIOT/examples/gnrc_border_router
make BOARD=cc2538dk
...
   text	   data	    bss	    dec	    hex	filename
  72652	    144	  24168	  96964	  17ac4	RIOT/examples/gnrc_border_router/bin/cc2538dk/gnrc_border_router.elf

The .elf/.bin files are again put inside the `bin/cc2538dk` folder – now flash the firmware to the board.

Setting up bridging interface

RIOT already comes with a very handy script that does the whole bridging work for you. Further explanation can be found in their wiki.

To get it working you first need to compile additional tools bundled with RIOT:

cd RIOT/dist/tools/ethos
make clean all
cd RIOT/dist/tools/uhcpd
make clean all
cd RIOT/dist/tools/ethos
sudo sh start_network.sh /dev/ttyUSB0 tap0 2001:db8::/64

The last line starts the shell script and hands in the device address of the UART port (/dev/ttyUSB0), the desired bridge interface name (tap0) and the IPv6 prefix for the network. You may need to change the UART device in your setup!

Flash the `gnrc_networking` example (as explained here) to a second device and start it up. You should get something like the following output on the host:

net.ipv6.conf.tap0.forwarding = 1
net.ipv6.conf.tap0.accept_ra = 0
----> ethos: sending hello.
----> ethos: activating serial pass through.
----> ethos: hello reply received
----> ethos: hello reply received
uhcp_client(): sending REQ...
got packet from fe80::3c6e:2aff:fe8d:a253 port 37622
uhcp: push from fe80::3c6e:2aff:fe8d:a253:37622 prefix=2001:db8::/64
gnrc_uhcpc: uhcp_handle_prefix(): got same prefix again

and should now see on the second board that it got the prefix’ed address:

> ifconfig
Iface  7   HWaddr: 9c:00  Channel: 26  Page: 0  NID: 0x23
           Long HWaddr: 00:12:4b:00:06:15:a8:6b
           TX-Power: 0dBm  State: IDLE
           AUTOACK  MTU:1280  HL:64  6LO  RTR  RTR_ADV  IPHC
           Source address length: 8
           Link type: wireless
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::212:4b00:615:a86b/64  scope: local
           inet6 addr: ff02::1:ff15:a86b/128  scope: local [multicast]
           inet6 addr: ff02::1a/128  scope: local [multicast]
           inet6 addr: 2001:db8::212:4b00:615:a86b/64  scope: global
           inet6 addr: ff02::2/128  scope: local [multicast]

           Statistics for Layer 2
            RX packets 21  bytes 1762
            TX packets 20 (Multicast: 3)  bytes 1755
            TX succeeded 0 errors 0
           Statistics for IPv6
            RX packets 16  bytes 1560
            TX packets 20 (Multicast: 3)  bytes 1786
            TX succeeded 20 errors 0

Now you can try pinging your device from the linux host system:

ping6 2001:db8::212:4b00:615:a86b
PING 2001:db8::212:4b00:615:a86b(2001:db8::212:4b00:615:a86b) 56 data bytes
64 bytes from 2001:db8::212:4b00:615:a86b: icmp_seq=1 ttl=63 time=55.4 ms
64 bytes from 2001:db8::212:4b00:615:a86b: icmp_seq=2 ttl=63 time=46.1 ms
64 bytes from 2001:db8::212:4b00:615:a86b: icmp_seq=3 ttl=63 time=58.8 ms
64 bytes from 2001:db8::212:4b00:615:a86b: icmp_seq=4 ttl=63 time=52.7 ms
64 bytes from 2001:db8::212:4b00:615:a86b: icmp_seq=5 ttl=63 time=43.0 ms
^C
--- 2001:db8::212:4b00:615:a86b ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 43.096/51.233/58.813/5.829 ms

Et voila you can now access the 6LowPAN network with RIOT devices from your linux host – and the other way around. If you want to enable your devices to reach the internet you will need to add additional routes to the host system (for correct routing).

Facebooktwittergoogle_plusFacebooktwittergoogle_plus

One Reply to “Setup a RIOT OS 6LowPAN border router”

  1. My Border-Router Details:

    Iface 6 HWaddr: 00:26:d5:19:4b:da
    MTU:1500 HL:64 RTR
    RTR_ADV Source address length: 6
    Link type: wired
    inet6 addr: fe80::226:d5ff:fe19:4bda scope: local
    inet6 addr: fe80::2 scope: local VAL
    inet6 group: ff02::2
    inet6 group: ff02::1
    inet6 group: ff02::1:ff19:4bda

    Iface 7 HWaddr: 7f:be Channel: 26 Page: 0 NID: 0x23
    Long HWaddr: 00:12:4b:00:04:13:31:40
    TX-Power: 0dBm State: IDLE
    AUTOACK MTU:1280 HL:64 RTR
    RTR_ADV IPHC
    Source address length: 8
    Link type: wireless
    inet6 addr: fe80::212:4b00:413:3140 scope: local VAL
    inet6 addr: 2001:db8::212:4b00:413:3140 scope: global VAL
    inet6 group: ff02::2
    inet6 group: ff02::1
    inet6 group: ff02::1:ff13:3140

    My gnrc_networking example details:
    ifconfig
    Iface 7 HWaddr: b6:b9
    Channel: 26 Page: 0 NID: 0x23
    Long HWaddr: 00:12:4b:00:04:22:a4:16
    TX-Power: 0dBm State: IDLE
    AUTOACK MTU:1280 HL:64 RTR
    RTR_ADV IPHC
    Source address length: 8
    Link type: wireless
    inet6 addr: fe80::212:4b00:422:a416 scope: local VAL
    inet6 addr: 2001:db8::212:4b00:422:a416 scope: global VAL
    inet6 group: ff02::2
    inet6 group: ff02::1
    inet6 group: ff02::1:ff22:a416
    inet6 group: ff02::1a

    Statistics for Layer 2
    RX packets 37 bytes 1968
    TX packets 85 (Multicast: 4) bytes 5630
    TX succeeded 0 errors 0

    Statistics for IPv6
    RX packets 36 bytes 2536
    TX packets 85 (Multicast: 4) bytes 6594
    TX succeeded 85 errors 0>

    So, i i try to ping example node with global IP address from my Linux PC its says failed packet loss. Its successful in pingnig Border Router ? why is so?
    Anything wrong in my setup ?

Leave a Reply

Your email address will not be published. Required fields are marked *