Keywords

1 Introduction

In recent years, the interconnection of Internet of Things (IoT) networks have received increasing interest from many academic and engineering fields. A hot topic is to Broadcasting and sharing of parameters in this kind of networks in a efficient way. So far, convenient and economical methods are very necessary. IoT networks has been considered as a new generation of networks that combine environmental sensing or temperature, humidity, \(CO_2\), adjustment of the environmental lights with data transmission and processing through wireless communication techniques or Wireless Sensor Networks (WSN) [1, 2], provide a better choice for broadcasting and sharing of parameters. Various sensors are attached in homes or wearable to acquire data containing physical or environmental states of these parameter. After sensor data collection, transmission, sharing processing and analyzing, structural problems such as adding new members in the network and communicate these parameters in a central way as a star configuration can be successfully predicted and adapted, so that the upcoming measurements caused by a conventional request may be answered [3, 4]. In addition, it is important to highlight that by 2020, The Internet of Things will have achieved critical mass. Linking enormous intelligence in the cloud to billions od mobile devices and having extremely inexpensive sensors and tag embedded in and on everything, will deliver enormous amount of new value to almost every human being. The full benefits, in terms of health, safety and convenience, will be enormous [4]. The perspective for this year, in this way will be 4 billion of connected people with a revenue of $4 Trillion USD because more than 25 millions of apps will be downloaded from the principal app-stores, thus we need approximately more than 25 billion MCU’s which will generate 50 trillion of Gigabytes of Data inside the global IoT network.

Furthermore, The increasing amount of IoT devises in a common or a conventional House, Fig. 1 shows a usual Floor Plan. In a IoT network contains a WiFi Access Point (WAP) that connect all the IoT devises to a Internet or Intranet networking as the main node. If a MCU want to share some parameters with another MCU, these MCU’s must communicate with the WAP. Even if they physically are very near each other if they do not have connection with the WAP they are not able to establish communication and sharing parameters.

Which is why in this paper, an effective method for broadcasting and sharing of parameters in WSN with Swarm Intelligence is proposed [5,6,7]. Here we use a large amount of networked sensors for realtime sensing and monitoring of different parameters in order to make efficient a IoT network and its application in a forthcoming Smart City. The further sections of this paper is organized as follows: General Description of the proposal is discussed in Sect. 2. In Sect. 3, a detailed description of Theoretical Framework is given describing Embedded Systems in the IoT network and Hilbert space-filling Curve. In Sect. 4, the description of the main scheme is given. In Sect. 5, simulation and performance comparison are presented to verify correctness and feasibility of the proposed scheme. Finally, some conclusions are drawn in Sect. 6.

2 General Description of the Proposal

This proposal is based in main work made by Beni and Wang [8] introduced the expression of Swarm Intelligence (SI) in their research of cellular robotic systems in 1993. The concept of SI is employed in work on Artifcial Intelligence (AI). SI is a computational intelligence technique which is based on the collective behavior of decentralized, self-organized systems. A typical SI system is made up of a group of simple agents which interact locally with each other and with the environment surrounding them. MCU’s in an SI system follow simple rules and act without the control of any centralized entities. However, the social interactions between such MCU’s may generate enormous benefits and often lead to a smart global behavior.

SI takes the full advantage of the swarm, therefore, it’s able to provide optimized solutions, which ensure high robustness, flexibility and low cost, for large-scale sophisticated problems without a centralized control entity.

Fig. 1.
figure 1

Floor Plan for exemplifying the proposed algorithm.

Which is why, this proposal is divided in 3 main parts based on SI:

  1. 1.

    Selecting the main or initial MCU,

  2. 2.

    Generation of the topology in a given Floor Plant, and

  3. 3.

    Indexing all the MCU’s inside the IoT network.

