An Energy Efficient Clustering Algorithm in Wireless Sensor Networks for Internet of Things Applications

Internet of things (IoT) integrates sensor, radio frequency identification, network and cloud computing technology into a large-scale monitoring area. Wireless sensor network (WSN), as the most suitable infrastructure for the Internet of Things, how to reduce its energy consumption has been a research hotspot. In hierarchical networks, cluster head nodes need to take on more energy consumption tasks. Therefore, reasonable cluster head selection scheme and normal node joining cluster mechanism become particularly important. This paper proposes a new clustering method to save energy and prolong network life. Firstly, in the cluster head selection phase, the influence of energy threshold, residual energy, node density and communication factor is considered. Secondly, in the ordinary node joining cluster phase, the residual energy and distance factor are considered to form the non-uniform cluster set of the network. Simulation results show that the algorithm has good performance in reducing and balancing energy consumption.


Introduction
In recent years, the Internet is developing rapidly towards the combination of sensors and devices, known as IoT system.WSNs are the most powerful networking infrastructure that monitors an IoT system [1].As one of the core supporting technologies in IoT system, as well as the powerful routing and network foundation of IoT, WSN plays an increasingly important role in IoT.WSN collect largescale monitoring area data through scattered nodes, which are used in smart home, military monitoring, space exploration, environmental monitoring and other IoT applications. In addition, due to the limited energy and self-organization of sensor nodes, WSN enables IoT to meet the challenges of adaptability and energy saving.
WSN is an information transmission network consists of a large number of sensor nodes in selforganization and multi-hop mode. A single sensor node can sense, measure and collect environmental information according to the local predefined decision-making process, and then relay it to the data center for further analysis and processing through the base station(BS).The environment of WSN is usually complex and harsh, which results in many limitations, such as processing constraints, low memory, security and limited energy [2].Network lifetime is dependent on the energy stored at the nodes [3].Therefore, how to reduce node energy consumption and improve network lifetime has always been the research focus and hotspot in WSN.
Researches on energy saving in WSN leads to classification in clustering techniques [4]. Clustering algorithm has always been a hot research area, because it can balance network consumption to each node. Data transmission and reception occupy the main part of energy consumption. In direct transmission, sensor nodes directly transmit the collected information to BS, which will lead to the nodes far away from BS to consume lots of energy and die too fast, thus sharply shortening the network life. Clustering technology reduces the amount and distance of data transmission by selecting the cluster head(CH). The member nodes in the cluster(CM) only need to send collected data to CH, which greatly reduces the transmission distance and saves the energy of a single node. Clustering technology divides WSN into multiple clusters, so that the entire network has a clear hierarchy and the nodes have a clear division of labor, reducing node energy consumption and balancing the network, thereby extending the entire network life cycle.
In reference [5], several works on clustering are introduced. Low energy adaptive cluster hierarchical(LEACH) [6] algorithm is one of the well-known clustering algorithms, and it is also a classic protocol in hierarchical routing protocol. However, it does not consider other factors, cluster head needs to undertake more tasks such as data receiving, fusion and transmission. Therefore, reasonable cluster head selection scheme and node joining cluster mechanism become particularly important. In this paper, an novel clustering algorithm is proposed to improve the cluster head selection and node joining cluster strategy to reach the purpose of reducing and balancing energy consumption.
The rest of this paper is: section 2 reviews the clustering work in WSN and IoT applications, section 3 describes the network model, section 4 presents the proposed algorithm, section 5 show the simulation parameters and results analysis, and conclusion is presented in section 6.

