Developing Actor-Based Middleware as Collector System for Sensor Data in Internet of Things (IoT)

Internet of Things (IoT) plays an important role in supporting wireless communication for middleware in collecting data sensors. An actor-based middleware is designed to bridge protocol differences between cloud and sensor nodes. This middleware also acts as an initiator in collecting data from several sensor nodes, and then sending the collected data to the cloud. Incorporating the differences of communication protocols and data formats between sensor nodes and cloud is the responsibility of middleware. This Middleware acts as an actor by acting proactively accessing data from each sensor node, so that it can facilitate the completion of sending data from the sensor node to the middleware by avoiding from "signal collisions” among sensor nodes. After the data is collected in the middleware, the data is sent to the cloud using the Websocket or HTTP protocol above the TCP / IP protocol. The performance of the system is evaluated based on the success of the middleware bridging communication between sensor nodes and the cloud, as well as the readability of IoT data sensors that have been adjusted by cloud. The test results show that built-in middleware can bridge protocols between cloud and sensor nodes. In addition, the Websocket usage protocol produces a lower delay value than the MQTT and CoAP protocols. Keyword : Midleware, protocols,Cloud


Introduction
The Internet of Things (IoT) paradigm allows connectivity between various types of devices such as household furniture, environmental sensors, cameras, motorized vehicles, etc., using Internet media. IoT is simply a concept in which things in life can be equipped with sensors, microcontrollers, actuators, and transceiver modules and protocol stack, so that they can communicate with each other and interact with the surrounding environment [1].
An IoT-based system can consist of several components, including components of identification, sensing, computing, communication, service, and semantics. The main function of the computational component is processing data generated by the sensing component. Light computing processes such as converting analog signals from sensors to digital signals can be done on microprocessors / minicomputers located on the sensor node. Data processing can also be done in data centers (data centers) with the concept of cloud computing (cloud computing), which can support processing of more complex and larger data. Data processing carried out in the cloud can overcome the problem of limited electricity resources, memory and computing capabilities and service capabilities on the sensor node.
Sensing data from the sensor node will be sent to the cloud for processing. Because the format of data from sensor nodes cannot always be directly understood by data processors in the cloud due to the diversity of communication protocols used by sensor nodes, middleware is needed to bridge communication between sensor nodes and the cloud [2]. Because IoT is composed of intelligent devices in large numbers, one of the challenges in trying to maintain the availability of connectivity between these devices is interoperability between the elements involved [3]. The change in the paradigm on the Internet from "interconnected computers" to "interconnected objects" requires no small amount of effort, including the need for a middleware system that can simplify the development of applications and services needed [4].
A middleware can provide an abstract layer between infrastructure and applications [1]. Middleware is capable of integrating applications and services, each of which runs on a heterogeneous system [5]. There are several types of IoT middleware architecture, one of which is an actor-based framework, which emphasizes plug and play IoT architecture that is open [6].
In this study, researchers proposed the title "Designing an Actor-based Middleware as an Internet of Things Sensor Data Collection System". The proposed data collection system is expected to bridge the differences in systems that exist in the cloud and sensor nodes. This Middleware will also act as an initiator to access data directly to several sensor nodes, then the middleware sends data that has been collected to the cloud. The difference between communication protocols and the different data formats between sensor nodes and the cloud is the responsibility of the middleware to synchronize. The advantages of the middleware can reduce data traffic from the sensor node directly to the cloud.
Previous research has been able to bridge sensor node protocols with protocols recognized by the cloud, except that data traffic from the sensor node is sent to the middleware and immediately forwarded to the cloud in real-time [7], so there is a potential for collisions. data traffic that is passing through the communication media. This actor-based middleware will act proactively in accessing data from each sensor node reached by adjusting the protocol supported by the sensor node. This proactive method can prevent each sensor node from sending data simultaneously which results in delivery failure due to a "collision" of data transmission. After the data is collected, data is sent to the cloud with other protocols used, generally with TCP / IP. Sending data from the sensor node to the cloud will be carried out periodically by the middleware. Especially for data with a certain value, the middleware can forward it to the cloud as soon as it is received from the sensor node, without waiting for the scheduled period of sending data from middleware to the cloud. The advantage of this proactive method is to prevent or reduce the problem of data transmission failure. Illustrations of the whole system are shown in Figure 1 The performance of the system created will be evaluated based on the success of bridging communication between sensor nodes and the cloud, as well as the success of readability of IoT sensor data that has been adjusted by cloud.
Based on the background, the problems in this study can be formulated as follows: 1. How can the IoT sensor data collection system (middleware) access data from the sensor node? 2. How does the IoT sensor data collection system (middleware) authenticate and authorize the sensor node? 3. How can the IoT sensor data collection system (middleware) send data to the cloud that has a different communication protocol? 4. How can the IoT sensor data collection system (middleware) send data to the cloud based on time periods and based on data values? 5. How is the performance of the IoT sensor data collection system (middleware) seen from the functionality and quality of service?

