A Sleep-Awake Scheme Based on CoAP for Energy-Efficiency in Internet of Things

Internet Engineering Task Force (IETF) have developed Constrained Application Protocol (CoAP) to enable communication between sensor or actuator nodes in constrained environments, such as small amount of memory, and low power. IETF CoAP and HTTP are used to monitor or control environments in Internet of Things (IoT) and Machine-to-Machine (M2M). In this paper, we present a sleep-awake scheme based on CoAP for energy efficiency in Internet of Things. This scheme supports to increase energy efficiency of IoT nodes using CoAP protocol. We have slightly modified the IoT middleware to improve CoAP protocol to conserve energy in the IoT nodes. Also, the IoT middleware includes some functionality of the CoRE Resource Directory (RD) and the Message Queue (MQ) broker with IoT nodes to synchronize sleepy status. Keywords— Sleeping scheme, RD, CoAP, IoT.


I. INTRODUCTION
Internet of Things is large network of connected devices including various sensors and actuators to achieve desired objective of an individual or organization.It is composed of various components, communication technologies, data storage facilities and decision support systems.
IETF CoRE (Constrained RESTful Environment) WG (Working Group) had proposed CoAP for constrained networks [1].CoAP provides a request/response interaction model between application endpoints using REST architectural style based on UDP.A size of CoAP message is small than HTTP and CoAP is more efficient than HTTP [2,3].IETF CoRE WG begin the standard track from 2010 and it had been published RFC 7252 in 2014.For CoAP, there are several implementations are available, and several IoT or M2M platforms use CoAP as communication protocol.IETF CoAP provides numerous potentially beneficial features for implementing wireless sensor networks with embed applications [4,5].Therefore, CoAP will become a part of the new dominant design for IoT applications [6].
In this paper, we present a sleepy-awake scheme for energy efficiency of IoT nodes using CoAP protocol.Sleepy approaches are necessary for constrained devices.We have designed and implemented a sleepy mechanism for supporting a sleepy approach for IoT nodes.The proposed network includes IoT node, IoT middleware and Web Client.The proposed scheme uses HTTP and CoAP for communication between each element in the network.For this scheme we have used CoAP libraries to implement communication that are not only used for sleepy mechanism but also used for delivering data to the web client application.
Rest of this paper is structured as follows; Section 2 introduces proposed sleepy scheme and section 3 illustrates the usage of the scheme for IoT nodes.Section 4 illustrates experiment of the sleepy scheme using IoT nodes and section 5 describes the performance.Finally, we conclude our paper in section 5.

II. PROPOSED SLEEPY-AWAKE SCHEME
The CoAP is a protocol intended towards devices which are constrained in terms of memory, processing and power i.e. small low power sensors, switches and valves etc.The CoAP allows such devices to interactively communicate over the Internet.The CoAP is a specialized web transfer protocol for constrained devices.It is expected that in CoAP networks, there will be a certain portion of nodes that temporarily suspend CoAP protocol communication to conserve energy.
Sleepy feature is necessary for constrained environment.CoAP nodes work on constrained environment, therefore, direct discovery of nodes is not practical due to sleepy nodes.There have been several IETF drafts for sleepy nodes in constrained environments.Our implementation design is based on the sleepy mechanism presented in [7].
CoRE RD is an entity which hosts descriptions of CoAP nodes held on a server.The server should be based on some power supply (not batteries), which can always allow lookups for retrieving registered information [8].In CoAP based communication network, a CoAP client can search a CoAP node from RD and access it.Before the searching process, the CoAP node needs to register its information to the RD [9].
An extension of the CoRE RD called MQ broker which is published as a draft in IETF [9].Functionalities for publishsubscribe communication are incorporated using the broker which enables to store and forward message from CoAP nodes.A CoAP node can send a data to the MQ broker and can switch into sleep mode.Then a CoAP client can request to MQ broker for getting the data which is sent by the CoAP node before sleep.The data is temporal, that can be updated or removed.The IoT middleware is used for in constrained networks for several reasons such as to improve performance and sleeping device scheduling.In CoAP networks, there will be a certain portion of devices that are "sleepy" and which may occasionally go into a sleep mode and temporarily suspend CoAP protocol communication.We present a mechanism for looking up sleepy nodes through interaction with IoT Middleware in the IoT.The functionality of RD and MQ are incorporated as part of the IoT middleware as shown in Figure 1.
IoT middleware includes RD functionality to manage information of IoT node.RD supports HTTP service to Web Client application for discovering and looking up information of IoT node which are registered by IoT node through CoAP service using RD.Functionality of MQ is used for performs store-and-forward messaging [10].MQ enables IoT node publishes context data to the middleware to be subscribed by web client application.In the same way, web client application publishes a command to the IoT middleware and forward to IoT node when the node is available.
Models can explicitly explain processes and visualize a flow in a view [11,12].Business process model and notation (BPMN) is a used for representing processes.BPMN involves flowchart which is better than UML diagrams for non-complex programs [13,14].Figure 2   We design the mechanism using functionalities of RD and MQ for web client application to learn about sleepy state information of IoT node.Synchronous process is used by web client application to synchronize the sleep time of the IoT node.
Figure 3 shows IoT node receives a PUT request from middleware for change sleepy state.When web client application requests for get node's data, then IoT middleware sends a respond message with sleep information.Web client application gets node's delay information from IoT middleware to synchronize the sleep state information.IoT middleware is implemented in java compile environment.The IoT middleware is a web application which support web link to be accessed by user such as web client and HTTP client.In the service layer, our service provider supports SOAP web service which uses HTTP client to request the IoT middleware.