Henceforth, we use the Floor Plant depicted in Fig. 1, which consists of one WPA and several ESP8266 and RaspberryPi3, namely 64 embedded systems. In addition, in the first part the nearest MCU to the WPA is selected as the main MCU. Then, measuring the bandwidth in Mbps (mega bits per second) we can predict a general topology for a given Floor Plant, when a new MCU is added the algorithm recalculates a new topology. Ones the topology of the network is calculates every member of the IoT network is indexed by the Hilbert Fractal, then we measure the effectiveness of the methodology sharing parameter along the network and then Wi-Fi Peer-to-Peer (P2P) and SoftAP algorithms are configured.

3 Theoretical Framework

3.1 Embedded Systems in the IoT Network

NodeMCU ESP8266 embedded system depicted by Fig. 2(a) is a development card similar to Arduino, especially oriented to IoT. It is based on the System on Chip (SoC) ESP8266, a highly integrated chip, designed for the needs of a connected world. It integrates a powerful processor with 32 bit architecture (more powerful than the Arduino Due) and Wifi connectivity.

Fig. 2.
figure 2

Embedded systems in the IoT network (a) NodeMCU ESP8266 embedded system (MCU-ESP8266) and (b) Raspberry Pi 3 embedded system (MCU-RPi3)

For the development of applications you can choose between the Arduino and LUA languages. When working within the Arduino environment we can use a language we already know and make use of a simple IDE to use, in addition to making use of all the information about projects and libraries available on the Internet. The user community of Arduino is very active and supports platforms such as ESP8266. NodeMCU comes with a pre-installed firmware which allows us to work with the interpreted language LUA, sending commands through the serial port (CP2102). The NodeMCU and Wemos D1 mini cards are the most used platforms in IoT projects. It does not compete with Arduino, because they cover different objectives, it is even possible to program NodeMCU from the Arduino IDE. The NodeMCU card is specially designed to work in breadboard. It has an on-board voltage regulator that allows it to feed directly from the USB port. The input/output pins work at 3.3V. The CP2102 chip handles USB-Serial communication.

NodeMCU has the following technical specifications:

figure a

Raspberry Pi 3 embedded system is one the most advanced thin client solution of the brand so far, which is shown by Fig. 2(b). Since the first Raspberry, called Raspberry Pi Modelo B, was introduced in 2012, more than 8 million units have been sold. Then it had only 256 MB of RAM. The new versions have been adding improvements in their features, thus reaching the Raspberry 3 pi Model B (MCU-RPi3).

In this work we would like to talk to you about some of the features and advantages of the MCU-RPi3, in case you are looking for a thin client to work with. The Raspberry Pi 3 thin client includes a series of advantages and novelties compared to the previous model, the Raspberry Pi 2 Model B. Among them, it is worth mentioning some of its main features. First, it has a much faster and more powerful processor than the versions. It is an ARM Cortex A53 with 4 cores, 1.2 GHz and 64 bits. Its performance is at least 50% higher than version 2 of Raspberry. The new thin client of Raspberry fulfilled another of the wishes of its main clients: wireless Wifi connectivity and Bluetooth. The previous models could only be connected through an Ethernet cable or through wireless USB adapters, so this version makes things much easier. The MCU-RPi3 includes a Bluetooth 4.1 and an 802.11n wireless Wifi network card. For the rest, it should be said that the new model hardly changes the size and only adds some changes in the position of the LED lights. The MCU-RPi3 account, on the other hand, with the same features that already included version 2.1 GB of RAM, fourth USB ports, Ethernet and HDMI port, Micro SD, CSI camera, etc. It is also fully compatible with the Zero and 2 versions. The Raspberry brand recommends using it in schools or for general use. Other recommendations of the brand for integrated projects are the Pi Zero and the Model A +. One of the great advantages of the MCU-RPi3 is precisely its price. Many companies, schools and centers use thin clients to create a more secure structure, but it can be given all kinds of uses: from creating a mini mail server to a low-end FM station.

The full specs for the Raspberry Pi 3 include:

figure b