Literature Review
In the study of this literature discussed earlier research related to IoT middleware as an intermediary between several different protocols. In "Challenges in Middleware Solutions for the Internet of Things" [8] there are some challenges faced by IoT middleware. One of the challenges is interoperability. Interoperability is one of the biggest challenges of IoT middleware, because there are so many and varied devices that interact with IoT, both now and in the future.
In "IoT Middleware Development as a Gateway for CoAP, MQTT, and Websocket Protocols", sensor node protocols with protocols recognized by the cloud can be bridged, except that data traffic from the sensor node is sent to the middleware and directly forwarded to the cloud in real-time. time [7,9,10,11]. This raises the potential for collisions / collisions between data traffic that is passing through the communication media.
The CoAP protocol and WebSocket operate in the form of a "client-server". The server will serve connection requests from other parties, namely the client. Client as the initiator who will contact the server. The server must have a specific IP address where the client can contact him. As described in the previous sub-chapter.
Unlike the two protocols above, MQTT operates in a "publish / subscribe" manner as explained in the MQTT sub-chapter. There are parties as subscribers, who subscribe (a topic) to brokers. One party as a publisher (a topic), which will send / publish through a third party, the broker. As a third party, brokers can disseminate information to each subscriber. Unlike the client-server, subscribers and publishers do not need to know their respective IP addresses. However, subscribers and publishers must contact brokers so that subscribers and publishers can exchange information. For this reason, the broker's address must be known by the subscriber and publisher. The number of subscribers and publishers is not limited, as long as they can be handled by brokers.
Following the next development, the broker at MQTT needed a database to store the data received from the publisher and then sent to all subscribers. Databases that can support the functionalities of MQTT are usually Redis and MongoDB. The data can be sent or accessed / distributed based on certain topics. Only with the appropriate topic, the subscriber will accept it.
The following example is how communication runs between publishers and subscribers. Nodes that as Subscriber register themselves with Topic1, then when a node publishes with Topic1 the subscriber nodes will be informed. So the broker receives information based on Topic1, and will disseminate that information to the nodes that subscribe to Topic1.

IoT Middleware
In the context of IoT, the existence of middleware can bridge communication between sensor nodes and clouds, because the format of data from sensor nodes cannot always be directly understood by data processors in the cloud due to the diversity of communication protocols used by sensor nodes [2].
1. Middleware for IoT is needed for several reasons, including: 2. The difficulty of forming and forcing vendors to use a standard on a variety of devices connected in the IoT network. 3. The need for an abstract layer can be used on all types of devices. 4. Middleware provides an Application Programming Interface (API) for communication with the physical layer and provides services to applications. 5. Reducing data traffic directly from the sensor node to the cloud. A middleware can provide an abstract layer between infrastructure and applications [1]. There are several types of IoT middleware architecture, one of which is an actor-based framework, which emphasizes plug and play IoT architecture that is open [6]. While according to Qusay Mahmouh [5] middleware can integrate several systems that run heterogeneous applications and services.

