Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

Abstract:

Based on the open-source system OpenWrt, an application program socket-support was developed, and 6LBR was ported to OpenWrt. Using the TP-link TL-WR703N chip and the low-power CC1310 chip produced by TI as the core hardware platform, a 6LoWPAN border router was designed based on Contiki, 6LBR, and the OpenWrt system. Two 6LoWPAN sub-nodes were also designed using the CC1310 chip, establishing an IoT application test network that includes a PC, sub-nodes, and the border router. The test results show that the PC can use the CoAP protocol to achieve data collection and control of the 6LoWPAN sub-nodes through the border router, applicable in various scenarios such as industrial control, environmental monitoring, and smart homes, possessing considerable application value.

0 Introduction

Since the concept of the Internet of Things was proposed, the 6LoWPAN (IPv6 over Low Power Wireless Personal Area Network) border router has been one of the main research topics. To achieve interconnection between the Internet and wireless sensor networks, the IETF working group proposed and established the 6LoWPAN technology standard based on IPv6 and IEEE802.15.4 as the underlying standard back in 2004. This mainly includes the 6LoWPAN adaptation layer, IPv6 header compression and decompression, data fragmentation and reassembly, routing protocols, IPv6 network access, and node address management technologies [1].

Currently, the 6LoWPAN protocol has been implemented on various open-source systems, such as 6LBR and Contiki. This paper adopts the open-source, highly portable 6LBR and Contiki operating systems. Among them, Contiki is an open-source event-driven multitasking operating system specifically designed for embedded devices that require networking and have severely limited hardware resources [2]. It provides support for the TCP/IP protocol for IPv4 and IPv6 through the uIP protocol stack and includes a lightweight wireless sensor network protocol stack called Rime; it also implements the 6LoWPAN protocol, RPL wireless routing protocol, and application layer protocol CoAP in IPv6. 6LBR is a 6LoWPAN/RPL border routing solution prepared for industrial applications, running on low-cost, open hardware platforms and Linux hosts, making 6LBR more aligned with the future development direction of border routers, and its design philosophy better meets future application needs [2].

This paper ports 6LBR to the embedded OpenWrt system based on Contiki and OpenWrt, designing a practical border router. It can complete the conversion between the IP protocol stack and the 6LoWPAN protocol stack, allowing hosts in the IP network to access nodes in the 6LoWPAN sensor network [3].

1 Border Router Implementation Plan

OpenWrt is a router operating system based on the Linux kernel, supporting various processor architectures, and has good support for the ARM architecture TL-WR703N router. It provides a simple and user-friendly environment framework and modular design for constructing one’s applications, greatly facilitating the development of applications and the porting of 6LBR to the OpenWrt system. This paper proposes two 6LoWPAN border router solutions based on the OpenWrt system, namely the 6LBR-OpenWrt border router solution and the OpenWrt border router solution.

2 6LBR-OpenWrt Border Router

2.1 6LBR-OpenWrt Border Router System Structure

6LBR is used to connect the wireless sensor network based on 802.15.4 and 6LoWPAN with the Ethernet-based IPv6 network. The design of 6LBR is flexible, and it can be configured to support various network topologies for connecting wireless sensor networks with the IP world. The router TL-WR703N cannot directly communicate wirelessly with the network sub-nodes in the 6LoWPAN network; it requires the CC1310DK chip running the Contiki program, which comes with the relevant SLIP protocol. The system block diagram is shown in Figure 1.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

2.2 6LBR Operating Modes

Currently, 6LBR has two operating modes: bridge mode and routing mode. In routing mode, the sub-nodes forming the 6LoWPAN wireless sensor network and the Ethernet have different network prefixes; in bridge mode, the prefixes are the same. References [2] and [4] provide detailed descriptions of several modes of 6LBR, and bridge mode will not be elaborated here. In the routing mode used in this paper, 6LBR acts as a complete IPv6 router, connecting the Ethernet and the 6LoWPAN network. The 6LoWPAN network is managed by the RPL protocol, and the Ethernet side is managed through the IPv6 neighbor discovery protocol. In this mode, through the packet filter module, 6LBR provides a virtual interface to Contiki. The routing mode can separate the sensor network into an independent subnet, allowing clear identification of nodes within the wireless sensor network; since the network prefix has switching capabilities, nodes can move between different 6LoWPAN networks; nodes will obtain a new address based on the new network prefix. The structure of the routing mode is shown in Figure 2.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

2.3 Software Design