Wi-Fi Peer-to-Peer (P2P) and SoftAP allow easy, direct connection among Wi-Fi devices, anywhere. There is no need for an Access Point. Through negotiation, one device becomes the Group Owner and the other the client. Initiation of the connection is designed to be quick and easy. Implementation does not require addition of new hardware, allowing existing smxWiFi users to add them to their products with just a software update. Wi-Fi Peer-to-Peer is a protocol designed to replace the legacy ad-hoc protocol for interconnecting Wi-Fi devices. Improvements over ad-hoc include easier connection and the latest security, 802.11i. It was designed to satisfy the growing need for dynamic connections among groups of electronics. It allows OEMs to create products that can interoperate with each other and with common consumer devices, such as phones, tablets, cameras, and printers. As with any Wi-Fi device, the range is up to 200m, making connection convenient even when devices are not in immediate proximity to one another.

SoftAP gives a device limited Access Point capabilities. When combined with Wi-Fi P2P, it allows the device to be the Group Owner. Without it, a device can participate only as a client.

3.2 Hilbert Space-Filling Curve

The Hilbert curve is an iterated function that is represented by a parallel rewriting system, concretely a L-system L-system. In general, a L-system structure is a tuple of four elements:

  1. 1.

    Alphabet: the variables or symbols to be replaced.

  2. 2.

    Constants: set of symbols that remain fixed.

  3. 3.

    Axiom or initiator: the initial state of the system.

  4. 4.

    Production rules: how variables are replaced.

In order to describe the Hilbert curve alphabet let us denote the upper left, lower left, lower right, and upper right quadrants as \(\mathcal {W}\), \(\mathcal {X}\), \(\mathcal {Y}\) and \(\mathcal {Z}\), respectively, and the variables as \(\mathcal {U}\) (up, \(\mathcal {W} \rightarrow \mathcal {X} \rightarrow \mathcal {Y} \rightarrow \mathcal {Z}\)), \(\mathcal {L}\) (left, \(\mathcal {W} \rightarrow \mathcal {Z} \rightarrow \mathcal {Y} \rightarrow \mathcal {X}\)), \(\mathcal {R}\) (right, \(\mathcal {Z} \rightarrow \mathcal {W} \rightarrow \mathcal {X} \rightarrow \mathcal {Y}\)), and \(\mathcal {D}\) (down, \(\mathcal {X} \rightarrow \mathcal {W} \rightarrow \mathcal {Z} \rightarrow \mathcal {Y}\)). Where \(\rightarrow \) indicates a movement from a certain quadrant to another. Each variable represents not only a trajectory followed through the quadrants, but also a set of \(4^m\) transformed pixels in m level. The structure of our Hilbert Curve representation does not need fixed symbols, since it is just a linear indexing of pixels.

Fig. 3.
figure 3

First three levels of a Hilbert fractal curve. Axiom = \(\mathcal {U}\) employed for this work.

The original work by Hilbert [9] proposes an axiom with a \(\mathcal {D}\) trajectory, while we propose to start with an \(\mathcal {U}\) trajectory (Fig. 3). Our proposal is based on the most of the energy is concentrated in the nearest MCU, namely at the right or left. The first three levels of a Hilbert Curve are portrayed in left-to-right order by Fig. 3. In this way the production rules of the Hilbert Curve are defined by:

  • \(\mathcal {U}\) is changed by the string \(\mathcal {LUUR}\)

  • \(\mathcal {L}\) by \(\mathcal {ULLD}\)

  • \(\mathcal {R}\) by \(\mathcal {DRRU}\)

  • \(\mathcal {D}\) by \(\mathcal {RDDL}\).

In this way high order curves are recursively generated replacing each former level curve with the four later level curves. The Hilbert Curve has the property of remaining in an area as long as possible before moving to a neighboring spatial region. Hence, correlation between neighbor pixels is maximized, which is an important property in image compression processes. The higher the correlation at the preprocessing, the more efficient the data transmission.

4 Broadcasting and Sharing of Parameters in an IoT Network