System Design
System design in this study consists of system flow design, middleware design, application design, and network architecture design for testing. System design is made by describing the system architecture based on the results of analysis of hardware requirements and software requirements that have been determined. This design is also based on the theory obtained in the literature study in the form of middleware architecture that supports interoperability. The design of this system is made to facilitate implementation, testing and analysis.
The built-in system as in Figure 1.1 can represent the whole system with many middlewares managing some sensor nodes. Nevertheless, this research project to evaluate actor-based middleware is suitable to have an actor-based middleware device with three sensor nodes, as shown as Figure 3.1. The middleware is implemented to bridge the protocol differences between sensor nodes and cloud gateway.
Meanwhile, the functional needs for this actor-based middleware are as follows 1. Sensor node-sensor nodes that use different communication protocols, namely CoAP, MQTT and WebSocket. Each sensor node is considered able to access the sensor devices installed on it, such as temperature sensors, humidity, and so on. Also each sensor node is equipped with a communication protocol and wireless device to send the data to the middleware. 2. Cloud uses only one type of communication protocol, in this study the cloud will use WebSocket. 3. Middleware can choose the protocol that corresponds to that used by the sensor node-sensor node to communicate. Middleware will read data from each sensor node sequentially (round robin). Doing round robin avoids from collision of wireless communication among sensor nodes. 4. Middleware can arrange data from each sensor node that has been read, and prepare by combining all data from each sensor node to be sent to the cloud. 5. Middleware uses the WebSocket protocol to send data that has been collected from the sensor nodes underneath. 6. As a support, the cloud can process and display combined data sent by middleware.

System Flow Designing
In the system developed, there are two types of data transmission. The first shipment is data from the sensor node (as a data source) to the middleware. The second shipment is data from middleware to the cloud (as a data store from all sensor nodes). Middleware can proactively access data from sensor nodes. The detailed mechanism of communication of each sensor node with different protocols is shown in Figure 3.1 and devices are also shown with allocated IP addresses.

Designing Middleware
Middleware developed applies a publish / subscribe pattern. This Middleware consists of three parts: application gateway, service unit, and sensor gateway. Application gateways provide an interface for middleware to send data to the cloud. The service unit is a part of the middleware that serves to provide an interface for the sensor gateway and application gateway. This service unit connects sensor nodes with brokers, and connects the cloud with brokers. The gateway sensor provides an interface for the middleware to read data from IoT node sensors. The gateway sensor makes it possible to use different communication protocols, and this protocol is adapted to the protocol used by the sensor node device.
Not only bridging sensor node protocols with protocols recognized by the cloud, middleware designed in this study will act proactively in accessing data from each sensor node reached by adjusting protocols supported by sensor nodes. This proactive method can prevent each sensor node from sending data simultaneously which results in delivery failure due to a "collision" of data transmission. After the data is collected, data is sent to the cloud with other protocols used, generally with TCP / IP. Sending data from the sensor node to the cloud will be carried out periodically by the middleware. Especially for data with a certain value, the middleware can forward it to the cloud as soon as it is received from the sensor node, without waiting for the scheduled period of sending data from middleware to the cloud. The advantage of this proactive method is to prevent or reduce the problem of data transmission failure.
Hence, this middleware device is designed to have three parts. The internal parts of the middleware along with the protocol or function in each part are shown in  Sensor gateways in middleware use protocols that are in accordance with the protocol used by the sensor node. Therefore, the communication protocol registration process from each sensor node in the middleware is needed.
The sequences diagram of communication between middleware and sensor nodes with different protocols, and between middleware and cloud are shown in Figure 3.3, Figure 3.4 and Figure 3.5. It also describes of how the middleware operates to accessing data from all sensor nodes with different protocols, and then to delivering all collected data to cloud. Nevertheless, before system is running every sensor node's address/ ID must be registered to middleware. Middleware can recognize every node and its in-use protocol. By round robin, middleware directly accesses to every available and registered sensor node provided with either CoAP or WebSocket. Each sensor node can inform middleware its data. Each sensor node with this protocols has to wait for Middleware to access and eventually reply with its data. While for a sensor node with MQTT, sensor node needs to send "subcribe" to middleware to inform its existance, and middleware also sends subcribes to sensor node. Subcription messages allow both devices to publish its data. The subcription of middleware to sensor enables to trigger sensor node to send its data, while sensor node is prohibited to proactively send its data until it gets a trigger of "publish message" from middleware. Thus, the natural characterics of sensor node with MQTT by sending or publishing its data by itself is restricted.
The data collected by middleware are stored in data base of Redis (database broker) .After getting data from all sensor nodes, eventually the middleware composes and deliveres all data under Redis to the cloud using WebSocket protokol.