This paper adopts the routing mode, where the Slip-radio program running on CC1310 can achieve communication between the 6LBR Linux process and the 802.15.4 radio through serial port data transmission. The MAC (Medium Access Control) layer is in 6LBR, with a driven method of Carrier Sense Multiple Access (CSMA); the RDC (Radio Duty Cycling) layer is in Slip-radio, where the MAC layer receives data sent from the RDC layer and sends data through the RDC; if the RDC layer detects a data collision, the MAC retransmits the data. After porting 6LBR to the TL-WR703N router, it is necessary to create a 6lbr.conf file on the router, which contains the following main content:

MODE=ROUTER

RAW_ETH=0

BRIDGE=1

ETH_JOIN_BRIDGE=0

DEV_BRIDGE=br-lan

DEV_TAP=tap0

DEV_ETH=br-lan

RAW_ETH_FCS=0

DEV_RADIO=/dev/ttyUSB0 BAUDRATE=9600

The CC1310DK is connected to the TL-WR703N via serial port, and the system on the router will generate a virtual network card tap0 based on the serial port; br-lan includes both wired LAN and wireless networks; then the tap0 port is connected to the br-lan port. The PC transmits data to TL-WR703N through the LAN port; after processing by 6LBR, the data is sent to CC1310 via tap0, which wirelessly transmits the data to the 6LoWPAN sensor network.

3 OpenWrt Border Router

3.1 OpenWrt Border Router System Structure

The OpenWrt border router also uses the CC1310DK chip. Unlike the first solution, the CC1310DK chip not only serves as the 802.15.4 interface connected to the 6LoWPAN sensor network but also acts as the RPL root node of the wireless sensor network, supporting routing functions and managing the RPL network, integrating the 6LoWPAN adaptation layer, and completing the conversion between IPv6 protocol and IEEE802.15.4 protocol, enabling communication between the complete 6LoWPAN/RPL network and the OpenWrt border router. Therefore, the CC1310DK truly fulfills the role of a 6LoWPAN border router. The TP-WR703N connects to the computer host via Ethernet or wirelessly, allowing the OpenWrt border router to process the data forwarded between the IP network and WSN’s IPv6. The system block diagram is shown in Figure 3.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

3.2 Software Design

The CC1310DK connects with TL-WR703N through a USB interface, generating the /dev/ttyUSB0 port number on the router. The tunslip6 software package on OpenWrt virtualizes this port number into the tun0 network card. This allows for pinging sub-nodes in the 6LoWPAN sensor network from TL-WR703N. External networks such as PCs can ping the border router through the LAN port but cannot ping the sub-nodes in the 6LoWPAN sensor network. To achieve communication between the IP network and the 6LoWPAN sensor network, there are two methods. The first is to add the following configuration in the firewall/files of OpenWrt:

config zone option input ‘ACCEPT’

option forward ‘REJECT’

option output ‘ACCEPT’

option name ‘6lowpan’

option network ‘lan6’

config forwarding option dest ‘lan’

option src ‘6lowpan’

config forwarding option dest ‘6lowpan’

option src ‘lan’

In the socket-support software package, add the following script commands:

uci set network.lan6=interface

uci set network.lan6.proto=static

uci set network.lan6.ifname=tun0

uci set network.lan6.ip6assign=64

uci commit network

The Uci command line adds a tun0 interface, which is the communication interface between the 6LoWPAN sensor network and the border router. This configuration allows the LAN and tun0 ports to communicate, enabling data forwarding between the two.

The 6LoWPAN sub-nodes run programs with the CoAP protocol. The CoAP protocol (Constrained Application Protocol) is a UDP-based application layer transport protocol designed for resource-constrained devices in the Internet of Things, allowing small devices to connect to the Internet. Libcoap is a C language implementation of the CoAP protocol that provides server and client functionality. The 6LoWPAN sub-nodes act as the server; OpenWrt provides the Libcoap software package, and the TL-WR703N router can act as the client, communicating with the data of sub-nodes in the 6LoWPAN wireless sensor network through the coap-client command. Currently, the communication is only achieved in the local area network formed by the TL-WR703N router and the sensor network. External networks communicate by operating on the TL-WR703N router. Therefore, this paper develops a software package socket-support on the OpenWrt system, mainly based on the socket program developed under Linux for the server side, with the communication protocol being TCP. External devices such as computers and mobile phones run the client.