4.1 Selecting the Main or Initial MCU

Our algorithm considers that the WPA is on random position inside the room, but with connection with at least one MCU in the IoT network. At the beginning all MCU’s try to be connected to the WPA, if they do not establish the connection, the WiFi Direct option is enabled. MCU’s that connect to the WPA disable the Direct WIFI mode until instructed otherwise. So, the WPA sets up with the broadcasting mode sending packages in order to measure the bandwidth of every member in the IoT network. Henceforth, we use a MCU Network Identifier (MNI), which contains the type of MCU, either MCU-ESP8266 or MCU-RPi3, and byte tag for identification inside the IoT network. For example a MNI=MCU-ESP8266-i refers a ESP8266, which was identified as the ith embedded system inside the room, no matter the type or characteristics of the MCU. Due to the material with which the room walls are made, connection is made to only with some MCU’s, in quantity, these must be less or equal than \(4^{n}\). Hence, The IoT network is made up of \(4^{n}\) elements, as much, that must be interconnected and it is defined by Eq. 1.

$$\begin{aligned} IoTe=\sum _{i=1}^{4^{n}}MCU_{i} \end{aligned}$$
(1)

where IoTe is the number of embedded systems in the network, i is index of the MCU Network Identifier, and n is the level of the Hilbert fractal, which is defined by the Eq. 2.

$$\begin{aligned} n=\left\lceil \log _{4} \left( IoTe \right) \right\rceil \end{aligned}$$
(2)

Which is why we can define the \(MCU_{i=1}\) as the nearest MCU connected with the WPA because it get the highest link speed of the IoTe links. So, \(MCU_{1}\) is indexed as the first node in the network.

4.2 Generation of the Topology in a Given Floor Plant

Ones \(MCU_{i=1}\) is identified as the main node in the IoT network. Hence, the IoTe embedded systems, \(MCU_{i=1}\) included, enable WiFi Direct mode and full a table with the bandwidth of the nodes are next to them, in order to generate a List of Reachable Nodes (LRN). Every MCU generates a particular LNR, then a the proposed IoT network can generate \(4^{n}\) LNR’s. In addition, every LRN\(_{i}\), contains the bandwidth of all \(MCU_{i}\), which it establish connection. In order to belong to the IoT network every \(MCU_{i}\) must connect to at least one link with other \(MCU_{i}\) LRN’s are shared and \(\sum _{i=1}^{4^{n}}MCU_{i}\) know the way to any node in the network, namely everyone knows the topology of the network. This second step has a paradigm neither optimized nor intelligent. So, it is important to employ some tools of SI to improve these initial results.

4.3 Indexing All the MCU’s Inside the IoT Network

Thus, each node has an initial index in the network which, for the time being, is not optimized. To optimize it, all the elements must be numbered according to the Hilbert fractal and the position where each node passes.

Fig. 4.
figure 4

(a) Matrix \(\theta \), (b) Matrix \(\mathcal {H}\), and (c) Vector \(\overrightarrow{\mathcal {H}}\)

figure c

A linear indexing is developed in order to identify the \(MCU_{i}\) matrix array into a vector. Let us define the Microcontroller Units matrix array as \(\mathcal {H}\) and the interleaved resultant vector as \(\overrightarrow{\mathcal {H}}\), being \(2^{n}\times 2^{n}\) be the size of \(\mathcal {H}\) and \(4^{n}\) the size of \(\overrightarrow{\mathcal {H}}\), where n is the Hilbert curve level. Algorithm 1 generates a Hilbert mapping matrix \(\theta \) with level n, expressing each curve as four consecutive indexes. The level n of \(\theta \) is acquired concatenating four different \(\theta \) transformations in the previous level \(n-1\). Algorithm 1 generates the Hilbert mapping matrix \(\theta \), where \(\overrightarrow{\beta }\) refers a 180\(^\circ \) rotation of \(\beta \) and \(\beta ^T\) is the linear algebraic transpose of \(\beta \). Figure 4 shows an example of the mapping matrix \(\theta \) at level \(n=3\). Thus, each \(MCU_{i}\) at \(\mathcal {H}_{\left( i,j\right) }\) is stored and ordered at \(\overrightarrow{\mathcal {H}}_{\theta _{\left( i,j\right) }}\), being \(\theta _{\left( i,j\right) }\) the location index of it into \(\overrightarrow{\mathcal {H}}\). In addition, Fig. 4(b) shows the position inside a room and the MNI of each \(MCU_{i}\), namely, the best way to communicate for \(MCU_{i}\) is the \(MCU_{i+1}\), giving as a result the increment of the bandwidth.

