www.seipub.org/ijc
International Journal on Communications (IJC) Volume 2 Issue 4, December 2013
The Design and Implementation of Lightweight RESTful Server Based on IoT Zesan Wei1 , Yahui Zhang2 , Bo Cheng2 , Junliang Chen3 The State Key Lab of Networking and Switching Beijing University of Posts and Telecommunications Beijing 100876, China
[email protected] Abstract In recent years, the technology of Internet of Things and the technology of Web Service have been developed rapidly. More and more sensors have been widely used to sense the surroundings in the field of railway,harbor,aerospace and heating.Using the technology of Internet of Things and the technology of Web Service, a new effective solution can be found for monitoring and controlling in the filed of heating. Based on B/S architecture, users can have access to the system, and get information anytime anywhere through a browser rather than that users use client applications to access the system based on C/S architecture.With the support of this system, it is more convienient for users to access the system for monitoring and controlling some data in the field of heating. Keywords Internet of Things; Monitor and Control in the Industry; Web Service; Restful
Introduction
With the development of science and technology, the Internet of Things has been widely used in many fields and more and more people pay attention to this emerging area. As known, the concept of Internet of Things was first presented in 1999. But now more and more communities agreed the Internet of Things is the third technological revolution of information industry in the world. In the filed of heating,users traditionally access the system under the use of client applications installed in computers.In this way, user couldn’t have access to the system without these client applications and it is not convienient.Using the technology of Web Service such as Restful, users can easily access the system through a browser.It is much more convienient for users than using client applications to access the system. The server system mentioned in this article is a new server system which incorporates the Internet of
128
Things technology and Restful technology. The whole system contains Data Access Layer, Resource Adapter Layer and Resource Access Layer. Data Access Layer provides some interfaces for users to access resources on the server. When users access the system, Data Access Layer extracts some parameters from requests, match some rules and convert them to a data object service. Resource Adapter Layer uses messages from the data object service to generate a data package and write it to the Resource Access Layer. Resource Access Layer connects with many physical modules which connect with many sensors. When Resource Access Layer accepts a data package, it will send a data package as a response to Resource Adapter Layer. Resource Adapter Layer accepts the data package from Resource Access Layer , parses the data package and transfers the result to Data Access Layer that then returns the result in a uniform format to users. The rest of this paper is organized as follows: related work is depicted in section II. Section III presents the architecture of the restful server system based on sensors. In section IV, the implementation of the system is displayed. Conclusion is made in section V. Related Work
The development of Internet of Things honors long history. In 1999, Professor Neil Gershenfeld, of MIT, published his book “When Things Start to Think”, where he described the principles of the “Internet of Things”, that is: The radio frequency identification (RFID), infrared sensors, global positioning systems, laser scanners and other information sensing device, according to the agreed protocol, to any article connected to the Internet up to information exchange and communication, in order to achieve intelligent identify, locate, track, monitor and manage a network. On November 17, 2005, in Tunis World Summit on the Information Society (WSIS), the International Telecommunication Union released the "ITU Internet
International Journal on Communications (IJC) Volume 2 Issue 4, December 2013
Report 2005: Internet of Things", pointing out that the ubiquitous "Internet of things" communications era dawns, all the objects from tires to toothbrushes, from housing to the tissue can be exchanged via the Internet initiative. In November 2008, IBM’s CEO Sam Palmisano outlined a new agenda for building a Smarter Planet, and clarified that the Internet of Things is the future trend. At present, China, USA, EU and other countries have fully realized the huge economic benefits of Internet of Things, and they are all spending heavily in-depth study to explore it. Using Restful technology, different applications which run on different machines can exchange data with each other without additional, specialized software or hardware. These applications according to specifications of Restful can exchange data with each other regardless of what language, platform and internal protocol they use. Restful technology is selfdescribing, self-contained network modules and can perform specific business functions. Restful technology is also easy to be deployed, because it is based on some standard technologies such as XML and HTTP. Restful technology reduces the cost of the application interface and provides a general mechanism for integrating business processes between several organizations. REST (representational State Transfer) refers to a set of architectural constraints and principles. The application or design which meets these constraints and principles is Restful. The most important principle of REST in web application is that client will exchange data with server in a non-state situation. Each request from client to server must contains necessary information so that server can understand what is the meaning of the request. In addition, client will not get any notifications whether the server restarts or not. Finally, non-status requests can be responded by any available servers, which is very suitable for deployment in the cloud computing environment.
www.seipub.org/ijc
understand other components and don’t exchange data with other components. Through limiting knowledge system to a single layer, REST can reduce the complexity of the system and promote the independence of the lower layer. When the constraints of REST architecture have been used as a whole, it can be applied in large client, reducing the delay of data exchange between client and servers and simplifying the architecture of the whole system and the implementations of the client and the server. There are four ways to parse XML object in Java , that is, DOM, SAX, DOM4J and JDOM. In this system SAX is utilized to parse XML object. When SAX parser based on the event-based model parses a XML object, a series of events can be triggered. When the parser discoveries a specified tag, it can activate a callback method and tell the method that a specified label has been found. The memory size of requirements for SAX is usually not very large. SAX sequentially scans the document. When it scans the start or the end of a document, or the start or the end of an element, we can write code to respond to these events and save data. The advantage of SAX is low memory consumption, but its disadvantage is complexity for coding. The Restful Server System based on Sensors mentioned in this paper incorporates the Internet of Things technology and Restful technology, using Internet of Things technology all kinds of data in factories can be automatically obtained, while using Restful technology information can be acquired on server anytime anywhere through a browser. Architecture of Lightweight RESTful Server
The Restful Server System is based on IOT contains Data Access Layer, Resource Adapter Layer and Resource Access Layer. We can see its architecture from Figure 1.
On the side of the server, applications and functions can be divided into different resources. Resource is a conceptual entity and open to clients. There are many types of resources such as applications, the record of database and algorithm. Each resource uses URI (Universal Resource Identifier) to get a unique address. While the rest uses standard HTTP methods such as GET, PUT, POST and DELETE. Another important principle of REST is hierarchical system, which means that one component can‘t
FIGURE 1 THE ARCHITECTURE OF THE RESTFUL SERVER
129
www.seipub.org/ijc
International Journal on Communications (IJC) Volume 2 Issue 4, December 2013
Data Access Layer This layer is between users and the platform of service. Through a browser, users can send request message to the server. When Data Access Layer of the server accepts the request from users, it will convert the message to a uniform format, generate a data object service according to a series of rules and transfer it to Resource Adapter Layer. When Data Access Layer receives the result as a response for Resource Adapter Layer, it will return the result in a uniform format to users.
request from a user ,extract the resource identifier and match rules of data object generation. If the result of match is true, these messages will be converted to a data object in XML format and this XML object is transferred to Resource Adapter Layer. When Data Access Layer receives the data of resource from Resource Adapter Layer, it will also convert the result to a XML object and return it to users. We can see its details from Figure 2. Start
Resource Adapter Layer Resource Adapter Layer provides a condition for the execution of data object service generated in Data Access Layer. When Resource Adapter Layer receives a data object service, it will extract some parameters from the data object service, and these parameters can be used to search the resource description table and interface description table, match the rules of data protocols and then generate a data package. Through the interface which connects between resources and the server system Resource Adapter Layer will write this package to the resource. When this layer receives a data package as a response from Resource Access Layer, it will parse this data package using the rules of data protocols and return the result that we need to Data Access Layer. Resource Access Layer Resource Access Layer connects with many physical modules, including many plcs (Programmable Logic Controller) that connect with many types of sensors which can sense the physical state of the surrounding and store their raw data in registers of these plcs. These plcs produced by different companies may have different data formats and data protocols. We will implement different data protocols for different types of plc to draw these data stored in registers. Implementation of The RESTful Server Based on IoT
Data Access Layer This layer provides many interfaces for users to access many resources on the server through a browser. All resources on the server are located by URI (Uniform Resource Identifier) and then users can have access to different resources by inputting different URIs. When users want to access a resource on the server by URI, Data Access Layer of the server will receive the
130
End
Receive Restful Request
Get Parameter From URI
Match Data object generation rules ?
Publish to Client
False
End Convert Parameter and Data to XML
True Convert to XML Object
Receive Data from Resource Adapter Layer
Transfer to Resource Adapter Layer
FIGURE 2 DATA FLOW OF DATA ACCESS LAYER
In the process of Data Access Layer, if these parameters from the request of a user can match rules of data object generation, it will convert these parameters to a XML object which includes much information what we want such as the variable name of the resource, the id of the resource, the data type of the resource (float data or digital data), the operation of the request (read or write), the date of the request and the time of the request. Resource Adapter Layer Resource Adapter Layer provides a condition for the execution of the XML data object generated in Data Access Layer. This layer includes three parts which are resource description table, interface description table and rules of data protocols. Resource description table records some information about these resources which have been accessed to the system. The information includes some attributes of resources such as name, value, type of control, type of data, rules of data protocol resources use. Interface description table records some information about these interfaces, through which resources connect with the system. The
International Journal on Communications (IJC) Volume 2 Issue 4, December 2013
www.seipub.org/ijc
information about the interface includes name, type, parameters of the interface, availability of the interface and so on.The rules of data protocols display how the data of sensors are stored in these registers in physical modules and how we can send protocol package to these modules and parse these packages as a response from these modules. After parsing the XML data object which is generated in Data Access Layer, these parameters from the XML data object will be utilized to search resource description table and interface description table and extract interface information and the type of protocol that resource uses. Then Resource Adapter Layer will use protocol information to match the rule list of data protocols. If successful, it will generate a package according to the description of the data protocol and write it to the modules through the interface. We can see the process from Figure 3.
FIGURE 4 DATA FOLW OF RESOURCE ADAPTER LAYER 2
Resource Access Layer Resource Access Layer displays many physical modules which have been connected with the system. These physical modules include many types of sensors and some plcs. In the production of industry, a large number of sensors connect with plc through some wires. These sensors can sense the physical state of the surrounding such as temperature, humidity, speed of the wind, pressure and store these raw data in registers. The physical module such as plc in Resource Access Layer receives a package from Resource Adapter Layer and will send a package as a response to upper layer. The upper layer will parse this raw package according to the rule of data protocol and get the value of the resource. We can see its detail process from Figure 5.
FIGURE 3 DATA FOLW OF RESOURCE ADAPTER LAYER 1
When Resource Adapter Layer receives a package as a response from Resource Access Layer, it will parse the package according to the description of data protocol, the value of the resource will be obtained and then transferred to Data Access Layer. We can see the process from Figure 4.
FIGURE 5 DATA FOLW OF RESOURCE ACCESS LAYER
Conclusions
The development of the Internet of Things has brought a new way to monitor and control data in the industry. The development of the RESTful technolygy improves the efficiency in accessing to resources on the server.
131
www.seipub.org/ijc
International Journal on Communications (IJC) Volume 2 Issue 4, December 2013
In this context, we have designed and implemented a lightweight RESTful Sever System based on IoT using Internet of Things and RESTful technology. This system should be much helpful for monitoring data and ensuring security in industrial processes.
Based on ZigBee Communication [A]. Proceedings of 2009
9th
International
Conference
on
Electronic
Measurement & Instruments (ICEMI’2009) Vol.1 [C]. 2009 GERSHENFELD, N. When Things Start to Think. Owl Books,
ACKNOWLEDGMENT
This research was supported by the National Grand Fundamental Research 973 Program of China under Grant No. 2011CB302506, 2011CB302704; National Key Technology Research and Development Program of China Research on the mobile community cultural service aggregation supporting technology" (Grant No. 2012BAH94F02); National High-tech R&D Program of China (863 Program) under Grant No. 2013AA102301; National Natural Science Foundation of China under Grant No. 61001118, 61132001); Program for New Century Excellent Talents in University (Grant No. NCET-11-0592); Project of New Generation Broad band Wireless Network under Grant No. 2011ZX03002-002-01. REFERENCES
Design and Implementation of Industrial Wireless Gateway
132
1999. ITU Internet Reports 2005: The Internet of Things,2005 Kumaran, S., R Liu, P. Dhoolia, T. Heath, P. Nandi, F. Pinel. A RESTful Architecture for Service-Oriented Business Process Execution. Proceedings of the 2008 IEEE International Conference on e-Business Engineering. 2008 Palmisano, Samuel J. A Smarter Planet: The Next Leadership Agenda, Council on Foreign Relations, November 6, 2008. Shuangquan Wang,Canfeng Chen, Jian Ma, "A Framework for Wireless Sensor Network Based Mobile Mashup Applications", World Congress on Computer Science and Information Engineering,2009 Vinoski S. RESTful Web Services Development Checklist. IEEE Internet Computing. 2008