Integration Testing
This test is done to get information whether a component can interact with each other when performing certain functions. The test uses two clients, by way of: client A with a protocol subscribing to a particular topic, then client B with another protocol publishing information with the topic, then testing whether client A can receive information on the topic. The results are shown in   it is concluded that the integration between two components (in this case are 2 nodes with different protocols) that can communicate from one component (node) to another (node).

Interoperability Testing.
This test is intended to determine the level of interoperability of the middleware designed. The middleware and node sensor devices are tested by using wireless networks whether the successful communication from sending data from the sensor node to the middleware is successful. If successful, how much success should be considered.

Testing of Hardware and Software
This test covers the needs of all hardware and software, especially in the middleware and sensor nodes, as well as a little discussion in the cloud. Figure 4.3a shows the middleware hardware that uses the Raspberry Pi. Next Figure 4.3b shows the sensor node device using NodeMCU Physically and electronically, the hardware can operate properly, meeting the expected functional objectives.

Success Rate of Delivery on Wireless Networks
Testing the success of data transmission between sensor nodes and middleware on wireless networks using wireless devices is indicated by packet loss rates and delay levels. The measurement results are shown in Table 4.1, where "Expected" is the amount of data sent at the sender, and "Actual" is the amount of data received at the recipient. While the results of measuring the delay in delivery are shown in Table 4.2. Measurement delay is based on the percentage of packet loss that is different. This is a representation of the state of wireless networks where packet loss is more likely to occur than using a wired network.    From the results of measurement of packet loss, the MQTT protocol packeloss is the smallest compared to the other two protocols. This happens probably because the size of the packet data formed by MQTT is smaller, so the success of reading the data packet is greater.
From the results of delay measurements on percentage of packet loss, WebSocket shows a small delay compared to the others. This is probably due to the delay measurement process starting when "immediately" the packet data is sent until it is processed by the recipient. "Immediately" sent this data packet to WebSocket faster than others.
The data sent by the sensor is proven to be compatible with the data received and stored by the application, including data that has been received by the application to be displayed and stored in the mongoDB database. The data displayed by the web-app is seen and compared to the data sent by the sensor. The results of these observations are shown in Figure 4.5. This web-app shows the same data format sent from middleware using websocket protocols, however the middleware itself has taken data from different node sensors via three different protocols.

Conclusion
Thus some conclusions can be taken from the results of the design and testing that have been done: As planned, that this middleware is actor-based, that is, middleware can provide "decisions locally", which can serve as a bridge between protocol differences from the cloud and sensor nodes.
Communication between the CoAP, MQTT and Websocket protocols in the middleware can be achieved by creating a gateway for each protocol, then connecting with a broker.
The use of the Websocket protocol produces a lower delay value than the MQTT and CoAP protocols.
The web application is able to show the same data format, since the middleware sends data using single protoco. However, the middleware access node sensoes via different protocols for respective node sensors.