Improvement of Perception Layer Routing Protocol with Static Nodes in IoT-Based Microgrids

: Aiming at the problem of uneven clustering and the unreasonable energy consumption of LEACH protocol in the perception layer of IoT-based microgrids of static nodes; in this paper, we propose a stationary-node energy-based routing protocol (SERP). First, we select a dynamic cluster radius for clustering to meet the actual needs of the network during clustering. Then, to solve the problem that the number of cluster heads is difﬁcult to determine, a dynamic optimal cluster head ratio is adopted. The dynamic optimal cluster head ratio can be obtained by minimizing the total energy consumption of cluster formation and the stable transmission phase, which can improve the efﬁciency of network transmission. Finally, by setting the residual energy factor and distance factor to improve the calculation of the cluster head election threshold, the energy load of the network is more uniform, and the location of the cluster head is more reasonable. Compared with the LEACH protocol and the HEED protocol, the simulation results show that the SERP protocol can effectively prolong the lifetime of the whole network.


Introduction
The Internet of Things (IoT) is allowing organizations to cost-effectively implement smart grids, also known as microgrids. Through IoT-based energy technologies, companies could revolutionize the distribution of electricity around the world. Microgrids create smaller groups from the larger electrical utility grid, which provides greater control to organizations on how they use their energy supply. Through this ability to disconnect and operate on the grid or in island mode, organizations can make smarter use of their power. A microgrid can operate on islanded mode which refers to the ability of microgrid owners to improve resiliency when the grid is not supplying enough power [1,2]. Microgrid owners are able to produce their own power when needed.
An IoT-based microgrid as shown in Figure 1 gives organizations power-both literally and figuratively. With the installation of an IoT-based microgrid, owners are able to improve the efficiency of their energy consumption. In addition to giving owners the ability to generate their own energy, microgrids also reduce dependency on utilities by helping to reduce costs and avoid peak usage charges. The technology even has the ability to produce revenue should the microgrid produce a surplus of power, which could be sold to a utility.
Although IoTs are widely adopted for monitoring, their use for control and automation of plants and processes is still very limited. Key concerns hampering wider adoption are the reliability of communication and the stability and magnitude of its latency. Controllers in microgrids depend on the reliable and timely communication of relatively small data packets containing measurements and commands, generated frequently at the sensors and controller. Guaranteeing these properties is challenging in the large-scale, multihop scenarios that are often the main reason for a wireless approach. Moreover, staple applications for wireless control rely on battery-powered sensors, which places energy efficiency in the limelight as replacing batteries is often costly or impractical. In this respect, it is well-known that radio activity, both listening and transmitting, is the main source of energy consumption. To optimize the energy consumption and prolong the lifetime of the whole network, a stationary-node energy-based routing protocol is worthy of attention. The IoT [3][4][5] collects various bottom-level data through the perception layer, groups them into the network layer transmission center through the gateway, and finally summarizes them to the application terminal, providing a data guarantee for customers to analyze and operate the entire Internet of Things. The Internet of Things completes information acquisition and data transmission by relying on the perception layer network [6,7]. The perception layer [8], also known as the sensing layer, includes all IoT devices, sensors and actuators, as well as supporting short-distance communication techniques and information collaborative processing techniques. Sensors sense and collect data from objects, machines and people in the real world. The actuators execute operations based on the perceived data or the request from the user. At the same time, the self-organizing network technique and routing protocols [9][10][11] are the key objects of research on the perception layer, and efficient routing protocols can improve the efficiency of sensor node data fusion and the overall life cycle of the network. However, the method of randomly selecting cluster heads can easily give rise to problems such as uneven clustering and uncoordinated cluster sizes. The number of clusters required should vary depending on network sizes. All of these problems will affect the energy consumption of networks to different extents.
The random selection of cluster heads in the LEACH [12][13][14] protocol makes the network energy consumption more uniform, but its disadvantages are also very significant. Subsequently, a wide range of improved protocols for dealing with the disadvantages of LEACH were proposed. Younis et al. [15] proposed the HEED (Hybrid Energy-Efficient Distributed Clustering) protocol where primary and secondary parameters were designed. The primary parameter represents the probability that the node is selected as the cluster head in the real situation, and the secondary parameter is used as the measurement of the communication overhead of the nodes in the cluster, which introduces the average lowest power in the cluster as the evaluation value. The operation process of heed protocol is as follows. In the first step, each node determines the value of its own primary parameter; In the second step, first check whether the temporary cluster head is included in the adjacent nodes around each node. If so, this node will compare the value of the secondary parameter with the alternative adjacent node, and the node with the lowest value of the secondary parameter is determined as the cluster head. If not, the probability that this node is selected as the cluster head is calculated with reference to the main parameter value; If the above conditions are not consistent, repeat the above operations and start the next round of algorithm iterations at the same time. Although the HEED protocol also pays attention to the energy of nodes, the key operation part is the algorithm iteration, which will increase the overall complexity of the algorithm and increase the amount of algorithm calculation. In the process of research on traditional wireless sensor networks, the LEACH protocol stands out because of its energy efficiency and load balance. It was first proposed in the wireless sensor network and is also the one of the most classic clustering algorithms [16][17][18]. Many subsequent sensor network routing protocols are established on the basis of LEACH. Therefore, studying the LEACH protocol helps better understand the routing algorithm protocol in sensor networks, and lays the foundation for proposing better protocols in the future. The LEACH protocol has many disadvantages. Due to the static cluster head ratio and cluster radius setting and the uncertainty mechanism of randomly selecting cluster heads, the LEACH protocol lacks consideration of node location and remaining energy, resulting in poor network stability and life cycle. To address the problems of the LEACH protocol, the paper improves the LEACH protocol under the system model of static nodes, and proposes a Stationary-node Energy-based Routing Protocol (SERP).
This paper mainly discusses the Improvement of Perception Layer Routing Protocol with Static Nodes in IoT-Based Microgrids. This paper has four main sections: (1) In Section 1, we introduce the IoT-based microgrids, LEACH protocol and HEED protocol; (2) In Section 2, we analyze the main problems in LEACH protocol and propose solutions; (3) In Section 3, we introduce the system model of this paper and the improvement of LEACH protocol; (4) In Section 4, we summarize the conclusions of this paper.

