IoT-Fog based Smart-Building Security System Design and Performance Evaluation

Corresponding Author: Maha Medhat Department of System and Computer Engineering, ALAzhar University, Cairo, Egypt Email: engmahamedhat86a@gmail.com Abstract: This paper aims to develop a smart building-security system utilizing fog technology. Fog computing is an innovative solution to reduce latency and network congestion, in which the cloud is extended to the edge of the network. The proposed system can detect an intruder, fire and water leakage. It is implemented using Raspberry Pi, Arduino, Pi-camera and different sensors. The sensors are installed on Arduino and Pi-camera is mounted on Raspberry Pi. The Raspberry Pi is used as a fog node to fit the time-sensitive nature of the system. The performance was evaluated through the iFogSim toolkit. Fog reduces 33.26 and 46.8% average latency and sensor delay as compared to the cloud. Also, the value of the network usage decreases by 71% in the case of fog-based even with increased network load. Finally, the iFogSim was evaluated by measuring the simulation time, which gave acceptable results of about 8.5 sec.


Introduction
Internet of Things is a network of interconnected electronic devices capable of sending data without interference or with minimal human intervention. This technology has been widely used for emergency applications such as smart city applications, health monitoring and smart building security. The smart building-security system becomes one of the critical issues that require research and study to protect people's lives and properties where any type of delay could be life-threatening (AlHammadi et al., 2019).
Fog is a complementary technology to cloud computing aiming to meet time-sensitive application requirements represented in low latency and an acceptable value of network usage to avoid congestion and further delay. This new technology decreases the volume of data that needs to be transferred to the cloud (Mukherjee et al., 2018;Khakimov et al., 2018).
In this study, an IoT-Fog based building security system is proposed and simulated to take the advantages offered by both fog computing and the Internet of Things. The system is implemented for monitoring the presence of intruders using the combination of motion detection and sound detector, early detection of fire using three different types of sensors and protects the building from water leakage.
The system also utilizes the capability of a door open sensor and glass break detector to detect any suspicious activity. The system is implemented on Raspberry Pi 3 and Arduino. Raspberry Pi was chosen as the system control unit to employ as a fog node (Lavassani et al., 2018). The system is expected to recognize the emergency type and report the exciting situation to the relevant emergency department. The system is also equipped with a feedback mechanism that warns the house owner who can cancel the false alarm within 10 sec to avoid false positive alarm.
To show a preference for fog computing compared to traditional cloud computing, the system performance was evaluated using the iFogSim toolkit. The evaluation includes the measurement of system latency and network usage. The results showed a significant decrease in their values in the case of fog computing. Finally, the iFogsim toolkit was evaluated by measuring the execution time.
The structure of the paper is organized as follows: Section II comprises some related work that has been done by researchers in this field. Section III gives details about the proposed system design approach. Section IV, presents system evaluation, simulation results and discussion. The summary of the paper is concluded in section V.

Related Work
Various technologies used in the proposed system were presented and discussed in this section.

