Research on IOT Intelligent Gateway Service Mechanism and System Implementation Qian XiaoJun*, Fan DongPing, Ji GengLin Nanjing Normal University, Nanjing, Jiangsu, China Abstract This paper discusses the key technique for Internet application, IOT gateway. It focuses on the implementation of hardware and software system layer, to provide an embedded platform environment for the development. The system offers the access of different types of devices and exchanges data with the transmission network by various modes. According to the actual demand for implementation of gateway system, we choose ARM9 microprocessor as the core of hardware system. Then the hardware platform for IOT gateway is established based on the embedded hardware system design principles, with the transplanting of ARM-Linux operation system. We also design and realize the software modules for IOT gateway based on the hardware platform, and provide detailed analysis on the design ideas and techniques. The system is performed joint debugging in software and hardware, and it uses simple interactive program to simulate the communication between the control module and coordinator. The experiments shows our scheme can offer the relative functions of embedded IOT gateway and the tests all achieve expected effects. Keywords - IOT gateway; ARM; embedded platform; socket; CoAP/HTTP I. INTRODUCTION With the rising and constant development of Internet of Things (IOT), it brings another tide in information industry. In the whole IOT, sensor network is one of key components in it. The sensor devices in sensor network concretize and digitalize abstract things, so the information among people, can also be exchanged [1]. However, with increasing the types and quantities of sensor devices, the connection contradiction between sensor network and transmission network is gradually obvious and it seriously hinders further development of IOT. In essence, IOT technology is not the sophisticated technology but the integration between network communication technology and automatic control. In terms of IOT gateway, it combines three levels including perception, network and application and introduces corresponding application environment to study its structure [2,3]. Literature [4] introduces an IOT gateway which is used for telecommunication operation business. Based on characteristics analysis of IOT and operation business network, it summarizes that IOT gateway as bridge needs broad network access of perception layer, network service, data management, etc. Meanwhile, IOT is located the layer between perception layer and infrastructure network layers in structure. Literature [5] introduces and designs a heterogeneous network of multiple perception layer to access gateway equipment of basic communication network, shield different sensor networks and access networks are shielded. Thus, it provides a united data format for middle platform and application layer so that application program only needs to concern data processing of application environment. The reference also indicates that protocol conversion of gateway is one of its main functions. Based on above analysis, the design and application of IOT gateway should start from the overall structure. Then it is integrated with specific application and is filtered with relevant functional modules. For special implementation of the intelligent gateway, the gateway service and management functions should make enough efforts and simplify external interference to the maximum degree. As an open-type service gateway, the levels should be more explicit. Its structure is clearer and simpler for utilization. Based on the analysis on above problems, this paper integrates current embedded system application of communication technology and designs a hardware system of IOT gateway. It realizes different types of equipment access and provides data exchange with transmission network in different patterns. According to implementation and actual demand of the gateway system, ARM9-based microprocessor is taken as its kernel hardware system, with theoretical analysis and practical selection. Based on the design principle of embedded hardware system, the hardware platform of IOT gateway is constructed and transplanted in embedded ARM- 1inux operating system. IEEE802.1l-based ARM node can operate BATMAN routing protocol; IEEE802.15.4-based sensor node can operate RPL routing protocol and RFID radio-frequency equipment. Data processing layer is used to capture, analyze and process data packet and it can provide the functions for CoAP/HTTP protocol translation and local storage information collection. In code realization, we adopt bottom-up method to finish the code compiling of various levels of programs, to improve the system speed and offer layering to the program. During specific implementation, we performed joint commission tests of software and hardware. Meanwhile, we apply simple serial interaction program to imitate the communication between main control module and coordinator to further verify the feasibility of service DOI 10.5013/IJSSST.a.16.1B.11 11.1 ISSN: 1473-804x online, 1473-8031 print
gateway. We establish the test environments respectively to test various functions of IOT gateway. The results show that the embedded Linux-based IOT system can meet the design requirement in this paper. II. OVERRALL DESIGN ARCHITECTURE OF SYSTEM IOT service gateway brings a totally new concept for comprehensive implementation of future IOT, as a novel word. It involves three layers of IOT and it also becomes a kind of centralized reflection of system application design [6]. In addition to realize the communication between different networks, it also needs to manage the bottom devices. Users and third-party platform can manage each the sensing node via IOT service gateway to obtain related information of each node and endpoint for remote control. This paper takes into account the function requirement of IOT gateway for the single application scenarios. It designs an IOT gateway to improve the equipment utilization, by adopting dynamic loading function module and expanding equipment circumscribed socket. Its overall framework is shown as figure 1: Figure 1. Overall structure of IOT gateway. As the bottom layer of IOT gateway framework, the perception access layer is used to adapt different types of perception equipments at the bottom and send the collected sensor data to upper layer for processing [7]. The sensor III. devices contain IEEE802.11-based ARM nodes, IEEE802.15.4-based sensor node and RFID devices. ARM node operates BATMAN routing protocol and the data exchanging is performed between sensor nodes via RPL routing protocol. As the interlayer of IOT gateway framework, data analysis layer is used to capture, analyze and process the perception packet at the bottom. If the type is CoAP protocol data packet, it needs CoAP/HTTP protocol translation. As the top layer of IOT gateway framework, the translation application layer is used for remote transmission and application processing of sensor data. The remote transmission contains Ethernet transmission and 3G transmission and it is flexibly switched according to network situations SCHEME DESIGN A. Hardware Platform The hardware of IOT gateway takes the embedded microprocessor as core and it contains SDRAM module, FLASH module, power manage module, Ethernet interface module, LCD display interface module, USB module and serial port module, as shown in figure 2. 802.11 device, 802.15.4 device and 3G device can connect the gateway by USB interface module, so do the RFID device by serial port module and LCD display by LCD display interface module, to exchange information with the IOT gateway. DOI 10.5013/IJSSST.a.16.1B.11 11.2 ISSN: 1473-804x online, 1473-8031 print
Figure 2. Hardware structure of IOT gateway. This paper chooses AR91RM9200 microcontroller in the series of ARM920T [8] as the core processor for IOT hardware system. The embedded microprocessor is based on computer processor. In actual implementation, the microprocessor is installed in specific circuit system, only keeping the needed functional module, and removing unrelated system functions by cutting. This largely reduces the volume and power of the whole system. Under some special conditions, in order to satisfy different application abilities of embedded system, the embedded microprocessor largely improves its hardware performance in addition to consistence between basic functions and standard processor. For instance, in some serious environments such as high/low temperature environment, frequent interruption spaces, etc, it still keeps its powerful reliability and stability. In addition, it has advantages like low cost, easy development, small size, light weight, etc. Main MPU contains ARM, MIPS, X86, etc. AT91RM9200 is a system which is established completely for ARM920T ARM thumb processor. It has rich systems, application peripherals and standard interfaces. It owns the characteristics of most embedded microprocessors like low power consumption, low cost and high performance. The internal structure is depicted in figure 3: In ATglRM9200, since most systems need to be allocated exterior memory devices. These memory devices are connected by allocated exterior bus interface of chips and selected storage devices through signals. There is a highspeed static RAM working area which is used to complete mapping between exterior storage and interior storage. By exterior data controller, this process treatment does not need processor or direct data exchanging. Therefore, the data transmission efficiency is largely improved while processor burden is reduced. Exterior bus interface contains dynamic storage controller, static storage controller and exterior extended storage controller and it realizes memory extension through designing special circuit. Advanced Interruption Controller (AIC) has 8 priorities. This controller has individual control ability and operates shield/openness operation according to requirement. Power management controller (PMC) can change running state of processor and other peripheral devices in order to reduce the power of the whole system during running as much as possible. In this microprocessor chip, various standard communication accesses are integrated including standard asynchronous serial communication access of RS232, RS422,etc, USB high speed interface, and Ethernet interface which is broadly used in internet. In addition, it also integrates a series of standard access, etc, in industrial field and can be broadly used in industrial control and management. The chips also integrate real-time debug interface such as UART, JTAG, etc. Due to existence of these debugging functions, during developing, developers can real-time track debug so that its development becomes more convenient and visual. B. Packet Processing The data processing module needs capture and type judgment of uploading data packet at the bottom and this needs Netfilter mechanism in Linux kernel. Netfilter is a filtering framework of Linux kernel packet and it owns the functions such as data packet processing, data packet filtering, transparent proxy, address masquerading, dynamic address transformation, media access control, etc. This framework defines a series of hook set for each protocol and each hook can download custom functions. The data packet will pass these hooks during the transmission at network layer and. The function registered by hooks will be triggered and process these data packets. When this process is finished, the data packet will return be submitted to the last protocol stack according to different types, or be retransmitted by route, or be directly discarded DOI 10.5013/IJSSST.a.16.1B.11 11.3 ISSN: 1473-804x online, 1473-8031 print
Figure 3: Internal architecture of AR91RM9200 Linux kernel provides a special structural body for Netfiter framework to express relative information of the hooks. The parameter is defined as follws: Static struct nf_hook_ops data_handle= {.hook= data_handle_process,.pf=pf_inet6,.hooknum=nf_ip6_pre_rounting,.priority= NF_IP6_PRI_FIRST, }; Hook denotes the custom functions that registered on the hook by users; pf denotes the protocol type adopted by Netfilter framework; hooknum denotes the type of operation hooks; priority denotes the priority order executed by hook function. This paper adopts NF_IP6_PRE_RPUTIONG hook in Netfilter framework to intercept and process the packets. Fist it needs to register the custom function of user on NF_IP6_PRE_RPUTIONG hook. When the data is post form the bottom layer to the top layer, the hook function is triggered automatically to intercept the packets and determine the types. If the packet is not UDP packet based on IPv6, it will be returned to kernel protocol stack directly; if the packet is CoAP packet, it will be turned to CoAP/HTTP protocol transformation module for process; if the packet is collected data, the information is backed up and turned to local storage module. The original data returns to kernel protocol stack. The packet processing flow is show as figure 4: We do not make much research on the data packets from DOI 10.5013/IJSSST.a.16.1B.11 11.4 ISSN: 1473-804x online, 1473-8031 print
top layer to bottom layer in this paper. So the data processing module will not intercept the data. It will find the next hop address by querying the router table and turn to corresponding device driver module to send it. Figure 4. Processing flow of packets same time, considering the modular programming idea of the C. Embedded Communication codes, each independent function should be encapsuled a ARM embedded platform adopts serial communication module to provide perfect interface for the outside, which is mode with wireless sensor network. It performs Socket convenient for system extension and daily maintenance. communication with user servers. Thus, the communication The data communication module of embedded platform is modules of embedded platform data is composed of composed by the serial data receiving module, serial data receiving module of serial data, sending module of serial sending module, socket data receiving module and data, receiving module of socket data, sending module of communication link maintenance module and etc. The socket data and maintenance module of communication link. relationship among them is describes as figure 5: Since we need rapid and random response of receiving and sending for the socket data, the reading and writing operations of socket should be isolated. Multithread design pattern is adopted in the system to process read-write operations by different threads. Read and write operations of the serial port and socket mainly aim to different types of buffers. The communication among different threads is realized by data sharing in buffer of the threads. This paper sets the buffer as global variable to get this object. Due to the global share buffer array, different threads will take synchronization mechanism to guarantee the consistency of data; otherwise, when one process performs read and write operation in the sharing area, another process also performs the same operation simultaneously, it will result in data disorder. During the program design process, we should determine Figure 5. Communication module of embedded system the function return value after the call of function interface In order to protect the read and write of serial port not to each time. If the return value is error, corresponding error be conflicted, the read and write operation between mutex processing mechanism will be set inside the module. At the and synchronous serial of conditional variable are adopted. DOI 10.5013/IJSSST.a.16.1B.11 11.5 ISSN: 1473-804x online, 1473-8031 print
When the thread reads corresponding data from serial port it attempts to obtain lock of buffer. If the lock of buffer is not released, it indicates that the data in buffer is not completely written in file descriptor of the socket file. That means it is not sent to the network. If the data at buffer has been completely sent through the network, the write module of socket will release previously obtained lock at buffer. At this time, the read module thread of serial obtains this lock, clears the buffer and writes data in this buffer. The Socket read module will receive data in an occupation mode from the network. If data is not received, this thread will always be occupied till it obtains mutex in buffer, cleans buffer, writes data in buffer and releases this lock. So we can guarantee the accuracy of data sending and receiving in the whole system in synchronous mode. IV. SYSTEM IMPLEMENTATION A. Ping Test For the implementation demand of the scheme we establish the test system described in figure 6. It is composed of 10 devices with the number from 0 to 9. This test system can be separated into two parts in the logic layer of IOT: one is the perception layer containing device number 0-4; the other is the application layer containing device number 6-9. The device connecting above two is the IOT gateway. Ping test is adopted to test the connectivity of IOT gateway. Command ping is used to test whether the address translation, IP packet header translation and ICMPT header translation are normal. The selected test devices include debug hosts of NO2. and NO.7. There are two test scenarios: No.2 debug host is in IPv4 network and No.7 debug host is in IPv6 network No.7 debug host is in IPv4 network and No.2 debug host is in IPv4 network In the first scenario, the address of No.2 debug host is 202.199.65.77; the IPv4 address of IOT gateway is 202.199.65.127 and the IPv6 address is 2001:da8:9000::251. Disposable IPv6 prefix is 2001:db8: 9000::2. The IOT gateway works in state mode. The IPv6 address of NO.7 debug host is 2001:da8:9003:0:30. When NO. 7 debug host use command Ping6 to connect NO. 2 debug host, the test result is shown as figure 7. In the second scenario, the IPv6 address of No.2 debug host is 2001:da8:9000::30 and the IPv4 address is 202.199.65.125. The IPv6 address of IOT gateway is 2001:da8:9000::232 and its IPv4 address is 202.199.65.127. Disposable IPv6 prefix is 2001:da8:9003:0:32. The IOT gateway works in stateless mode. The IPv6 address of NO.7 debug host is 202.199.65.70. When NO. 2 debug host uses Figure 6. Architecture of test system command Ping6 to connect NO. 7 debug host, the test result is shown as figure 8. Figure 7. Test result of the first scenario DOI 10.5013/IJSSST.a.16.1B.11 11.6 ISSN: 1473-804x online, 1473-8031 print
Figure 8. Test result of the second scenario B. Translation function Test of COAP/HTTP protocol CoAP/HTTP protocol translation makes the remote clients based on HTTP access CoAP-based sensor node Web servers. The client input the URL access information http://2001:da8:9000::232/. This URL is the IPv6 address of the sensor node. The client send http request packet to the IOT gateway and the packet format is shown as figure 9. Figure 9. Http request message Figure 10. Http Response Message After the process of CoAP/HTTP protocol translation module, IOT gateway will send the coap request packet to the sensor node. Its packet format is shown in figure 10. When the sensor node receives the coap request packet it will resolve it and return the packet back to IOT gateway by coap response packet. IV. CONCLUSION At present, the development tendency of IOT, particularly for the sensor network, its types and quantities are constantly increasing and they influence development of peripheral network directly. Based on the study on a series of problems in this paper, an embedded-based IOT gateway system is proposed in order to realize access of constantly changing sensor device in sensor network, integrated with current network technology and embedded system development technology. We summarize the system structure of IOT and analyze the functional demand for IOT gateway. Then, we design overall architecture of the gateway and propose the system solution by the scheme of ARM+Linux. By functional tests and implementation tests of designed intelligent IOT gateway, it shows that our system operates stably and satisfies expected demand. Therefore, it has practicality and reference value for the development and research on embedded gateways.. ACKNOWLEDGMENT This work is supported by the Jiangsu province science and technology support plan: multiple platform based on WEB community integrated information management system (BE2013685); Prospective joint research plan project in jiangsu province: the wisdom of the town system based on GIS (BY2014001-03) funding. REFERENCES [1] Clayworth Geoffrey T., Bohlen Heinz P., IOT. A new, environmentally-friendly tube for UHF television transmitters, IEE Conference Publication, vol. 35, no. 4, pp.45-50, 1992. [2] Zhu Q, Wang R, Chen Q, et al., IOT gateway: Bridging wireless sensor networks into Internet of things, Embedded and Ubiquitous Computing (EUC), proceedings of IEEE/IFIP 8th International Conference on. IEEE, vol. 7, no. 2, pp. 347-352, 2010. [3] Diane J. Skiba, The Internet of Things, Nursing Education Perspectives, vol.34, no. 3, pp.63-64, 2013,. [4] Li Fei, Wan Zhou, Xiong Xin, Research on sensor-gateway-terminal security mechanism of smart home based on IOT, Communications in Computer and Information Science, Changsha, China, vol. 5, no. 9, pp.415-422, 2012. [5] Savolainen Teemu, Soininen Jonne, Silverajan Bilhanan, IPv6 addressing strategies for IOT, IEEE Sensors Journal, vol.13, no. 10, pp. 3511-3519, 2013. [6] Wen Yingyou, Li Zhi, A service-integrated sensor network middleware applied to industrial solutions of IOT related, Telecommunication Systems, vol.53, no. 9, pp.61-68, 2013. [7] Fantacci Romano, Pecorella Tommaso, Viti Roberto, A network architecture solution for efficient IOT WSN backhauling: Challenges and opportunities, IEEE Wireless Communications, vol.21, no. 12, pp.113-119, 2014. [8] Wang JianZhong, Tian Li, Wu Ling, ARM920T-based microcontroller AT91RM9200 for residential gateway application, Control & Automation, vol. 20, no. 1, pp.49-51, 2004. [9] WANG Yiping, WEI Wei, Realization of network security framework netfilter in Linux, Computer Engineering and Design, vol.27, No.3, pp.439-443, 2006. DOI 10.5013/IJSSST.a.16.1B.11 11.7 ISSN: 1473-804x online, 1473-8031 print