Energy Efficient Routing-Based Clustering Protocol Using Computational Intelligence Algorithms in Sensor-Based IoT

Background: The main limitation of wireless IoT sensor-based networks is their energy resource, which cannot be charged or replaced because, in most applications, these sensors are usually applied in places where they are not accessible or rechargeable. Objective: The present article's main objective is to assist in improving energy consumption in the sensorbased IoT network and thus increase the network’s lifetime. Cluster heads are used to send data to the base station. Methods: In the present paper, the type-1 fuzzy algorithm is employed to select cluster heads, and the type-2 fuzzy algorithm is used for routing between cluster heads to the base station. After selecting the cluster head using the type-1 fuzzy algorithm, the normal nodes become the members of the cluster heads and send their data to the cluster head, and then the cluster heads transfer the collected data to the main station through the path which has been determined by the type-2 fuzzy algorithm. Results: The proposed algorithm was implemented using MATLAB simulator and compared with LEACH, DEC, and DEEC protocols. The simulation results suggest that the proposed protocol among the mentioned algorithms increases the network’s lifetime in homogeneous and heterogeneous environments. Conclusion: Due to the energy limitation in sensor-based IoT networks and the impossibility of recharging the sensors in most applications, the use of computational intelligence techniques in the design and implementation of these algorithms considerably contributes to the reduction of energy consumption and ultimately the increase in network’s lifetime.


1-Introduction
The Internet of Things (IoT) is one of the technologies of the present era that bridges the gap between the physical and virtual worlds. In the wireless sensor-based IoT network, numerous large-scale sensor nodes are deployed, which leads to an increase in complexity [1]. These networks have an extensive range of applications such as disaster management, environmental monitoring, health care, identification and investigation of the subject of defense, etc. In these networks, after placing the sensors in the environment, all sensors collect data from the environment and then process and transfer the data to the base station [2]. Normally, the energy of the power supply of sensors is limited, irreplaceable, and rechargeable; for this reason, energy has become one of the most important factors in these networks. Hence, the reduction of energy consumption in sensors has increased the network's lifetime, which has caused these networks to be one of the interesting research subjects among researchers. There are many approaches and techniques to reduce energy consumption in these networks, one of which is the topology control that increases the system's efficiency and reduces energy consumption [3] [4]. Clustering and routing are of the most effective techniques in controlling the topology control. Clustering in sensor-based IoT networks has advantages, including scalability, energy consumption, and reduction of data transmission latency in routing, Moreover, in clustering, the energy consumption is balanced between the sensors, which will increase the network's life.
In clustering, first numerous sensors are selected as cluster heads, which is usually performed randomly for the first time, and then normal sensors (nodes) become the members of these cluster heads, and the sensors send their collected data from the environment to their cluster head, and the cluster head sends the collected and aggregated data in a single-hop manner (each cluster head separately) to the base station. However, in more optimal routing methods, the shortest path from the cluster heads to the base station is created, which reduces the energy loss of the cluster heads. See Figure (1) [5] [5]. Fig.1. A clustered wireless sensor-based IoT network. [5] Clustering leads to the local formation of the path within the cluster; hence, the size of the routing table of each node is reduced, and the scalability in the network is enhanced. Clustering saves the communication bandwidth and intra-cluster communications and reduces the redundancy resulted from message exchange between sensors. Moreover, the sensors are only involved in connection with their cluster heads and are not affected by changes in the levels between cluster heads. As a result, the maintenance overload of the network topology is reduced [7] [8]. In addition to clustering algorithms, proper routing algorithms play an effective role in reducing energy consumption and, consequently, increasing the network's lifetime. Designing routing algorithms in sensor-based IoT networks is challenging since the network energy limitations must also be considered during design. In general, routing is the way of sending the data packet from source to destination. Network routing protocols are divided into two types: 1) Flat routing method, 2) Hierarchical, or classified routing method [4], [7], [9]. In flat routing, all nodes (sensors) have similar roles, and features, and data transmission is outspread in the network similar to the flood flow. The flat routing method is somewhat appropriate in relatively small networks, but in large networks, data processing, and high bandwidth are needed due to a large amount of collected data in the sensors, limiting the application of flat routing. In hierarchical routing, the data collected in each cluster head is transferred to the upper cluster head, and this process continues until data to be sent to the base station, which results in scalability, shorter data transmission distance, lower energy consumption, and also lower load. In the present article, a new routing and clustering energyaware algorithm using computational intelligence techniques called RCECI was presented for wireless sensor-based IoT networks. In the proposed method, the cluster heads at the base station and the path from the cluster heads to the base station are selected using the computational intelligence technique, and this data is sent to all nodes in the network. All normal nodes become the members of the existing cluster heads and are then organized, and after the data is collected by the sensors and sent to the cluster heads, the collected data is transferred to the base station through the path specified by the computational intelligence algorithms. Finally, some experiments are performed on the proposed algorithm (RCECI), and the results are compared with LEACH, DCE, DEEC, and SEP algorithms. The results indicate the efficiency of the proposed algorithm in energy consumption, network coverage, and the number of data packets sent to the base station. The structure of the article is as follows. A review of some related works is discussed in Section 2. The proposed algorithm is described in Section 3. The experimental results are presented and compared with other algorithms in Section 4, and the conclusions are given in Section 5.