A. Fog Computing
Fog computing is an emerging and evolving technology that bridges the cloud and the Internet-of-Things (IoT) world. It acts as a layer between them to allow computing in a decentralized manner (Cisco Systems, 2015). It provides a promising approach for processing a huge amount of data generated and consumed by billions of devices connected to the Internet of Things at the edge of the network (Naha et al., 2018;Habibi et al., 2020).
In the last few years, researchers have developed several emergency response systems based on fog technology. Paul et al. (2018) have proposed a fog computing-based IoT for a health monitoring system to help patients who suffer from chronic diseases. The proposed system reduces the amount of data that is transferred between the cloud and sensor networks. It also overcomes a data center failure bears with it. Dar et al. (2018a) has presented an automated accident detection and response system which makes use of fog computing to decrease response time. System evaluation by iFogSim toolkit is introduced in (Dar et al., 2019;2018b). Sarkar and Kumar (2019) have developed and simulated a fog based intelligent security system using the PTZ controller. Also, (Peng et al., 2020) proposed a traffic analysis system using broad learning which supports traffic-intensive applications utilizing fog computing to save bandwidth resources by offloading the traffic data uploading tasks to the fog nodes.
To facilitate the fog based system evaluation, there have been some studies for the edge and fog computing simulator. Gupta et al. (2017) conducted a study entitle " iFogSim: A Toolkit for Modeling and Simulation of Resource Management Techniques in Internet of Things, Edge and Fog Computing Environments ". It introduced an open-source simulator for edge and fog computing to evaluate the IoT environment scenarios in terms of latency, network congestion, energy consumption and cost.
The iFogSim depends on sensor-actuate architecture as illustrated in (Mahmud and Buyya, 2019). In this architecture, data is initially collected from sensors then broadcasted to local fog server either in an event or periodic manner. Subsequently, local fog nodes process the received data. Lastly, necessary reactions are directed back to actuators.
The cloud-only placement and Fog-based scenarios are modeled in the simulator. The cloud-only is based on the traditional cloud-based where all modules of an application run in the data center. Sensors transmit the sensed data to the cloud where it is processed. While for the fog placement, the data is processed at the fog server.

B. Building Security System
There have been several previous studies on IoT based building-security system. Tanwar et al. (2017) conducted a study entitled "An Advanced Internet of Thing based Security Alert System for Smart Home". It describes inexpensive home security systems. The hardware used was Raspberry Pi, Infrared (PIR) and, modules to minimize delays during e-mail alerts. PIR sensors are used as a motion detector and Raspberry Pi as the control unit.
Another research was conducted by (Kumbhar et al., 2018) entitled "IoT Based Home Security System Using Raspberry Pi-3". It proposed IoT enabled security system to send an email to the owner of the home once an intrusion is detected in front of the door. Raspberry pi controls the whole system where an image is captured by pi-camera. The motion is detected by using a motion sensor, Ultrasonic sensor and microphone.
The third study was conducted by (Rani et al., 2018) entitled "IoT Based Home Security System Using Raspberry Pi with Email and Voice Alert". It proposed a security system using raspberry pi which sends a real-time SMS alert to authorize person through WAY2SMS which is connected through the internet. The image of the intruder is then sent via g-mail after motion detection.
Taryudi and Budi (2018) conducted a study entitled "IoT-based Integrated Home Security and Monitoring System". This study discusses the design of a monitoring system to detect the room temperature and humidity to detect the stove's fire. The system is controlled by NodeMCU ESP8266.
The fifth study was conducted by (Surantha and Wicaksono, 2019) under the title "An IoT based House Intruder Detection and Alert System using Histogram of Oriented Gradients". This research discusses the design and implementation of a home security system with human detection capability using Raspberry Pi 3 and Arduino. The webcam is mounted on the Raspberry Pi and the PIR sensor is installed on Arduino. The movement around the sensor is detected by the PIR sensor which activates the webcam to capture a picture. The author proposed a Histogram of Oriented Gradients (HOG) and Support Vector Machine (SVM) to detect the suspicious object. The alarm then is activated and a warning email is sent to the owner. This system is very good because it can detect the intruder with an accuracy of 90% as illustrated by authors.
Al Rasyid et al. (2018) proposed a smart home system using raspberry pi as a main centralized controller. The system has several end nodes using Arduino and can work in two modes of access that is a local mode (intranet) and internet to facilitate the use of a large scale. Saheed et al. (2019) proposed a fire prevention and surveillance security system as an efficient means of controlling intruders, fire-outbreak as well as serving as a surveillance system. It consists of a gas sensor, PIR sensors, buzzer, Global System Mobile (GSM) module, Liquid Crystal Display (LCD) and RGB Light Emitting Diode (LED). All components were connected to the Arduino Mega microcontroller.