The data communication in these two methods is essentially the same except for the differences in sending and receiving at the PC end. The PC transmits data to the TL-WR703N router through the Ethernet port, and the CC1310 running the border-router program communicates with the router through the virtual network card tun0. The CC1310 can be regarded as a 6LoWPAN gateway node, which receives data packets from the router through the SLIP protocol. The packet format is IPv6, while the communication standard for the wireless sensor network is IEEE 802.15.4. Therefore, the gateway node utilizes the 6LoWPAN adaptation layer to perform header compression and data fragmentation on the data packets, and the processed data is sent according to the destination address, which is the IPv6 address of the 6LoWPAN network sub-node; after receiving the data, the sub-node performs data reassembly, responds to commands, and transmits the collected data back to the gateway node after compression and fragmentation. The 6LoWPAN gateway node then transmits the received data through the tun0 port to the router, which forwards it to the IPv6 network through the Ethernet port. The communication process is illustrated in Figure 4.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

4 Border Router Function Verification

Since 6LBR is ported to OpenWrt as a software package application, for convenient testing, one can choose the 6LBR application package based on the second solution. Both solutions require the border router to connect to the CC1310DK via serial port, and the TP-WR703N currently only provides one port, so testing can only be done separately during debugging.

4.1 6LBR-Openwrt Border Router Connectivity Test

The connectivity test mainly involves the following steps:

(1) Open cmd.exe on the PC side or execute the command ping -6 bbbb::100 to test the connectivity from the PC to the gateway, as shown in Figure 5.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

(2) In the Firefox browser with the Copper plugin running, enter coap://[sub-node IPv6 address]:5683/ to access the sub-node’s web program, where specific resources can be accessed using GET/POST/PUT/DELETE to obtain the specific content of the resource. It can be observed that the IPv6 address prefixes of the sub-Ethernet and wireless networks are different, indicating that the operating mode is routing mode, as shown in Figure 6.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

4.2 OpenWrt Border Router Connectivity Test

(1) Open the network debugging assistant, select TCP Client mode to connect to the border router, and enter the getip and getipall commands to obtain the IPv6 address of the border router and the sub-nodes, as shown in Figure 7.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

(2) Ping the sub-node address for connectivity testing, and the sub-node’s IPv6 address can also be entered into the browser’s address bar to access the sub-node’s web interface. One can perform GET/POST/PUT/DELETE command operations on the web page, or input coap commands in the network debugging assistant to control the sub-node, such as: coap-client -m get coap://[sub-node IPv6 address]:5683/sen/batmon/tem-p (to get the temperature value of the sub-node chip 29). Therefore, one can choose either the web page or the network debugging assistant based on the specific application, as shown in Figure 8.

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

5 Conclusion

This paper, based on multiple open-source systems such as Contiki, 6LBR, and OpenWrt, has designed and researched the 6LoWPAN border router from multiple aspects, proposing several feasible solutions. From the test results, it can be seen that the designed 6LoWPAN border router has achieved the expected design goals, and it is possible to select a suitable border router based on specific applications in wireless sensor networks. The next step will be to continuously improve the border router and apply it to environmental monitoring.

References

[1] Wang Guoqing. Research on 6LoWPAN and its Implementation in WSN Nodes [D]. Beijing: North China University of Technology, 2014.

[2] Zhang Yan. Design and Implementation of IoT Application Platform Based on Contiki System [D]. Harbin: Harbin Engineering University, 2013.

[3] Tian Guangdong, Ye Xin. Design of 6LoWPAN Border Router Based on Contiki [J]. Electronic Technology Application, 2016, 42(3): 61-63, 70.

[4] SPANDAN. 6LBR Modes [EB/OL]. (2016-5-20) [2017-12-31]. https://Github.com/cetic/6lbr/wiki/6LBR Modes.

[5] HUI J, THUBERT P. Compression Format for IPv6 Datagrams over IEEE 802.15.4-based Networks [S]. RFC 6282, 2011.

[6] Yang Yong. Design of 6LoWPAN Gateway Node Based on Contiki [D]. Wuhan: Central China Normal University, 2013.

[7] Zhu Ruoxin. Research on 6LoWPAN Technology in IoT Applications Based on Multiple Open Source Systems [D]. Kunming: Yunnan University, 2015.

[8] Chang Yingliang. Research and Implementation of IoT Gateway Based on Embedded Linux [D]. Beijing: Beijing Jiaotong University, 2014.

[9] Sheng Lili. Design and Implementation of Wireless Sensor Network Nodes Based on Contiki Operating System [D]. Wuhan: Wuhan University of Engineering, 2012.

Author Information:

Wu Mingbiao 1, 2, Wu Guiqing 1, Chen Qinghua 2

(1. Hunan University, School of Electrical and Information Engineering, Hunan, Changsha 410082; 2. Zhejiang Tsinghua Yangtze River Delta Research Institute, Zhejiang, Jiaxing 314006)

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

Design of 6LoWPAN Border Router Based on Multiple Open Source Systems

Leave a Comment