Problem Analysis
As a hierarchical routing protocol, LEACH protocol further reduces energy consumption and prolongs the network life cycle compared with the flat routing protocol. However, its distribution and random selection characteristics have led to many problems that cannot be ignored. The following is a detailed description of the major problems of the LEACH protocol: (1) One of the important parameters in the LEACH protocol is the ratio p of cluster heads to the total number of nodes. The value of this parameter in the protocol is a constant set in advance. After the parameters are initialized, the value of p will not change. However, the static p value cannot adapt to the needs of the network under different conditions and operating periods. When the network operates to the later stage, the number of dead nodes increases, and an excessively large cluster head ratio p will cause an excessively larger number of cluster heads in the network. A large number of cluster heads not only reduces the network data transmission efficiency, but also accelerates the energy attenuation. Meanwhile, if the cluster head ratio p is set too small, the number of member nodes within the cluster will increase, thus resulting in the rapid death of cluster head nodes and jeopardizing the stability of the network topology. An excessively smaller number of cluster heads will increase the average distance between the member nodes and the cluster heads, thus leading to an increase in the network energy consumption. (2) The LEACH protocol establishes clusters through random selection of cluster heads.
However, this random mechanism does not take into account the differences in energy and location between nodes, resulting in unreasonable cluster heads. Under the random selection mechanism, the nodes far away from the base station and the nodes with excessively low remaining energy will be selected as cluster heads, which accelerates the death of nodes in some areas of the network and affects the overall stability of the network. (3) In the LEACH protocol, after the cluster heads are selected, the node will search for the cluster head with the smallest distance within the cluster radius and send a join request. However, the static cluster radius cannot meet the needs of nodes at different locations. In areas with high node density, an excessively larger cluster radius will cause more energy to be consumed to selected the most suitable cluster head during the establishment of clusters.
(4) The randomization mechanism used by LEACH in the cluster head selection stage does not consider the impact of node density on the network. Randomized cluster head selection will make it impossible for the number of cluster heads in the areas with higher node density to meet the real needs, while the number of cluster heads in the areas with lower node density exceeds the needs.
In response to Problem 1, the transformation of the static cluster head ratio p into a dynamic cluster head ratio P based on the lowest energy consumption calculation can make the number of network cluster heads more reasonable. In response to Problems 2 and 4 , multiple factors such as node residual energy and neighbor node density are employed to improve the cluster head selection threshold, so that the stability of the network topology can be maintained. In response to Problem 3, selecting a dynamic cluster radius for clustering can meet the actual needs of the network during clustering.