2-Previous Works
Numerous routing and clustering algorithms have been developed for wireless sensor-based IoT networks; the LEACH algorithm is one of the most important and basic [10] [11]. The clustering operation in LEACH is performed randomly. Cluster heads are replaced in each round. Every single round is divided into two phases: the setup phase to select the cluster head and the steady-state phase to send data. The setup phase includes selecting the cluster head node, declaring the cluster head to the entire network, and joining normal nodes to the cluster head. The cluster heads are randomly selected at the start of the LEACH algorithm. The selection rule is that each sensor randomly generates a number 0 or 1. If these numbers are less than the threshold, the sensor is considered as a cluster head. A formula for the threshold limit T(n) is indicated in Equation (1). (1) Where, p implies the expected percentage of cluster head nodes in the sensor population. R denotes the current phase number. G is referred to as a group of nodes that have not been converted to cluster head nodes in the last 1/p step. LEACH's main disadvantage is that the sensor node with considerably low energy is probable to be selected as the cluster head, and the cluster heads send the data directly to the base station in a single-hop communication. Hence, this method increases the energy consumption of the cluster head [12] [13]. The Stable Election Protocol (SEP) [14][5] and Distributed Energy-Efficient Clustering (DEEC) [15][5] algorithms have been specifically designed for heterogeneous networks. SEP is aimed to prolong the stability period of two-level heterogeneous networks and includes two types of nodes based on initial energy: normal nodes and advanced nodes. Also, SEP operates similarly to LEACH; however, the rotation round of the cluster heads and the probability of their selection as the cluster head is directly related to the initial energy of the nodes. Nevertheless, SEP does not consider the remaining energy of the sensors for a multilevel heterogeneous network. Contrary to SEP, DEEC considers the sensor's initial energy and remaining energy in selecting the cluster head, which improves the network's lifetime. DEEC shows better performance than LEACH and SEP in multilevel heterogeneous networks. In DEEC, the central station is assumed to be at the center of the network; therefore, this method cannot be applied if it is extremely far from the sensor nodes. Besides, although cluster head selection is improved by changing the probability function and can guarantee that sensors with relatively high remaining energy and initial energy are more probable to become cluster heads, low-energy sensors still have a good chance of becoming cluster heads [5]. The DCE algorithm for heterogeneous networks is on the basis of two-phase cluster head selection. In DCE [5], the cluster head is selected in two phases. In the first phase, the test cluster heads are picked according to the initial energy and the remaining energy of the sensors. In the second phase, if the test cluster heads have lower energy than one of the cluster members, they are replaced with them to determine the final cluster head. The use of two phases in cluster head selection ensures that nodes with higher energy have a better chance of becoming cluster heads. Moreover, this algorithm does not consider some parameters such as density and centrality in the selection of cluster heads and select the cluster heads based on the initial energy and remaining energy. The EECA 1 algorithm [2]: The node's residual energy, distance and data overhead have been used in selecting the cluster head in the EECA method. Clustering in this method is done in two steps; in the first stage, clustering is done according to energy and distance, and in the second stage, clusters are optimized using the K-means clustering 1. Energy Efficient Clustering Algorithm for Wireless Sensor Networks algorithm. The information is sent to the base station, after collecting the data and aggregating it by the headers.