Related Work
The number and position of CH are unstable due to the random cluster head selection mechanism of LEACH. Many scholars have made different improvements to it. This section will discuss the research work on clustering algorithm in WSN.
In 2011, Dasgupta et al. [7] proposed a new CH selection method, which embedded FCM algorithm according to the requirements of minimum distance and maximum residual energy. In 2018, M. Razzaq et al. [8] proposed a k-mean clustering algorithm, which determines whether a node becomes CH by two weight functions. In addition, in order to ensure flexibility, the optimal packet size is also taken into account. In 2015, Arumugam et al. [9] proposed an energy routing protocol considering the integration of data and the selection of the optimal CH. However, it only selects nodes with high residual energy and ignores any other factor. In 2017, shokrollahi et al. [10] proposed an energy-saving clustering algorithm, which combines FCM with ECAFG to optimize the selection process of CH from three aspects: residual energy, distance from node to cluster center and BS. In 2018, Elshrkawey et al. [11] proposed a CH selection algorithm. In the selection process, pay attention to the remaining energy of the node and the distance from the sink. In addition, CH only sends broadcast messages to the nearby radius to avoid a surge in long-distance energy consumption. In 2016, Murali [12] proposed a novel clustering method. Considering the relationship of communication and cooperation between nodes, the results illustrate that compared with no cooperation, energy consumption is lower when there is cooperation. However, the traffic consumption will increase as the network size increases. In 2017, K. Jung et al. [13] proposed a cluster head selection algorithm based on fuzzy logic, which took battery power, node density and data transmission frequency as consideration parameters. In 2019, Payam et al. [14] proposed a load balancing algorithm that can intelligently change to spread node energy consumption. The fuzzy logic controller forms a priority queue according to the input three parameters to allocate CH among nodes.

Network Topology Model
The clustering protocols generally generally have two phases: clustering phase and stable transmission phase, as shown in Fig. 1, after which the CH communicates with the BS. In LEACH protocol, all CH communicate directly with BS in single-hop mode. Many scholars have studied multi-hop transmission mode. Single-hop mode is is straightforward and easy to execute. However, once the distance is too large, energy consumption will increase sharply, nodes will die too fast, and network cycle will be greatly shortened. Multi-hop mode divides long-distance transmission into short-distance transmission, and the energy consumption is distributed to each CH, which can reduce energy consumption and balance energy consumption, but also increase the energy consumption and delay of data forwarding, which is not suitable for real-time network. In this paper, we adopt a single-hop and multi-hop inter-cluster transmission strategy. The network topology of clustering and inter-cluster transmission is shown in Fig. 2 and Fig. 3.     Figure 3, cluster head E is the leader CH, which is responsible for communication with BS or Sink. Other CHs send data to leader CH in the form of single hop or multi hops. For example, cluster heads A and B are transmitted to leader CH through multi-hop mode, while D communicates with E directly through single hop. In this way, a routing tree with the leader CH as the root is formed to balance the network energy consumption to each CH, thus prolonging the network lifetime.

Network Energy Consumption Model
We adopt the energy consumption model of wireless communication in reference [6]. As shown in Fig. 4, the sensor communication module has a transmitting device and a receiving device. In this model, the transmitter sends bits data from a distance of , and the corresponding energy l d consumption of the transmitter satisfies the following formula: The energy required by the receiver is:

Optimal Cluster Head Probability
The CH selection mechanism of LEACH protocol is directly related to the proportion of CHs in the network, so determining the CH ratio has a direct impact on the network power consumption. In this paper, we assume that homogeneous nodes are randomly distributed in network, the Assuming that the CH is in the center of the cluster, the node density is , the mean k M y x 2 1 ) , (   of the distance between the CM and the CH is obtained as follows: Incorporating formula (5) into formula (4) can obtain the total energy consumption of CMs: Step 2. On average, each normal CH receives the data of one CH and members, and ) ( 1 k N  sends its own data and received data to the next CH. The energy consumption is as follows:  (8) represents the minimum energy required for the normal CH to work. If it is less than this value, it will die due to insufficient energy. Therefore, is the minimum standard for a NRM _ CH E node to act as an ordinary CH, that is, the energy threshold of a normal CH, which is denoted as : Step 3. The difference between leader CH and normal CH is that the data needs to be sent to the remote BS or Sink.
Step 4. According to formula (9) and (10), the total energy consumption of all CHs is as follows: Step 5. The total energy consumption of each round can be obtained from equations (6) and (11): Step 6. Calculate the partial derivative of equation (12) to obtain the optimal number of CHs: Therefore, the optimal CH ratio is:

Clustering Phase
The LEACH protocol CH selection mechanism is: in each round, The random number generated by node compares with the threshold in equation (15). If the value is less than the threshold, it becomes the CH, otherwise it is a CM.
represents the proportion of CH in the network, is the current rounds, represents the i-th node. is a set that nodes haven't become CH.

G
In this paper, the steps to improve the clustering stage are as follows: Step 1. From equation (14), we can see that is the optimal CH ratio, and the normal CH of the network. If the residual energy of node is below the threshold, resulting in less than 0 i i p and then less than 0, the node can not be selected as CH. Therefore, formula (17) can not only i T improve the probability of high-energy nodes being selected as CHs, but also effectively protect lowenergy nodes.
Step 2. Consider the density of nodes around node . i

i R
Step 3. node randomly generates a random number between 0 and 1. If the number is below i than the threshold of equation (17), the node becomes the temporary CH and immediately broadcasts the elected message to the whole network. The non CH node select the cluster with the smallest c d to join according to formula (18). between clusters, CH near leader CH has a large amount of tasks to converge and forward data, which leads to increased energy consumption and forms a problem of energy consumption hot spots; while the CH far away from the leader CH has a lighter task. The energy consumption is relatively small. Therefore, let non-cluster-head nodes choose the CH that is closer to themselves, have more remaining energy, and are far from the leader CH to join, so that clusters closer to the leader CH have less CM, which reduces the energy consumption of intra-cluster communication. The clusters farther from the leader CH have more CMs, forming a non-uniform network cluster, effectively disperses the energy consumption of the whole network.
Step 4. Establish the formal cluster head. is defined as the i-th cluster, is the  8 cluster, so that the node with more energy and the lowest communication cost becomes the final CH.

Stable Transmission Phase
After the clustering phase is completed, each CM sends data to CH in its own slot according to TDMA time slot table. CH collects data packets from all sensor nodes in the cluster, and merges the collected data, then transmits them to the leader CH through a combination of single and multiple hop way. Finally, leader CH sends data to BS or Sink.

Simulation Results and Analysis
In this section, we use MATLAB R2019b for simulation and verify the superiority of the proposed algorithm based on the results. The experimental parameters are shown in Fig. 5.

Figure 5. Experimental parameters
We consider four parameters to measure the performance of the protocol, namely network life (rounds of network operation), the rounds when the first node dies (FND), the rounds at half node death (HND), and the rounds when the last node dies (LND).We analyze the proposed algorithm and LEACH according to the above parameters, so as to prove the feasibility of the improved algorithm.  Figure 6. Alive nodes per round Figure 6 shows the changes between the number of alive nodes and the rounds. It is obvious that the life cycle of the improved protocol is significantly longer than that of the LEACH protocol. From the beginning of the network operation to the FND, this stage is called the stable period of network operation. The stable period of the improved protocol is significantly longer than LEACH. In addition, the slope of the improved algorithm curve is significantly smaller than LEACH, which is due to the energy consumption balance of the new clustering algorithm, so that after FND, network nodes will not die sharply in short rounds. It can be seen that the improved protocol has better stability and more balanced energy consumption, which can effectively extend the network life cycle.  Figure 7 shows the comparison between the improved protocol and LEACH's FND, HND, and LND. For LEACH, FND is 401 rounds, and no node survived after the 1028th round, while the improved protocol, FND is 1081 rounds, and the LND is 2935 rounds.

Conclusion
In this paper, we propose a new clustering algorithm to disperse energy consumption and extend network life. First, in the cluster head selection stage, consider the impact of energy threshold, residual energy, node density, and communication factors. Second, in the clustering stage of ordinary nodes, consider the remaining energy and distance factors to form a non-uniform network cluster structure to balance energy consumption. We compare and analyze the two protocol from network lifetime, FND, HND and LND aspects. The results indicate that the improved protocol is superior to LEACH and has good performance.