C. Fog and Cloud-based Smart System
There have been a limited number of studies that combine IoT smart system and cloud-fog based technology. The author in (Yuan, 2015) conducted a study entitled "Study of Smart Home System Based on Cloud Computing and the Key Technologies". This study proposed a new smart home system that is based on the combined development of cloud computing and the Internet of Things. The proposed system is greatly shortens processing time when compared to ordinary intelligence lives.
Another research was conducted by (Stojkoska and Trivodaliev, 2017) entitled "Enabling internet of things for smart homes through fog computing". Through simulation on thereal smart meter dataset, the result showed that fog computing based on predictive filters can reduce the number of transmissions and minimize smart home network traffic.
Dutta and Roy (2017) have conducted a study under the title "IoT-fog-cloud based architecture for smart city: Prototype of a smart building". It aims to improve the standard of living at home and in-office with newly improved working facilities where the whole system will be automatic, efficient and will be under the control of the user via his/her smartphone done by the integration of IoT, fog and cloud.
The fourth study was proposed by (Shah, 2017) entitled "A Mobile Ad hoc Cloud Computing and Networking Infrastructure for Automated Video Surveillance System". It introduced a mobile automated video surveillance system that requires a vast quantity of computing and storage resources. The author built the Surveillance System based on mobile ad hoc network cloud computing. The proposed system has been implemented on a group of Wi-Fi Direct enabled Samsung mobile devices.
From the literature review, there have been few researchers who focus on the fog, smart building system. However, there has been no researcher specifically discussing fog-based intruder detection and fire prevention. Also, several studies did not compare the fog based system to traditional cloud computing. Therefore, in this research, the design is proposed to minimize system latency and network traffic. The research also compares the important network parameters in the case of designing the system with fog or only-cloud technology.

The Architecture of the Proposed System
Based on the fog technology advantages, a fog-based building-security system is introduced. The system design approach is discussed in this section. The general fogbased system architecture is shown in Fig. 1. It consists of three layers, sensors layer, fog layer and cloud layer.
The system is implemented on Raspberry Pi 3, Arduino microcontroller (Surantha and Wicaksono, 2019), Pi camera and, several sensors. The Raspberry Pi is chosen as the control unit because it can be implemented as a fog node where all sensors data is processed over it near the source. Arduino is used to integrating all the electronic devices into one environment.

A. General System Design
To ensure the complete safety of people's life and property, the system has been designed to detect three main emergencies. The proposed system can early detect if there is an intruder, a water leakage, or a fire (Fig. 2).
For early fire detection, the system will continuously monitor the surrounding temperature, the level of carbon monoxide in the air and, the presence of thick smoke. If any of these signs are presented, a fire warning is sent to the user's smartphone and the nearest fire station.
In this research, we assume the system is designed for a private building. The PIR sensor reads every movement that passes through the detection range of the PIR sensor, i.e., around 4-7 m. The PIR sensor reads continuously until a movement is found. If there is a movement, then the system will check the sound detector. The system then sends an alarm to the owner's mobile. If the alarm notification did not cancel in 10 sec, the Pi Camera is activated to capture the intruder picture and to record the theft video.
A door open sensor and a glass break detector are used to detect any suspicious activity to confirm the home attack situation and inform the nearest police station. The proposed system also protects the building from drowning with water through a water sensor. The complete system workflow is shown in Fig. 2.

B. Hardware Design
The hardware layout is outlined in this section. That involves the selection of the electronics parts and the integration of all the components. Figure 3 shows the hardware design for our building-security system.  Raspberry Pi 3 Model B was used as the processing module. We used a PIR motion sensor, sound detector, door open sensor and glass break detector to detect an intruder. Temperature sensors, a carbon monoxide detector and a smoke sensor were used for early fire detection. A water sensor is used to report the water leakage case. All sensors were connected to the Arduino for easy sensor data handling. Arduino is connected to the Raspberry Pi via the USB port. This is by far the easiest method that minimizes wiring and hassle. To capture an intruder picture, the Raspberry Pi Camera Module is connected to the RPi via the camera module port. For sending and receiving SMS text messages, a GSM modem is connected up to the Raspberry Pi. The Raspberry Pi 3 is also connected to the internet so that the system can send the picture and the theft video to be stored in the cloud.