3-Proposed Method
The assumptions considered in the proposed method are as follows: -The simulation is performed in several scenarios; the sensors' energy is either homogeneous or heterogeneous depending on the scenario. In the homogeneous scenario, all nodes' energy is equal to 0.5 J, and when the environment is heterogeneous, the energy of half of the sensors equals 1 J. -All sensor nodes are placed randomly and uniformly, and the sensors are aware of neighboring nodes and their positions, as well as the base station's position. -The base station can be in different positions and also movable or fixed depending on various scenarios. -According to the scenario, the sensors may not be fixed, and their position may change. Nodes' instability does not mean relocating the sensors by remote control but only involves ground displacements including displacements or erosion caused by external objects that lead to in-place changes. -Since the authors have assumed that mobility is done by external factors, there is no energy consumption in nodes. -Sensors can change their signal strength for transmission based on nodes' distance. -Cluster heads can aggregate the collected data to remove additional data.

3-1-Energy Consumption Model
Energy consumption in the sensor-based IoT network consists of three sections: data transmission, data reception, and data processing. Equation (2) presents the energy model as follows [16][6]: Where, P T , P R , and P cpu denote the energy consumption of transmission, reception, and processing of k-bits data, respectively. E elec , E amp , and E cpu are the energy consumption (nJ/bit) for transmitting per bit in the radio radius, the energy required for transmitting with a radius higher than E elec , and the energy needed for processing per bit, respectively. The total energy consumption of k bits, according to Equation (3), is as follows [16][6]: Equation (3) indicates that energy consumption is directly related to the data length. In the case that the data sent first is less, less energy will be consumed. If the transmission distance is less than the threshold, the energy consumption would be in relation to d 2 , and if the transmission distance is greater than the threshold, it will be in relation to d 4 . Thus, the shorter the transmission distance, the lower the energy consumption.

3-2-Description of Proposed Method
The most important objective of the present article is to use computational intelligence algorithms to improve the sensor-based IoT network's lifetime. Therefore, the authors have presented a method based on computational intelligence algorithms to minimize the energy consumption of sensors in the network. In this section, the proposed algorithm is discussed. The suggested algorithm (RCECI) in the proposed method is implemented after the sensor nodes are distributed in the desired area. In this method, the cluster heads are performed by the type-1 fuzzy algorithm, and also the path between the cluster heads to the base station is done by the type-2 fuzzy algorithm; the operations are performed accurately at the base station. The proposed algorithm operates based on round, and each round includes two phases: setup and steady-state. The network initializes all sensor nodes before the first round and notifies them by sending a message containing information about the total network energy, synchronization time, and start order. In each round, after selecting the cluster heads by the type-1 fuzzy algorithm at the base station and also specifying the path between the cluster heads to the base station using the type-2 fuzzy algorithm, a message is sent from the base station to the identified cluster heads to inform the related sensor about its role as a cluster head and the path of data transfer to the base station in the current round. Then, the sensors selected as cluster heads inform the other sensors of their role as cluster heads in the current round. For this purpose, each header broadcasts an announcement message throughout the network. Normal sensors then become the members of cluster heads, which require the least energy and the shortest distance to communicate with them. After each normal sensor makes a decision about the cluster, it wants to join in the current round and notifies the cluster head of this decision with a Join-REQ message. The cluster heads, depending on the number of cluster members, create a Time-Division Multiple Access (TDMA) schedule and notify their members to prevent data collisions during the transfer. Consequently, there would be no collision between the data within a cluster. After the TDMA schedule is identified by all member nodes of the clusters, the setup phase is completed, and the Steady-state (data transfer phase) starts. At this stage, the network performance is divided into a number of time slots; each sensor transfers data to the related cluster header at a specified period. In the proposed algorithm, the base station transmits simultaneous pulses to the network sensors so that all the sensors begin the starting phase together. After identifying the cluster heads, forming the clusters, and determining the TDMA schedule, each sensor transmits its data to the cluster at a specific time using the Carrier-Sense Multiple Access (CSMA) method and a unique distribution code. Cluster heads also apply the same distribution code to send their data. When the cluster head has data to send, it should listen to the channel to ensure that no other sensor has data to send at that time. If the channel is empty, it should transfer its data to another cluster head or base station, and if the channel is busy, it waits for a random period and sends its data after the channel is empty.

