7
SmartHome System Based on Containerization Technology Yunjie Zhong 1,a,* , Houjun Yang 2,b ,Yanbin Fan 2,c and Yu Zhang 2,d 1 Department of Data Science and Software Engineering, QingDao University, No. 308 Ningxia Road, QingDao, China 2 Department of Computing Science, QingDao University, No. 308 Ningxia Road, Qingdao, China a [email protected] *YunjieZhong Keywods: Docker, SmartHome, Openstack, SSM, nginx, zigbee. Abstract. In order to improve the robustness and scalability of the smart home system, this paper presents a design scheme that based on Docker containerization technology for building an SmartHome system cluster. In the Openstack environment to create a Docker container instance in this scheme.Through the Docker container engine, the SSM Web application environment is packaged and used to generate the application container.Load balancing of service traffic is implemented by nginx.Smart home gateway adopts development board based on ARM cortex-A9 as the hardware carrier.Realize distribution control that equipment communicate by wifi/zigbee/ Bluetooth and other protocol.The SmarthHome system deployed in the cloud to provide more space for the intelligence of the system.Compared with the deployment of smart home systems through virtual machines ,Docker containers have the advantages of fast start-up speed, high resource utilization and low performance overhead. 1. Introduction The data uploaded to the smart home control system is not just simple byte data, but also multimedia data such as pictures, audio, video and so on.The application server has a high demand for carrying capacity,under the pressure of a large number of users and huge amounts of data.A large amount of server hardware is purchased to meet the demand of maximum throughput of the system, and the computational resources of the server are wasted.In addition, SSM architecture need to configure the operating system,the standards library of development language,distributed cache and other dependent environment for provides the application services.This makes the system's rapid deployment, expansion, version of the trace more difficult. Virtualization technology can divide a physical host into several isolated parts, each server running an independent operating system and effectively utilizing the physical host resources.Docker containerization is a lightweight virtualization technology that does not rely on any operating system, development framework and design language, and can quickly package and publish application environments needed by smart home systems.Server clusters built with Docker containers can meet the need for server performance and rapid expansion. 2. The Working Principle and Advantages of Docker Docker containerization technology uses LXC (Linux Container) to implement functions similar to virtual machines, so as to provide more resources for users with more saving hardware resources.Different from VM's work principle, LXC is not a approach based on hardware virtualization ,but a system level virtualization approach.Docker has an abstraction layer that is less than a virtual machine.Since Docker does not require Hypervisor to implement virtualization of hardware resources, programs running on the Docker container are directly using hardware resources of the actual physical machine.As a result,Docker will have an advantage in efficiency on CPU and memory utilization.Docker takes advantage of the host kernel rather than Guest OS. When 5th International Conference on Mechatronics, Materials, Chemistry and Computer Engineering (ICMMCCE 2017) Copyright © 2017, the Authors. Published by Atlantis Press. This is an open access article under the CC BY-NC license (http://creativecommons.org/licenses/by-nc/4.0/). Advances in Engineering Research, volume 141 724

SmartHome System Based on Containerization Technology

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SmartHome System Based on Containerization Technology

SmartHome System Based on Containerization Technology

Yunjie Zhong1,a,*, Houjun Yang2,b ,Yanbin Fan2,c and Yu Zhang2,d 1Department of Data Science and Software Engineering, QingDao University, No. 308 Ningxia Road,

QingDao, China 2Department of Computing Science, QingDao University, No. 308 Ningxia Road, Qingdao, China

a [email protected]

*YunjieZhong

Keywods: Docker, SmartHome, Openstack, SSM, nginx, zigbee.

Abstract. In order to improve the robustness and scalability of the smart home system, this paper presents a design scheme that based on Docker containerization technology for building an SmartHome system cluster. In the Openstack environment to create a Docker container instance in this scheme.Through the Docker container engine, the SSM Web application environment is packaged and used to generate the application container.Load balancing of service traffic is implemented by nginx.Smart home gateway adopts development board based on ARM cortex-A9 as the hardware carrier.Realize distribution control that equipment communicate by wifi/zigbee/ Bluetooth and other protocol.The SmarthHome system deployed in the cloud to provide more space for the intelligence of the system.Compared with the deployment of smart home systems through virtual machines ,Docker containers have the advantages of fast start-up speed, high resource utilization and low performance overhead.

1. Introduction The data uploaded to the smart home control system is not just simple byte data, but also

multimedia data such as pictures, audio, video and so on.The application server has a high demand for carrying capacity,under the pressure of a large number of users and huge amounts of data.A large amount of server hardware is purchased to meet the demand of maximum throughput of the system, and the computational resources of the server are wasted.In addition, SSM architecture need to configure the operating system,the standards library of development language,distributed cache and other dependent environment for provides the application services.This makes the system's rapid deployment, expansion, version of the trace more difficult.

Virtualization technology can divide a physical host into several isolated parts, each server running an independent operating system and effectively utilizing the physical host resources.Docker containerization is a lightweight virtualization technology that does not rely on any operating system, development framework and design language, and can quickly package and publish application environments needed by smart home systems.Server clusters built with Docker containers can meet the need for server performance and rapid expansion.

2. The Working Principle and Advantages of Docker Docker containerization technology uses LXC (Linux Container) to implement functions similar

to virtual machines, so as to provide more resources for users with more saving hardware resources.Different from VM's work principle, LXC is not a approach based on hardware virtualization ,but a system level virtualization approach.Docker has an abstraction layer that is less than a virtual machine.Since Docker does not require Hypervisor to implement virtualization of hardware resources, programs running on the Docker container are directly using hardware resources of the actual physical machine.As a result,Docker will have an advantage in efficiency on CPU and memory utilization.Docker takes advantage of the host kernel rather than Guest OS. When

5th International Conference on Mechatronics, Materials, Chemistry and Computer Engineering (ICMMCCE 2017)

Copyright © 2017, the Authors. Published by Atlantis Press. This is an open access article under the CC BY-NC license (http://creativecommons.org/licenses/by-nc/4.0/).

Advances in Engineering Research, volume 141

724

Page 2: SmartHome System Based on Containerization Technology

a new container is built, Docker does not need to reload an operating system kernel like the virtual machine. To boot and load the operating system kernel is a time-consuming, resource - consuming process that is minute - level. Docker, however, omits the process because it uses the host operating system directly, so it takes only a few seconds to build a new Docker container.

According to the above analysis, Docker is more efficient in CPU and memory utilization than in virtual machines.

The experimental data are analyzed according to the reference data given by IBM's papers. The following data are measured on the IBM x3650 M4 server, and the main hardware parameters are as Fig.1

(1) 2 Intel Xeon E5-2655 processor,basic frequency 2.4-3.0 GHz.Each processor has 8 cores,so there are 16 cores altogether.

(2) 256 GB RAM. In testing,compute power data is obtained by running Linpack programs.The result is shown

below:

Fig.1 Diagram of computing power wastage In Fig.1, from left to right are the computer power data of physical machine , Docker and virtual

machine. It can be seen that Docker has almost no loss of computing power relative to physical machines,

and virtual machines have very obvious losses in contrast to physical machines. The computing power of the virtual machine is lossed about 50%.

The virtualization in IO device, there are many scenarios for Docker mirroring management, such as using Aufs file systems or Device Mapper to implement file management of Docker, and various implementations are slightly different in efficiency.Image is only a read-only base layer in the Docker system structure, and the layer here refers to AUFS. Using the AUFS file system allows multiple containers to share the underlying read-only file system, and multiple runnable containers can be started simultaneously.

3. Frame structure of SmartHome system SmartHome is an important part in the field of Internet of things.The SmartHome system is

divided into four layers from the aspect of the Internet realization: the perception layer, the transport layer, the intelligent layer and the application layer.As shown in Fig.2.

Through the perception layer to achieve the perception of the home environment, access to the relevant sensor data, which including light sensors, temperature and humidity sensors and security-related door sensors, infrared sensors, cameras, safety-related gas sensors, flame sensors,Including SmartHome terminal equipment, air conditioning, refrigerators, curtains, lights and so on. These perceptual terminals are communicated via zigbee and are also controlled by Bluetooth, infrared or WIFI.

Advances in Engineering Research, volume 141

725

Page 3: SmartHome System Based on Containerization Technology

Fig. 2 Hierarchy diagram of SmartHome system Transport layer: The transport layer is used to transport the sensor data and system control

information, for different communication protocol terminal node through the corresponding networking technology will be gathered to the information collected to the home gateway, and access through the Internet gateway to server, sent a large number of device data to the intelligent layer. Home gateway using Android-based development board as a hardware carrier, to achieve the perception of the terminal node data acquisition and upload control of the upper control instructions.

Intelligent layer (service management): the SmartHome sensor layer through the home gateway (Transport layer) transmission of data for dynamic aggregation, storage, logic processing and data analysis, data mining and other intelligent processing. In order to achieve intelligent processing while ensuring its robustness and functionality scalability, intelligent layer using the current popular SSM (Spring + SpringMVC + MyBatis) framework. The use of Docker container technology to achieve SmartHome "separation of brain and body", the SmartHome "brain" deployed in the cloud, to realize system load balancing, HA (High Available), data storage security.

Application layer (terminal control layer): To achieve "reduce costs and improve development efficiency", the development of SmartHome terminal control can be based on Cordova (PhoneGap) cross-platform operating mechanism, the page using H5 development, once develop can be used in everywhere. Any terminal device equipped with a Web browser can be used as a control terminal for the user to achieve "no difference" control.

4. Container Technology to Build SmartHome Server Cluster 4.1. Kubernetes Manages Docker Clusters to Achieve Load Balancing

Kubernetes is a container cluster management system that is opened source by Google.Kubernetes implements Docker based build containers and uses Kubernetes to manage containers in multiple Docker hosts in many ways.A number of Docker hosts are abstracted as a resource and managed by cluster, including task scheduling, resource management, flexibility, rolling upgrades, and so on.

YAML File can build container cluster quickly, provide load balancing, and solve the problem of container direct association and communication. Kubernetes can automatically manage and fix containers.For example,create a cluster, there are ten containers, if a container is abnormal shut down, it will try to restarting or redistributing containers always ensures that ten containers are running,but kill excess. The Kubernetes architecture is a typical Master/Slave architecture. Master is responsible for overall coordination control, and Slave is responsible for specific tasks.

Advances in Engineering Research, volume 141

726

Page 4: SmartHome System Based on Containerization Technology

Nginx as the front reverse proxy service access, when a user requests access to the server, the reverse proxy server will distribute service requests to different containers in Docker according to the load balancing strategy be preconfigured.Nginx runs as a Service in Kubernetes cluster.In the Kubernetes cluster Nginx needs to have a reasonable hot update scheme.The routing configurations of these Service in the Nginx reverse proxy need to be updated synchronously and become effective when the Service in the Kubernetes cluster changes, for example, a new Service is created or deleted.

The implementation scheme is as Fig.3: As shown in Fig.3,nginx is deployed in a Kubernetes cluster as a Service and can have multiple

Pod copies.Take a nginx pod as an example, the Pod includes three Containers are init-container, nginx-container and nginx-config-generator container.The three Container mount and share the same Pod volume,without persistent storage volumes, and the three Container mount paths are /etc/nginx/conf.d.

Fig.3 Nginx in a Kubernetes cluster

4.2. Integrated Docker in OpenStack Openstack virtualized the hardware resources into the computing resource pool,a series of API is

opened up to support the development of upper applications and satisfy the user's various requirements for computing resources.SmartHome systems based on containerized deployments are achieved by creating Docker on Openstack.

There is a variety of solutions for integrating Docker in OpenStack.Commonly used is Docker Driver for Nova,docker driver deployed as hypervisor by nova-api.Nova-computer-api connects nova-docker-driver as httpagent and docker rest-api via virt-ap to control the communication between docker and containers.In addition,Glance provides the image service as the local node of the docker register service.Compared to VM,it has some performance advantages,but does not support some of the advanced features of Docker.As shown in Fig.4.

The scheme adopted for this project is Murano, contributed by Mirantis.Murano and Kubernetes integrated, users can easily use the Murano function through Kubernetes, you can deploy Pod, Service, Replication, Controller, etc. through the Murano.

Advances in Engineering Research, volume 141

727

Page 5: SmartHome System Based on Containerization Technology

Fig. 4 Docker Driver for Nova Fig.5 Murano Integrate with Kubernetes

As shown in Fig.5,The integration of Murano and Kubernetes is mainly in the first three steps. The first step is to create a Kubernetes environment;Then, in the second step,add an application service to the Kubernetes environment we created. First, add a application template of cluster for Kubernetes, and then add a Pod application on the basis of the Kubernetes cluster;The third step is to add Container to the Pod based on the Pod of second step.After these three steps are finished, you can deploy the environment.In the end, Murano invoking Heat to creating a cluster of Kubernetes, and then the Kubernetes cluster creates the Pod based on the user's needs.

5. Communication Design of Smart Home Lower machine 5.1. Design of SmartHome Gateway

The gateway of smart home is the home network center, and all the smart home devices are added to the lan.It monitors and receives the control commands in the whole control system and distributes them to each terminal node according to the protocol.This project is based on ARM cortex-A9 development board. Embedded software development is implemented with Android system.

Fig.6 Function diagram of home gateway Fig.7 User access communication diagram

When the home gateway implements its function, it is actually playing the role of socket server and client,as shown in Fig.6.For SmartHome servers, it is the socket server side that listens and reads instructions from the home server.After the instruction is received and then used as the socket client, the instruction is selected according to the communication protocol of the terminal node, and is distributed to the terminal device through the ZigBee communication module, the WiFi communication module or the bluetooth.

Home gateways can receive access information from external networks and home lans,as shown in Fig.7.When users in the outdoor control of intelligent home equipment, first access to the

Advances in Engineering Research, volume 141

728

Page 6: SmartHome System Based on Containerization Technology

SmartHome server in cloud, the server commands through the home gateway forwarding to the terminal node, the terminal device response.The return value of the device completion operation is transmitted to the home server through the home gateway and is fed back to the user of the client,a remote control flow is completed;In home access, for some simple data access and send control command operation, the client's information is not through the server, but directly through the home gateway sent to the terminal node.This can split the task and reduce the pressure on the server.

5.2 . Communication between Home Gateway and ZigBee Coordinator The home server communicates with the home gateway via Socket,Socket is the intermediate

software abstraction layer of the application layer in the network and the communication of the TCP/IP protocol family,as a set of interfaces, the complex TCP/IP protocol family is hidden behind the Socket interface.For data that needs to be transmitted reliably, such as control instructions and request data, it is transmitted via SocketTCP.The data streams requiring high transmission efficiency, such as video surveillance data, are transmitted over the SocketUDP.

The data between the smart home gateway and the Zigbee coordinator are transparently transmitted through the socketTCP. The transport protocol table is shown in Table 1.

Table 1Transmission Protocol between Home Gateway and Zigbee Coordinator Header FrameType SensorType SensorNum SensorData END Value 0xFE 0xEF Bytes 1 1 1 1 4 1

In the process of data transmission, the transmit and receive frames are uniformly fixed, each with 9 bytes.

As shown in Table2.There are five main types of transport types: JOIN, REQUEST, REPLY, CONTROL, ACK.

When the terminal node joins the network, the JOIN frame is sent to the coordinator, and the coordinator sends the JOIN frame to the home gateway and then transmits it to the server.

When the server through the gateway sends a REQUEST frame to the coordinator, the coordinator of REQUEST frame is transmitted to the terminal node, terminal node to read sensor data, REPLY is sent to the coordinator, the coordinator will be sent to the server for processing REPLY frame.

When the server sends a CONTROL frame to the coordinator, the coordinator of CONTROL frame is transmitted to the terminal node, terminal node to execute the corresponding operation after ACK is sent to the coordinator, the coordinator of ACK frames sent to the server, and feedback to the user.

Table 2 Frame Type Specification Frame Type JOIN REQUEST REPLY CONTROL ACK Value 0x01 0x02 0x03 0x04 0x05

5.3Design of ZigBee Coordinator

The coordinator part equipped with CC2530 chip,which is a true System on chip using 2.4GHz and RF4MC.The protocol stack of Zigbee is Z-Stack, and the standard protocol is IEEE802.15.4.A RF transceiver is integrated into the CC2530, which has high sensitivity and strong anti-interference ability.An integrated 8051 microprocessor is integrated inside.CC2530 from the internal structure can be divided into three types of modules: CPU and memory module, peripherals and power management module, wireless module.The CPU and memory module are the core modules of the microprocessor, which ensure the realization of the basic functions of the chip.Peripheral and power management modules provide protection for micro processing, expansion, and normal operation. The wireless module provides an interface to the MCU so that the microprocessor can send commands, read its own state, automatically operate, and sort wireless events. The wireless device also includes a packet filtering and address identification module.

Advances in Engineering Research, volume 141

729

Page 7: SmartHome System Based on Containerization Technology

Fig. 8 Minimum system diagram of the CC2530 In the minimum system diagram of the CC2530,It mainly includes clock module and antenna

module. Since CC2530 is mainly used in wireless communication, it is necessary to filter in order to stabilize the signal. Therefore, most of the capacitors in the circuit diagram play the role of filtering.

6. Conclusion This paper starts with the architecture of SmartHome system, mainly introduces the intelligent

layer (home server), home gateway and ZigBee coordinator and the design of communication protocol. The intelligent layer uses the containerization technology to build the server cluster,realizes the "separation of brain and body" of the SmartHome system, and deploys the brain to the cloud,which provides a wide space for the intelligent realization of the system. OpenStack omits the underlying hardware differences and provides a unified computing, storage, and network resource. Packaged application environment, through the Docker container technology, so that the cluster can quickly deploy and expand, through scripting language can achieve automation of cluster management and maintenance.The Docker container technology guarantees the availability and robustness of the SmartHome server cluster.

References [1] ZHANG Zhong-lin,HUANG Bing-liang. The docker application based on openstack cloud platform[J]. SOFTWARE, 2014, 35(11): 73-76 [2] LIU Xi, HU Zhi-yong. Design and implementation of Web cluster based on Docker container[J]. Electronic Design Engineering, 2016, (8): 117-119 [3] GAO Li, GAO Xin. Research on the Application of Docker in Software Development Process[J]. Computer Engineering & Software, 2016, 37(3): 110-113 [4] Wu Jiaxing, Li Aiguo. The Smart Home System Based on Cloud Computing[J]. Computer Applications and Software, 2013, 30(7): 240-243 [5]ZhongYunjie, YangHoujun, FanYanbin. Design of cross platform Smarthome control system based on B/S architecture[J]. Industrial Control Computer, 2016, 29(12): 91-93

CC2530

Advances in Engineering Research, volume 141

730