Simulation and Result Discussion
To illustrate the importance of fog computing versus the traditional cloud computing, the simulation was done considering the anti-theft system that uses the PIR and the sound detector. Simulation has been done using the iFogsim toolkit to evaluate the system performance in the form of system latency, total network usage and simulator execution time. The structure of the topology used for the anti-theft system is shown in Fig. 4.
The system has been evaluated on several physical infrastructure configurations which differ in the number of Raspberry Pi and Arduino edge as shown in Table 1. Two placement policies have been evaluated in the physical topology cloud-only placement and fog-based placement. The sensor node is represented in the motion sensor and sound detector, while the smartphone and picamera are modeled as an actuator node.
The simulation configurations of the different devices (MIP-RAM-UP Link BW-Down Link BW-Busy and Idle power) are described in Table 2. While the Network latency between devices is tabulated in Table 3.
We conducted several simulation runs and the average results were computed to avoid the effect of the simulation time overhead and machine busy and idle power. The results are a clear demonstration of how the system works faster and performs better in the fog computing scenario. System latency and system delay comparison is illustrated in Table 4. Figure 5 and 6 show the comparison between cloud and fog-based on network usage and simulation time.

A. System Latency and System Delay
The Building-Security system is related to security and detection both, so latency is the most vital parameter to achieve a quick emergency response. The system latency and delay comparison between cloud and fog-based is given in Table 4. The average latency of the fog-based system is 62.8 ms where the latency in the case of the cloud scenario is 94.1 ms. Latency reduction is achieved through processing the gathered data on fog nodes. The simulation also shows lower values of the delay between the PIR sensor and the Raspberry Pi (emission of data, processing and then forwarding to gateway and Arduino to raspberry pi), where the delay is 47.5 and 89.3 ms for fog-based and cloud-only respectively.

B. Network Usage
As shown in Fig. 5 the total network usage is significantly less in the case of fog computing. Where network congestion and slow speed transmission occur when only-cloud computing is used due to the increased traffic. The average network usage for cloud-only and fogbased is 43215 and 12434 kbps respectively. Figure 5 also demonstrates that as the number of devices connected to a network increase, the difference between network usage values of the two scenarios increases. For the first configuration, the difference is 4325 and for configuration 2, 3 and 4, the difference in the network usage values was 12908, 47295 and 58598 respectively. Thus, we can conclude that the increased number of connected devices can demonstrate the importance of using fog computing as it increases throughput and transmission speed.

C. Simulation Time
Execution time for various configurations was measured and illustrated in Fig. 6. The simulation time increases as the number of connected devices increase. The increase in simulation time is almost linear for both fog-computing and traditional cloud computing scenarios. The simulation time varies from 3.5 sec to 12.8 sec for the fog scenario and from 4.2 to 13.5 sec for cloud computing. We can conclude that simulation can be run in an acceptable time about 8.5 sec even if a considerable number of devices are added.

Conclusion
This paper has proposed a smart-building security system based on IoT and fog technology. The proposed system consists of Raspberry Pi 3, Arduino, several sensors and a Pi camera. The novelty of this system is using the raspberry as a fog node to allow efficient and localized processing of data.
The performance of the proposed system is evaluated using the iFogSim toolkit. The simulation shows that the average latency is 94.1 and 62.8 ms for cloud-only and fog-based scenarios respectively, which decreased by 33.26%. Also, the value of the delay between the PIR sensor and the Raspberry Pi has been decreased by 46.8% in the case of fog-based.
The simulation also illustrates on average, the network usage decreases by 4325, 12908, 47295 and 58598 for the different tested configurations. The network usage reduction is about 71% in the case of fog-based.
Finally, the iFogSim has been evaluated by measuring the simulation time, which proves that simulation can be run in an acceptable time of about 8.5 sec. In the future, this model will be verified in a real fog environment for practical realization.

Acknowledgment
This work is supported by the System and Computer Engineering Department, AL-Azhar University.