That is why the nodes i are consecutive and communicate with the node \(i + 1\). In the case that in the current topology there is no \(MCU_{i}\) in a certain position i, the index that is closest to \(i-1\) is searched and this \(MCU_{i}\) is considered as a No-Significant Node (NSN) otherwise it is considered as Significant Node or (SN). It is important to mention that the node \(MCU_{1}\) is always SN and it is the only one that establishes a connection with the WPA. In the case that this node \(MCU_{i + 1}\) is NSN, \(MCU_{i}\) searches a SN incrementing i until finding it. In order to know the significance of the IoT, we propose a String of Network Significance (SNS) with \(4^{n}\) bits or \(2^{2n-3}\)bytes; 0 for NSN and 1 for SN. The SNS is broadcasted to \(\sum _{i=1}^{4^{n}}MCU_{i}\) and it takes few nanoseconds. Every \(MCU_{i}\) measures or evaluates certain parameters such as temperature, humidity, \(CO_2\), adjustment of the environmental lights. To differentiate them, we propose a 1-byte marker that specifically indicates which parameter that a sensor measures or MS and its value in Celsius degrees or voltage, for instance. Table 1 shows some examples of parameters that a \(MCU_{i}\) can measures, also a 1-byte MS can indicate up to 256 parameters.

Table 1. Some examples of marker of sensor or MS.

Each parameter value that measures an \(MCU_{i}\) is represented by a two-byte long Marker, which is divided in three parts: Sign, Exponent \(\varepsilon \) and Mantissa \(\mu \) (Fig. 5).

The most significant bit of the marker is the sign of parameter, whether 0 for positive or 1 for negative. The ten least significant bits are employed for the allocation of \(\mu \), which is defined by [10] as:

$$\begin{aligned} \mu = \left\lfloor 2^{10}\left( \frac{Parameter}{2^{R - \varepsilon }}-1\right) + \frac{1}{2}\right\rfloor \end{aligned}$$
(3)

Equation (4) expresses how \(\varepsilon \) is obtained, which is stored at the 5 remaining bits of the marker

$$\begin{aligned} \varepsilon = R-\left\lceil \log _2 \left| Parameter \right| \right\rceil \end{aligned}$$
(4)

where R is the number of bits used to represent the highest value of a certain parameter, defined as

$$\begin{aligned} R= \left\lceil \log _2 \left[ \max \left\{ Parameter\right\} \right] \right\rceil . \end{aligned}$$
(5)
Fig. 5.
figure 5

Structure of the sensor marker or SM.

5 Experimental Results

In this section we extend the exposed in previous section. Also, we use the Floor Plant of the Fig. 1 and the following amount of MCU’s:

  • 46 MCU-ESP8266

  • 18 MCU-RPi3

It is important to note that we use a WPA to connect the IoT network to Internet as initial node with following features: Tenda N300 Wireless WIFI Router WI-FI Repeater Booster Extender 802.11 b/g/n RJ45 with 4 Ports at 300 Mbps.

Fig. 6.
figure 6

Experimental results: (a) estimation of link speed every member in the IoT network and (b) reachable Nodes for MCU-RPi3-7