System Models
The nodes in the network are in fixed positions, and the network models and energy models are analyzed for modeling.

Network Models under Static Nodes
Based on the distributed network in the perception layer of the Internet of Things, a network model is established. The major characteristics are described as follows: (1) The nodes in the network are randomly deployed in the specified area, and the coordinate positions of all nodes can be derived through GPS and other methods; (2) The nodes in the network have no mobility and remain stationary; (3) The nodes in the network are consistent in physical and network properties, that is, the nodes are same in terms of energy reservation, communication capabilities etc; (4) After the nodes in the network are initialized, the system will neither continue to supply energy to them, nor provide any other resources. In other words, the energy is fixed.
Under the constraints of the above conditions, the IoT perception layer network model of static nodes established in the paper is shown in Figure 2: Figure 2 shows a schematic diagram of the network after a round of clustering. CH represents the cluster head, CM represents the member nodes in the cluster, and BS is the base station. At this time, the network has been divided into four clusters. The sensor nodes are randomly distributed within a certain network range during initialization. The cluster head CH receives the data transmitted by the member nodes CM within the cluster and performs data fusion. Then the cluster head transmits the packed data packets to the base station BS beyond the network range.

Energy Model under Static Nodes
In this paper, in consideration of the application scenarios of the routing protocol of the perception layer of the Internet of Things, the wireless communication energy consumption model as shown in Figure 3 was utilized: In this paper, a radio model was selected as the energy model: E = kd n , where E is the energy consumed, k is the number of bits of the data sent, d is the communication distance, and n is the exponent. The value of n is determined by the model fitting of the network. If the network model fits the multipath fading model in the channel model, then n = 4; otherwise, the network model fits the free space model in the channel model, and n = 2.
The energy E TX (m, d) consumed by a node to send information contains two parts: E AX (m, d) and E TPX (m).
where E AX refers to the energy consumption of the information sent by the node in the path; it can be seen that E AX is proportional to the square of the distance d, m is the size of the data packet sent by the node, the unit is bit, E is the energy consumption coefficient, and E PX represents the energy consumption of a unit of data in the node hardware, E TPX (m) refers to the energy consumption of data of m bits in the node hardware.
The energy consumption E RX (m) of receiving m bits of data is: where E RX is the energy consumption of the node receiving a unit of data.

Algorithm Improvement under Static Nodes
In this section, the cluster radius, cluster head ratio and cluster head selection threshold methods are improved on the basis of the disadvantages of the LEACH protocol.

Cluster Radius Formula
The cluster head connects to the nodes that communicate with the base station, with faster energy loss than that of the nodes within the cluster. The farther the cluster head is from the base station, the greater its energy consumption will be. Therefore, to reduce the overall energy consumption of the network, the number of those cluster heads in areas far away from the base station should be controlled as small as possible. At the same time, nodes need a larger cluster radius to select suitable cluster heads and send a joint request.
On the contrary, the number of cluster heads in the area closer to the base station should be larger, and the cluster radius of the node should be smaller. First, based on the principle of the minimum average energy consumption in the cluster, a dynamic cluster radius formula is derived.
The energy consumption in a cluster is chiefly composed of four aspects: E To − BS , the energy consumed by the cluster head for sending information to the base station, E To − BS ; E A , the energy consumed for data fusion; E To − Head , the total energy consumed by each node in the cluster for transmitting information to the cluster head; E R , the energy consumed by the cluster head for receiving the information transmitted by each node.
As a result, the energy consumed by the cluster head for sending information to the base station can be derived: where D i denotes the distance from the node i to the base station, R i denotes the cluster radius corresponding to the node i, and m denotes the size of the data packet. The energy consumed by the cluster head for fusing m bits of data is: where E DA is the energy consumed by fusing a unit bit of data.
where ρ represents the average density of nodes. In the proposed network model, the area where N nodes are distributed is a rectangle of M × M, and the average density ρ of randomly scattered nodes can be expressed as: on the other hand, the energy consumed by the cluster head for receiving the information transmitted by each node is: From the above, the total energy consumption E Cluster of the cluster is expressed as: Therefore, the average energy consumption E Node of nodes within the cluster can be obtained: According to Formula (9), the average energy consumption of the nodes within the cluster, if the average energy consumption of the nodes is to be minimized, the cluster radius should take the value:

Optimal Cluster Head Ratio
The cluster head ratio p in the LEACH protocol is an important parameter. Before the network is initialized, the value of p is already set in advance according to the network scale and other factors. When the LEACH protocol repeats the establishment of clusters in units of rounds, the cluster head ratio p always remains unchanged. However, each time the location of the base station, the scale of the network, and the deployment scenario will change, the value of p will be reconsidered. At the same time, during the operation of the network, the number of surviving nodes also changes . . . at all times. As the static cluster head ratio p is no longer suitable for these changes in the network, the paper aims to design a dynamic cluster head ratio p which varies with the number of surviving nodes. At the same time, the optimal number of cluster heads in the network can be calculated on the premise that the total energy consumption of the network is the lowest: (11) where N denotes the number of nodes in the network, the area where the nodes are distributed is a rectangle of M * M, ξ f s and ξ mp are the energy model parameters related to the LEACH protocol, and d 2 to BS is the square of the distance between the cluster head and the base station. Therefore, the optimal cluster head ratio p can be expressed as: It can be seen from Formula (12) that the improved value of p is correlated with N, the number of nodes in the network, and changes dynamically with N. In this way, the dynamically changing value of p can be more adapted to the changes in the network. d 2 toBS denotes the square of the distance from the base station to the cluster head. In the actual network operation, the distance between the base station and the cluster head has to be repeatedly calculated in each round, which will add to the algorithm complexity. However, in the paper, the expectation of the square of the distance from the base station to the node as the value of the parameter to reduce the computational complexity. Therefore, when a node in the network runs out of energy and loses its function, the system will mark such a node and update the value of the number of nodes, N, and calculate the new optimal cluster head ratio P value, and broadcast it to each node.

Formula for Cluster Head Selection Threshold
In the cluster establishment stage, T(s i ) calculated by the network according to the formula for the cluster head selection threshold and, a, the random number assigned, were compared to select a cluster head. As the positions of each node relative to the base station are different, the energy consumption of the communication with the base station will increase with the distance. Therefore, the factor of distance must be included in the cluster head selection threshold formula to reduce the probability of a node far from the base station being selected as a cluster head for decreasing the total network transmission distance. The paper introduces D f , the "distance factor", which represents the feedback of the node's position to the cluster head selection. The distance factor D f can be expressed as: In Formula (16), d max represents the farthest distance between a node in the entire network and the base station, d toBS (i) is the distance between the node i and the base station, and d min denotes the closest distance between a node in the entire network and the base station. In particular, when d max = d min , let D f = 0. On the other hand, in addition to the effects of node location on the selection of cluster heads, the differences of nodes in energy in each area of the network should also be taken into account in the selection of cluster heads. In the entire network, as the number of rounds increases, the energy stored in the nodes will gradually decrease. In particular, the nodes that have been selected as cluster heads consume more energy than nodes that have not been selected as cluster heads. To prevent such nodes with low residual energy from being repeatedly selected as cluster heads and early death of nodes in some areas of the network, the residual energy of the nodes should be regarded as one of the influencing factors of the cluster head selection threshold, and the average energy of other nodes should also be considered. Hence, the paper introduces the "energy factor" E f , which represents the feedback of the node's energy to the cluster head selection. The energy factor E f can be expressed as: Among them, E(i) is the residual energy of the node i, and E local (i) is the average energy in the node i cluster.
Based on the formula for the cluster head selection threshold in the LEACH protocol, the distance factor D f and energy factor E f are added for improvement, and the formula for the cluster head selection threshold in the SERP protocol for the perception layer of the Internet of Things with static nodes can be obtained: where p denotes the optimal cluster head ratio, r denotes the number of running rounds, and G denotes the set of nodes that have not been selected for cluster heads in the most recent 1/p round. ω 1 and ω 2 are adjustable parameters, indicating the weight of each parameter. By controlling the weight of each parameter, the clustering algorithm can be more inclined to a certain property, for example, the clustering algorithm is more inclined to energy, then W 2 may be set larger. In the paper, it is expected that the weight of the energy factor will be lower at the beginning of clustering, and then gradually increase, so let In summary, T(s i ) can be expressed as:

Description of Algorithm Flow
The SERP protocol algorithm is described as follows: First, initialize the parameters after completing the arrangement of sensor nodes and base station nodes. Then, calculate R i , the cluster radius of each node and ratio of cluster heads p, the optimal cluster head ratio according to Formulas (10) and (12). Determine T(s i ), the cluster head selection threshold for each node by the distance factor D f and the energy factor E f , select the cluster head by comparing it with a randomly generated random number within the range of 0-1, and update the G set. Then the cluster heads broadcast the information of the selected cluster heads, and the non-cluster head node searches for the nearest cluster head within its cluster radius R i to send a join request. After completing the stage of cluster establishment, proceed with the data transmission stage. The nodes within the cluster send data to the cluster head according to the time slots as scheduled by TDMA. The nodes may shut down themselves and sleep while waiting for the time slot. Complete the algorithm operation if the energy of all the nodes within the system area is depleted or the number of running rounds reaches the maximum after completing the data transmission stage. Otherwise, continue to start a new round of cluster establishment from the calculation of the cluster radius and other parameters. The algorithm flow chart of the SERP protocol is shown in Figure 4.

Algorithm Simulation and Analysis
To accurately evaluate the performance of the proposed SERP protocol and verify its effectiveness in reducing energy consumption and prolonging the network life cycle in a static-node IoT perception layer network, a simulation experiment is conducted. A simulation environment is set up with the MATLAB tools, and simulation parameters are set by referring to [1,2]. Compared with the LEACH protocol, the main parameters of simulation are shown in Table 1.
It is impossible for the normal network to maintain its normal functions when there are too few surviving nodes. In the paper, simulation will be terminated when the percentage of dead nodes exceeds 95%, so that the performance of various routing protocols can be more effectively compared.
In the paper, the LEACH protocol, HEED protocol and the proposed SERP protocol are selected, compared and analyzed in terms of performance from the total network energy consumption, the network life cycle and total data throughput, respectively. To eliminate the contingency of the simulation results, the number of nodes is set to N = 100 and N = 300, respectively, to compare the performance of routing protocols under different network scales. It can be seen from Figures 5 and 6 that the energy consumption rate of nodes in the SERP protocol is slower than that in either the LEACH protocol or the HEED protocol, and the round of energy depletion also emerges later. With the increase of the number of running rounds, some nodes begin to die, and the increase rate of the total energy consumption of the three protocols gradually slows down until all nodes die to a maximum. When the number of nodes n increases from 100 to 300, the node energy consumption rate under LEACH protocol becomes significantly faster. In contrast, the node energy of heed protocol and SERP protocol can maintain a stable increase. At the same time, the total energy consumption of nodes under SERP protocol remains the lowest and the total number of running rounds is the largest. This shows that the SERP protocol can still maintain stable energy loss in large-scale node networks. This indicates that the improvement of the cluster head selection threshold is achieved through the distance factor and energy factor.  From Figures 7 and 8, it can be seen that compared with the LEACH protocol, the SERP protocol has a slower rate of node death, and requires a larger number of rounds before 95% of nodes die, which effectively prolongs the network life cycle and improves slightly compared with the HEED protocol. At the same time, when the number of network nodes N increases, in the LEACH protocol, nodes die in the 300th-400th rounds, indicating that the LEACH protocol is not stable enough for larger networks. As a direct result, LEACH protocol has lost most nodes when it runs to half of the total number of running rounds. Instead, the SERP protocol can still maintain a low rate of node death, which demonstrates that it has a network stability than the LEACH protocol.  From Figures 9 and 10, the total data throughput of the network can be observed. Although the LEACH protocol has a high data throughput rate at the beginning, its nodes die faster, thus significantly reducing the throughput rate when the number of dead nodes reaches a certain level. At the same time, when the number of network nodes n increases, the number of stable transmission rounds of LEACH protocol does not increase significantly, indicating that LEACH protocol has a bottleneck in data transmission in a large-scale node network. The SERP protocol can always maintain a relatively stable rate for data transmission and has a higher final total data throughput than both the LEACH and HEED protocols due to its longer life cycle.  Hence, the proposed SERP protocol has the characteristics of low energy consumption, long network life cycle, stable data transmission, and high throughput.

Conclusions
This paper analyzes the problems of the LEACH protocol in IoT-based microgrids, and improves the LEACH protocol from three aspects.Firstly, the dynamic cluster radius is selected to meet the actual needs of the network in the process of cluster establishment. Secondly, the optimal cluster head ratio is used to make the number of network cluster heads more reasonable. Finally, the distance factor and energy factor are used to improve the cluster head selection threshold. Then, this paper compares the LEACH protocol and heed protocol through simulation. The results show that the improved SERP protocol has a good performance in terms of total network energy consumption, network life cycle and total data throughput, and can still maintain good performance in a larger network.

Conflicts of Interest:
The authors declare no conflict of interest.