484 Simulation Model of Information Interaction of Measuring Devices in an Automated Environmental Monitoring System Based on IoT Technologies* Evgenii I. Milenin 1 [0000-0003-1364-828X] and Viktor V. Sivov 1 [0000-0002-0541-8866] 1 ITMO University, Kronverkskiy prospekt, 49, St. Petersburg, 197101, Russia monser2002@gmail.com Abstract. The article considers a method for simulating information interaction in complex-structured and volumetric technical systems based on the Internet of things technologies. The features of the MQTT Protocol are considered, the to- pology of solutions operating based on the Internet of things technologies is de- scribed, and the architecture of IoT solutions is maximally decomposed into ex- isting interaction levels. The Agent-based model is used as the basis for the study of the simulation of information interaction, and AnyLogic software was used for the practical implementation of the task. Keywords: Modeling, Simulation, Model, Probability, Queries, Internet of Things, Distributed Networks, Monitoring, Network Topology, Ecology. 1 Introduction 1.1 Relevance Currently, much attention is paid to the problem of the ecological state of the environ- ment. In particular, an important aspect of a balanced environment is the conservation of water and soil resources, since they directly affect the entire ecosystem of the planet as a whole. Many federal laws and regulations require businesses to comply with a set of envi- ronmental practices when manufacturing. However, there is no developed monitoring system for the timely detection of violations and waste discharges that lead to the pol- lution of water and soil resources. Today, data on the ecological state of the hydrographic network is not stored in a structured way and is not filled with up-to-date information. Solving the problem of universal control of the environmental situation should stand alongside the most im- portant tasks of the scientific community. Thanks to modern technologies, it is possible to create a distributed network of devices that collect metric data at all key points of the * Copyright 2021 for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). 485 hydrographic network with minimal economic costs. To minimize the cost of creating such a system, it is important to make all the nec- essary calculations and simulate the operation of such a system, taking into account the specifics of its implementation and further application [1]. 1.2 Applied technology To solve this problem, we will turn to technologies that allow us to transmit metric data from devices located at a remote distance. These technologies include the MQTT (mes- sage queuing telemetry transport) Protocol [2]. This simplified network protocol works on top of TCP / IP and is focused on exchanging messages using the publisher-sub- scriber (pub/sub) template [3]. The Protocol is used for devices with low power and limited battery life. Thanks to it, you can organize data streaming between devices with limited CPU power and battery life, operating in conditions of low bandwidth, unpre- dictable stability, and high latency [4]. A communication system based on the MQTT Protocol must consist of a publisher server, a broker, and one or more clients [5]. Since the publisher server does not request additional add-ons for the number and location of subscribers and the subscriber does not need additional configuration for the pointing publisher, the system may consist of an infinite number of brokers that will distribute messages [6]. Because high-level clients receive each message, and low-level clients receive messages that relate exclusively to one or two base channels, the ex- change of information is facilitated by its size from 2 bytes to 256 megabytes [7]. In addition to a suitable communication Protocol, distributed devices must maintain Autonomous operation, which means that their power consumption must be organized through a stored battery and solar panels of sufficient power to maintain the required level of charge throughout the entire period of operation. 2 The topology of IoT solutions 2.1 Crucial information To solve this problem, you should delve into the level architecture of the IoT solution being developed in the most detailed way. The IoT topology differs significantly from the usual OSI layer model [8] since it is not linear and contains a complex flow graph. Some elements are optional and may be omitted from a certain class of solutions for many reasons. There are three types of logic in this type of network: M2M (machine to machine), M2P (machine to person), and C2C (car to car). Solutions based on IoT technologies have two physical locations – on the end pe- ripherals and in the data center with the possibility of location on a physical server or in cloud storage [9, 10]. Figure 1 schematically shows the levels, processes, and interaction objects that can be involved in the topology of IoT – based networks. 486 Fig. 1. Schematic representation of the network topology based on IoT technologies. 2.2 Levels in the architecture of IoT solutions Before you start simulating the information interaction of measuring devices, it is im- portant to define each level in the IoT solution architecture to understand the whole picture and not to miss important details when building models [11]. Physical Layer. At this level, there are two possible types of operations-collecting information from various types of sensors and actuators that perform mechanical oper- ations, such as opening the locks of the entrance doors, activating the engines, turning on and off the lights. Edge Layer. Used to provide the minimum functionality to convert analog infor- mation to digital and vice versa. Integration problems often arise at this level since a single standard for the data model for peripheral devices has not yet been developed. The main function of this level is to receive, transform, and store information that comes from sensors. Local Network Layer. The most energy-intensive part of the peripheral device op- eration is data transfer. This aspect is extremely important since most peripheral devices run on battery or alternative sources of electricity. At this level, protocols such as ZigBee, Zwave, BLE, LoRa, and Proprietary low band are involved. To increase the distance and reliability of communication, Ad Hoc and Mesh are used at this level. 487 Gateway Layer. This level exists due to the need to process information to save power and costs on the backend side, as well as to guarantee the response to requests from peripherals in real-time. Wide Network Layer. This layer allows you to separate the peripheral and backend parts of the overall solution. It contains communication services and ISO models, in- cludes and supports balancing and location services that are based on a DNS server, the COAP transport Protocol, DTLS encryption, and many other components. Security Layer. Provides key functions that are responsible for authentication, au- thorization, and connection tracking. Encrypts and decrypts data streams along with related services that are connected to the Internet. Middleware Layer. Allows you to provide internal load balancing functionality, and moderates the message queue and the order in which streaming information is transmitted. Components of this level are usually duplicated and require automatic scal- ing. This level works based on microservices or using the services of cloud providers. ETL layer. It collects data from all the peripheral devices involved in the system, converts the collected information to a standard form, and stores it for future use. It also includes such functions as archiving, data destruction, and informing related services about new data. Big Data and Analytic Layer. The data set and execution features depend directly on the features of a particular application. It is used as an analytical level, where artifi- cial intelligence and machine learning algorithms are usually implemented, depending on the tasks solved by the developed system. Notification layer. Any of the existing components at this level is the General algo- rithm of the notification upon subscription. The client subscribes to events that interest them, and when such an event occurs, the client receives a notification. Presentation Layer. It is used to process and provide information from an M2M stream and allows you to organize maintenance, configuration, and changes to the state of the system to the engineers who maintain it. Configuration Layer. It applies to all types of threads that were previously defined and works as storage that updates information about the state of peripherals. All changes to the operating status of peripherals are stored at this level. The communica- tion process at this level is shown in Figure 2. Fig. 2. Process of communication on the configuration layer. 3 Simulation of information interaction 3.1 Modeling as a process Modeling is a process that can result in creating a model that can display important key metrics that are used in the future to implement the system being developed. Modeling is a method of indirect practical or theoretical operation of an object, in which it is not 488 the object of interest itself that is studied, but a specially created auxiliary artificial or natural system. At the same time, it must be in certain objective accordance with the object being studied, it must be able to replace it at certain stages of cognition and give information about the object being modeled in the end. This distinctive feature is unique to the modeling process and distinguishes it from other methods of cognition [16]. For technical systems, modeling is the process of replacing an object of research with some of its models and conducting research on the model to obtain the necessary information about the object or system. A model is a physical or abstract image of a modeled object that is convenient for conducting research and allows the researcher to display the physical properties and characteristics of the object that are of interest to the researcher. The convenience of conducting research can be determined by various fac- tors: the ease and accessibility of obtaining information, shortening the time, and re- ducing the material costs of research [17]. Simulation of complex systems is not related to their analytical representation, but to the principles that are embedded in the simulation component using software and information tools in their most complex aspect-in the dynamic representation. The measuring device itself is an element of the simulation model that allows simulating the maintenance process. 3.2 Agent-based modeling of information interaction Implementation of simulation modeling in practice takes the following four paradigms as the main ones:  Discrete event modeling  Dynamic modeling  System dynamics  Agent-based model The agent-based model allows you to perform research that determines the behavior of decentralized agents and the behavior of the entire system as a whole, which is most relevant for a distributed system of devices that provide monitoring of the environmen- tal situation in the environment [18]. To implement the simulation, it was decided to use the AnyLogic software tool, whose functioning structure is shown in Figure 3. 489 Fig. 3. Process of communication on the configuration layer. The model shown in Figure 3 functions in such a way those incoming requests from peripherals are received in a chaotic order. If the validation and certification of the transceiver information are performed successfully at the first detection of the device in the network, the device identification data is added to the network map and further identified as a reliable privileged source. After the received information is processed and saved, the corresponding command is sent to the server, after which a receipt mark is made at the notification level. Figure 4 shows the configuration window in the AnyLogic software tool, which displays the operation of the simulated interaction sim- ulation process. Because of the simulation, the key problems and features of the proposed IoT net- work topology were calculated and discovered, as shown below: 1. Due to conflicts of data sources, agent requests for data transmission may be period- ically rejected, which is important to take into account in the architectural component of the system being developed. 2. It is possible to duplicate the same peripheral device in the same network map, which is solved by automatically deleting the device if no response is received from it within the specified period. 3. If the device finds it difficult to send the received data, which may result in a failure of the measuring device and, therefore, in the absence of data, the system will re- peatedly offer to perform this action until the command is executed, or if the maxi- mum number of attempts to be made is predetermined in the logic of the device. 4. When the request has completed the route, the information interaction is considered completed. 490 Fig. 4. The window for configuration of measuring devices and their interaction. 4 Conclusion The developed simulation model of information interaction, based on a multi-agent ap- proach for the network topology, organized based on IoT technologies for a distributed system of measuring devices, allows to determine the key parameters, the calculation of which is necessary for reliable and fault-tolerant operation [19, 20] of the entire net- work of devices with minimal losses in data collected [21 22], processed and received by the server. Having modeled and activated modes such as polling, interrupts, and, most im- portantly, multiple access, the work performed gives an idea of the number of parame- ters that should be given maximum attention in the further development of interaction algorithms at all active levels of The IoT network topology for the deployment of a complex of subsystems of a distributed environmental monitoring system. Among the defined parameters, the most obvious ones are the number of sensor devices, the format 491 of data transmission and packet, and the average time of data transmission in probabil- istic estimation under the conditions of potential collisions on each of the active net- work sections during data transmission. References 1. Haughian, Barry. Design, Launch, and Scale IoT Services. Apress, 2018, pp. 194-220. https://doi.org/10.1007/978-1-4842-3712-0 2. Su W., Chen W. and Chen C. An Extensible and Transparent Thing-to-Thing Security En- hancement for MQTT Protocol in IoT Environment. 2019 Global IoT Summit (GIoTS), Aarhus, Denmark, 2019, pp. 1-4. DOI: 10.1109/GIOTS.2019.8766412. 3. Lea, Perry. Internet of Things for Architects. Packt Publishing, 2018, pp. 410-422. 4. Guinard Dominique D., Trifa Vlad M. Using the Web to Build the IoT. Manning, 2016, pp. 144-161. 5. Tamboli, Anand. Build Your Own IoT Platform. Apress, Berkeley, CA, 2019, pp. 65-84. DOI: https://doi.org/10.1007/978-1-4842-4498-2 6. Hillar, Gaston C. Hands-On MQTT Programming with Python. Packt Publishing, 2018, pp. 92-113. 7. Sadio O., Ngom I. and Lishou C. Lightweight Security Scheme for MQTT/MQTT-SN Pro- tocol. 2019 Sixth International Conference on Internet of Things: Systems, Management and Security (IOTSMS), Granada, Spain, 2019, pp. 119-123. DOI: 10.1109/IOTSMS48152.2019.8939177. 8. Tantitharanukul N., Osathanunkul K., Hantrakul K., Pramokchon P. and Khoenkaw P. MQTT-Topics Management System for sharing of Open Data. 2017 International Confer- ence on Digital Arts, Media and Technology (ICDAMT), Chiang Mai, 2017, pp. 62-65. DOI: 10.1109/ICDAMT.2017.7904935. 9. Alqinsi P., Matheus Edward I. J., Ismail N. and Darmalaksana W. IoT-Based UPS Monitor- ing System Using MQTT Protocols. 2018 4th International Conference on Wireless and Telematics (ICWT), Nusa Dua, 2018, pp. 1-5. DOI: 10.1109/ICWT.2018.8527815. 10. Sadeq A. S., Hassan R., Al-rawi S. S., Jubair A. M. and Aman A. H. M. A Qos Approach For Internet Of Things (IoT) Environment Using MQTT Protocol. 2019 International Con- ference on Cybersecurity (ICoCSec), Negeri Sembilan, Malaysia, 2019, pp. 59-63. DOI: 10.1109/ICoCSec47621.2019.8971097. 11. Bogatyrev V. A., Bogatyrev S. V., Bogatyrev A. V. Model and Interaction Efciency of Com- puter Nodes Based on Transfer Reservation at Multipath Routing. 2019 Wave Electronics and its Application in Information and Telecommunication Systems (WECONF), Saint Pe- tersburg, 2019, pp. 1-4. DOI: 10.1109/WE-CONF.2019.8840647 12. Dow, Colin. Internet of Things Programming Projects. Packt Publishing, 2018, pp. 189-212. 13. Mesnil, Jeff. Mobile and Web Messaging. O’Reilly Media, Inc., 2014, pp 43-47. 14. Boyd, Bryan et al. Building Real-time Mobile Solutions with MQTT and IBM Mes- sageSight. IBM Redbooks, 2014, p.38. 15. Blokdyk, Gerard. MQTT: A Concise and Practical Tutorial. Paperback, 2017, pp. 25-32. 16. Novik, I. B. Filosofskie voprosy` modelirovaniya psixiki [Philosophical questions of mod- eling the psyche]. M.: Nauka, 1969. 174 p. 17. Tarasik, V. P. Matematicheskoe modelirovanie texnicheskix sistem. Uchebnik dlya vuzov [Mathematical modeling of technical systems. Textbook for universities]. Moscow: Nauka, 1997. 600 p. 492 18. Lychkina, N.N.: Innovatsionnye paradigmy imitatsionnogo modelirovaniya i ikh primenenie v upravlencheskom konsaltinge, logistike i strategicheskom menedzhmente [Innovative par- adigm of simulation and their application in management consulting, logistics and strategic management]. Logistics Supply Chain Manage. 5(58), 28–41 (2013). Pp. 28-41. 19. Bogatyrev A. V., Bogatyrev V. A., Bogatyrev S. V. Multipath Redundant Transmission with Packet Segmentation. 2019 Wave Electronics and its Application in Information and Tele- communication Systems (WECONF), Saint Petersburg, 2019, pp. 1-4. DOI: 10.1109/WECONF.2019.8840643 20. Bogatyrev V.A., Bogatyrev S.V., Derkach A.N. Timeliness of the Reserved Maintenance by Duplicated Computers of Heterogeneous Delay-Critical Stream. CEUR Workshop Proceed- ings, 2019, Vol. 2522, pp. 26-36. Available at: http://ceur-ws.org/Vol-2522/paper3.pdf (Ac- cessed 29 March 2020). 21. Bogatyrev V.A. Increasing the fault tolerance of a multi-trunk channel by means of inter- trunk packet forwarding. In: Automatic Control and Computer Sciences, 1999, 33(2), pp. 70-76. Allerton Press, Inc., New York. 22. Bogatyrev V. A., Bogatyrev S. V. and Bogatyrev A. V. Model and Interaction Efficiency of Computer Nodes Based on Transfer Reservation at Multipath Routing. 2019 Wave Elec- tronics and its Application in Information and Telecommunication Systems (WECONF), Saint Petersburg, 2019, pp. 1-4. DOI: 10.1109/WECONF.2019.8840647.