From Fig. 1, Fig. 6(a) shows that the WPA is on the upper right corner. At the beginning all the MCU’s try to be connected to the WPA, if they do not establish the connection, the WiFi Direct option is enabled. MCU’s that connect to the WPA disable the Direct WIFI mode until instructed otherwise. So, the WPA sets up with the broadcasting mode sending packages in order to measure the bandwidth of every member in the IoT network. Henceforth, we use a MCU Network Identifier (MNI), which contains the type of MCU, either MCU-ESP8266 or MCU-RPi3, and byte tag for identification inside the IoT intranet. For example a MNI = MCU-ESP8266-8 refers a ESP8266, which was identified as the eighth embedded system inside the room, no matter the type or characteristics of the MCU. Due to the material with which the walls are made, connection is made to only seventeen MCU’s the speeds depicted in Table 2, we only show the first ten MCU connected to the WPA. Which is why we can define the MCU-ESP8266-1 as the nearest MCU connected with the WPA because it get a link speed of 199.37 Mbps and the furthest MCU is MCU-ESP8266-16 with 53.14 Mbps. MCU-ESP8266-1 is indexed as the first node in the network.

Table 2. Bandwidth (Mbps) of the first ten MCU’s inside the IoT network

Ones MCU-ESP8266-1 is identified as the main node or Node 1 in the IoT network, all the MCU’s, MCU-ESP8266-1 included, enable WiFi Direct mode and full a table with the bandwidth of the nodes are next to them, in order to generate a List of Reachable Nodes (LRN). Every MCU generates a particular LNR, for instance, Fig. 6(b) shows a visual representation of the MNI’s whom the MCU-RPi3-7 can connect. According to Fig. 1 our example generates 64 LNR’s.

In addition, Table 3 shows the LRN-7, i.e. the bandwidth of the nineteen MCU’s, which it establish connection the MCU-RPi3-7. As we can see MCU-ESP8266-6 and MCU-ESP8266-8 obtain the two highest bandwidth for Node 7, with 203.94 Mbps and 201.20 Mbps, respectively.

Table 3. Seventh list of reachable nodes or LRN\(_{7}\) generated by the MCU-RPi3-7.

In addition, Fig. 4(b) shows the position inside a room and the MNI of each \(MCU_{i}\), namely, the best way to communicate for \(MCU_{64}\) is the \(MCU_{9}\), increasing the bandwidth and so on. In addition, Fig. 7 shows a visual interpretation of the linear indexing making by means of a \(n=3\) Hilbert Fractal.

Fig. 7.
figure 7

Floor Plan for conventional house.

We perform one thousand requests from the farthest nodes, i.e. from \(MCU_{64}\) to \(MCU_{1}\) and from \(MCU_{8}\) to \(MCU_{57}\). On the average the link \(MCU_{64}\leftrightarrow MCU_{1}\) obtains a bandwidth of 194.69 Mbps and for the one \(MCU_{8}\leftrightarrow MCU_{57}\) 192.35 Mbps. In both in a central topology, we cannot connect neither \(MCU_{64}\leftrightarrow MCU_{1}\) nor \(MCU_{8}\leftrightarrow MCU_{57}\).

6 Conclusions

Reducing energy consumption is a compulsory objective in the design of any communication protocol for Wireless Sensor Networks. Most of this energy can be saved through member aggregation, given that most of the sensed information is redundant due to geographically collocated sensors. Therefore, efficient broadcasting scheme to consider sharing parameters have been proposed. However, they still suffer from the high communication cost and have not fully resolved the sharing parameters. We proposed a lightweight broadcasting algorithm in wireless sensor networks. From the performance analysis, we can confirm that the IoT network reconfiguration scheme improves both the network lifetime and efficient parameter information than the traditional schemes. Also, we obtain some parameters connected in a certain \(MCU_{i}\) of all the IoT network in microseconds, what meets the definition of real time definition. In addition, this proposal make use of Swarm Intelligence, since every \(MCU_{i}\) learns of the rest of the members of the IoT network and knows what happen even it is not physically connected to other member.