3-3-Selection of Cluster Heads and Routing
The optimal selection of cluster heads is performed using the type-1 fuzzy algorithm. Fuzzy logic is a theory for acting in conditions of uncertainty; the theory is capable of mathematically formulating many inaccurate and ambiguous concepts, variables, and systems and provides a basis for reasoning, deduction, control, and decisionmaking in conditions of uncertainty. Most of our decisions and measures are in conditions of uncertainty, and clear and unambiguous states are extremely rare. Figure (2) demonstrates the basic structure of the fuzzy system. Fig. 2. Structure of the fuzzy algorithm [17] After placing the nodes for clustering in the proposed algorithm, type-1 fuzzy logic is applied to select the cluster head. In this algorithm, the triangular membership function with three parameters has been used, the first parameter of which is the remaining energy and is obtained by the equation as follows: Density is equal to the ratio of neighboring nodes to total nodes; the higher it is, the node is more suitable for becoming a cluster head.
n N is referred to as the neighboring nodes, and N T denotes the total nodes. Centrality was applied, which is referred to as the centrality of the node relative to its neighbor nodes and is the sum of the total distance of the node from its neighbors. A lower value indicates that the node needs less energy as a cluster head and is more suitable for becoming a cluster head.  After the membership functions of all three parameters, as well as the output membership function, are formed, the fuzzy rules are developed according to Table (1) and given to the fuzzy network. Then, each node's fuzzy value is obtained, and after implementing the fuzzy algorithm, 10% of the nodes with the best values are specified as cluster heads. Also, the base station informs the cluster heads of their role, and then the cluster heads send a message to the network announcing that they are cluster heads. Afterward, each normal node that receives this message joins the cluster head based on its energy and distance to the cluster head node and announces its membership to the desired cluster head. After selecting the cluster head and carrying out the membership operations for cluster heads, normal sensors collect the sensed data from the network and send it to their cluster head; then, the cluster heads must transfer data to the base station. For this purpose, the type-2 fuzzy algorithm has been applied to obtain the best nodes for creating a minimum tree from the cluster heads toward the sink. Figure  (5) indicates the type-2 fuzzy logic diagram block. Fig. 5. Type-2 Fuzzy Logic Diagram [18] In the setup phase, after determining which sensors have been selected for becoming the cluster heads, the type-2 fuzzy algorithm is applied for path selection. First, the cluster heads are arranged based on their distance to the base station, and then the routing algorithm is implemented for all cluster heads so that the neighbor of each cluster head is equal to half of the cluster heads closer to it; if there is no neighbor with these conditions, the cluster head is connected directly to the base station. In the case that the cluster heads have neighbors, the type-2 fuzzy algorithm is implemented for the neighbor cluster heads, and they are arranged in descending order based on their fuzzy value. Then, the neighbor with the maximum fuzzy value is picked, provided that the neighbor cluster head is closer to the base station compared to the cluster head itself, and if such conditions do not exist, the cluster head connects directly to the base station. In order to implement the type-2 fuzzy algorithm in routing, first, the type-2 fuzzy triangular membership function for all cluster heads is specified based on the parameters remaining energy, the distance from the cluster head to the base station, and the distance to the current cluster head.
E r denotes the remaining energy of the sensors.
(X 3 , y 3 ) is the space coordinate of the cluster head, and (x 4 , y 4 ) is the space coordinate of the base station.  After the membership functions are specified, the fuzzy rules are defined and given to the fuzzy network. The routing algorithm is implemented to create a path between the cluster heads and the base station. Then the data is transferred from the cluster heads toward the base station according to the created path.

4-Results
The proposed protocol in the present article is implemented and tested with MATLAB software in two scenarios: 1) Constant energy of all sensors (homogeneous environment) and the fixed base station 2) Not equal energy for all sensors (heterogeneous environment), movable sensors, and the clockwise movement of the base station at a speed of 10 degrees per round.