Working of sleepy scheme is shown in
We implement the CoAP protocol in the proposed environment, and verify the interoperability.Figure 5 shows environment for testing CoAP client and CoAP server program.The CoAP client was written by Java, so it was executed in JRE environment.The CoAP server uses Linux C library and can be executed where the Linux that GCC compiler is exist.
The CoAP client slide uses Californium version which is based on the Java language, and the CoAP server uses Californium library which is based on the C language.The Californium library is ETSI IoT CoAP protocol and it uses "3-clause BSD" license [15].The Libcoap protocol is implemented by using Linux C library, and it uses "BSD" license.When the client sends a message to the server, the server sends the response message.The CoAP protocol is based on UDP protocol, and when the response message is not reached to the server in the pre-defined time, it sends message again.Repeat this again 5 times and if it is not received response message, this means that the communication is failed.We have developed testing applications for both client and server side.Figure 6 and Figure 7 presents sample snapshot of execution of client and server application respectively.When the CoAP client sends request message to the CoAP server via the CoAP protocol, the CoAP server processes it and sends reply message back to the CoAP client.These figures show exchange of request and response messages.The value "CON" is the T (Type) value of the CoAP protocol message format, and the "GET" is the method type of the CoAP protocol, and the IETF defines 4 method types.MsgId (i.e.10658) means ID of message, and this value can be created automatically or developer can define it.The "#Options: 1" means the number of message attributes included in CoAP protocol message, and basically it is "MsgId" attribute.
Figure 7 shows experiment screenshot of node emulator in CoAP server.This program is executed with Console in Linux environment, and receiving message from a CoAP protocol node and collecting current temperature is shown on Console screen.7.In this period, the IoT node will stop unit's functions.The record list given in Figure 8 shows that in the period from "02:33:12" to "02:33:41", the IoT node had slept 15 seconds and waked up.
V. PERFORMANCE EVALUATION Using our test applications for the proposed IoT system, we evaluated the performance of the message interaction for sleepy schemes.In this experiment, when an IoT node wakes up from sleep, then a web client application will get context data of IoT node. Figure 10 shows testing results of sleep scheme.This screenshot shows the results of context data of IoT node and time estimation for the process.The unit of time is millisecond.From the result, the timestamp of the process is 26 ms.In this study, we have presented a sleepy scheduling scheme to build on IoT middleware for energy conservation in IoT elements.We applied CoAP and CoAP extensions for interaction of these elements.IoT node is based on CoAP protocol, which works in constrained environment using low power and limited RAM and ROM.We designed and implemented the IoT node to fit the requirement.IoT middleware works with IoT node via CoAP in the Constrained RESTful Environment.We proposed an enhanced mechanism for management of sleepy nodes using CoRE RD and CoAP MQ.This mechanism is tested with IoT node and IoT middleware based on CoAP.In this paper, we have only presented our design and initial working implementation.In future, we will perform experiments to extensively analyse our design and resultant energy savings.

Fig. 1
Fig. 1 Functionality of RD and MQ in IoT Middleware for sleep mode shows sleepy scenario using business process model.The process begins from web client application part.It sends message to RD to get node's data.RD check node's sleep state by node ID and RD returns sleep information to web client application.Web client application gets node's sleep delay data and synchronize the sleep state information with IoT middleware.When web client application knows node is awake, web client application can get the contextual data of node.

Fig. 2
Fig. 2 Business process model for sleepy scenario

Figure 4 .
Web client application sends sleep command request to IoT node through IoT middleware through HTTP protocol using node ID, sleep_state and sleep_duration as parameters.IoT middleware retrieve the IP address of IoT node via the node ID, and forward the sleep properties to IoT node through CoAP.IoT node invokes do_sleep() function for falling asleep.

Fig. 4
Fig. 4 Implementation of request command for sleep modeWe have used Java framework to implement IoT middleware and C library to implement IoT node[15][16].IoT node is implemented in Linux C compile environment because of IoT node working in the constrained environment.IoT middleware is implemented in java compile environment.The IoT middleware is a web application which support web link to be accessed by user such as web client and HTTP client.In the service layer, our service provider supports SOAP web service which uses HTTP client to request the IoT middleware.We implement the CoAP protocol in the proposed environment, and verify the interoperability.Figure5shows environment for testing CoAP client and CoAP server program.The CoAP client was written by Java, so it was executed in JRE environment.The CoAP server uses Linux C library and can be executed where the Linux that GCC compiler is exist.The CoAP client slide uses Californium version which is based on the Java language, and the CoAP server uses Californium library which is based on the C language.The Californium library is ETSI IoT CoAP protocol and it uses "3-clause BSD" license[15].The Libcoap protocol is implemented by using Linux C library, and it uses "BSD" license.

Fig. 8
Fig. 8 Context data record list in the sleep mode of IoT node Figure 8 shows a context data record list when the IoT node falls asleep after receiving a sleep command from IoT middleware.IoT node received a CoAP message with a URI-query specifying sleep duration is 15 seconds as shown in Figure7.In this period, the IoT node will stop unit's functions.The record list given in Figure8shows that in the period from "02:33:12" to "02:33:41", the IoT node had slept 15 seconds and waked up.

Fig. 9
Fig. 9 Message transfer process for sleep-awake scheme Figure 9 shows message transfer process for sleep scheme.In the synchronous scheme for sleepy IoT node, the state information of sleepy time is known by the web client application.When the time of sleep is up in the web client application, then it sends a request to the IoT middleware for acquiring context data of IoT node.Then the IoT middleware sends a CoAP request message to the IoT node to get context data.Finally, IoT middleware responds the context data to the web client application.Figure10shows testing results of sleep scheme.This screenshot shows the results of context data of IoT node and

Fig. 10
Fig. 10 Result of context data and time estimation for sleep scheme