4-1-Scenario I
In this scenario, 150 sensor nodes were randomly distributed over an area of 200*200 m 2 . In this test, the initial energy of all sensors is identical (homogeneous environment) and equals 0.5 J. The base station is also fixed in the position (100*350). Fig. 8. Comparison of energy consumption and remaining energy in the network As shown in Figure (8), the proposed method (RCECI) has improved the network's energy consumption compared to previous algorithms. The proposed algorithm increases networks' lifetime by approximately 34%, 45%, and 56% compared to the DCE, DEEC, and LEACH algorithms, respectively. According to Figures (9) and (10), it can be concluded that the proposed algorithm is superior than other algorithms in both the first node die (FND) and the last node die (LND) because sensors survive in most rounds. As shown in Figures (9) and (10), in the proposed algorithm, FND occurs in the 155th round, and the LND is taken place in the 2930s round. Also, in the DCE algorithm, the FND occurs in the 126th round, and the LND is taken place in the 2201st round, which shows the performance of the proposed algorithm is superior than other algorithms. In the following, we examine the proposed scenario in environments of different sizes. Table 4. the proposed scenario 1 in environments of different sizes As shown in Table 4, the larger the environment, the sooner the sensors die, and this is because the distance between the sensors increases, and they spend more energy on communicating with each other. Besides, the proposed method performs better in different interval environments than the previous algorithms, and the sensors survive longer rounds, which shows that the proposed algorithm does not lose its working efficiency as the environment grows. 1.9*10 , respectively, which shows that the number of packets sent to the base station in the proposed method is more than DCE, DEEC, and LEACH algorithms by about 32%, 50%, and 62%, respectively.

4-2-Scenario II
In this scenario, 100 sensor nodes were randomly distributed in an area of 100*100 m 2 . The sensors are movable, and their mobility is due to external factors, and the sensor's energy is not consumed, and only its position changes. The sensors' initial energy is varied (heterogeneous environment, half of the sensors have twice the energy of the others), and the base station in the position 50*150 moves around the environment in a clockwise manner at a speed of 10 degrees per round.    (13) and (14), it can be concluded that the proposed algorithm is superior than other algorithms regarding both FND and LND, and sensors survive in most rounds. In the proposed algorithm, FND occurs in the 896th round, and LND is taken place 2960s round. Also, in the DCE algorithm, FND occurs in the 629th round, and LND is taken place in the 2242nd round, which indicates the better performance of the proposed method compared to other algorithms. In the following, we examine the proposed scenario in environments of different sizes. The results obtained in Table 5 show that the proposed method is not affected by environmental change and is still better than previous methods in which the sensors survive further rounds. As it is clear, with increasing the length of the environment, using the energy by sensors will be increased due to increment of the distance of communication and leads to a reduction in the total lifetime of the network. As indicated in Figure (15

5-Discussion and Conclusion
In the present research, a clustering-based routing protocol using computational intelligence algorithms was proposed for wireless sensor-based IoT networks. In this algorithm, first, the appropriate cluster heads are specified from the existing sensor nodes using the type-1 fuzzy algorithm, and then the sensors join these cluster heads and send the collected data to their cluster heads. Then, the cluster heads perform hierarchically to send their collected data to the sink, so that select the best cluster head to send the data from the cluster heads to the base station in a multi-hob manner using the type-2 fuzzy algorithm. According to the simulation, it can be concluded that the network's lifetime (based on the first sensor die and the last node die) has been improved by approximately 33%, 40%, and 52% compared to DCE, DEEC, and LEACH algorithms, respectively in the case of changing the number of sensors, altering the environment, homogeneity and heterogeneity of sensors and movability of the base station. Furthermore, the number of packets sent to the base station has been evaluated in different scenarios, which indicates that the proposed algorithm led to a significant improvement in the number of packets sent to the base station.
The following suggestions may be made for future research: -The use of other computational intelligence algorithms and integrating them to improve routing between cluster heads. For example, the use of machine learning algorithms -The use of various criteria for creating paths and selecting cluster heads. For instance, the use of the distance between the Cluster head or the number of members of each cluster