1 Introduction

Wireless sensor networks (WSNs) mainly because of wide variety of applications [1] as well as future potential such as integration into ‘Internet of Things’ [27] has received a significant attention over the past decade. Typically these type of networks, which might have different topologies [8, 9], are made of a large number of tiny battery-powered sensor nodes (SNs). The primary task of the SNs is to sense and collect data from their surrounding environment. The collected data by the SNs are needed to be sent to the base station (BS) which acts as a bridge between remote users and WSN. Due to huge number of SNs, distributed usually in inaccessible locations, recharging or replacing of sensors’ batteries are impractical. Therefore the energy management and extending the lifetime of network could be addressed as the main challenges associated with these type of networks. In [10] authors designed and implemented a house-build experimental platform, called energy management system for wireless sensor networks (EMrise) for management of the energy and exploration on WSNs.

Transmission of data to the BS is undoubtedly one of the major energy consuming task [11]. Consequently in this regard various energy efficient algorithms [1218] have been designed and improved. Clustering is one of the popular techniques which is adopted to reduce the energy consumption of the WSNs by decreasing the number of transference within the network. In clustering the WSN is divided into number of clusters and each cluster is allocated a cluster head (CH) which receives the data from its members and forwards them to the BS. Figure 1 gives a picture of a typical WSN along with the components of a SN.

Fig. 1
figure 1

A typical WSN along with the components of a sensor node

Choosing appropriate CHs by carefully considering various factors associated with each SN could result in minimizing the energy consumption to a significant degree and consequently prolonging the network’s lifetime. Low energy adaptive clustering hierarchy (LEACH) [19] is the earliest and most propounded clustering algorithms which was introduced more than a decade ago. In LEACH the network area is randomly divided into pre-determined number of clusters and each cluster is assigned a CH. CHs are elected and changed randomly after specific time intervals. A node will be re-elected only if all the other candidates have been elected. Due to random selection of CHs in LEACH without considering vital information of nodes such as location, remaining energy, distance from base station etc. it might result in improper distribution (CHs will be close to one another) or inappropriate selection (e.g. Nodes with low energy) of CHs.

Popular methods such as fuzzy logic (FL) and genetic algorithm (GA) have been employed in various novel and existing algorithms to enhance the process of CHs election. In this paper a new routing protocol based on fuzzy logic is proposed, where a two-step FL system is used to select the appropriate CHs in order to reduce the energy consumption and extending the lifetime of the network. In first-step of the proposed algorithm, the main factors of each SN such as residual energy, density and distance to BS are checked and according to the output, most suitable candidates are selected. Furthermore in the second-step of FL system the vulnerability index, centrality and distance between CHs are checked and according to the output the CHs will be elected. In the proposed fuzzy system the usage of vulnerability index as a parameter for each sensor node has been introduced which assures the availability of the network as the nodes with high vulnerability index has a fewer chance to be chosen as the CHs. Centrality and distance between CHs are other factors which are checked to promise proper distribution of CHs within the network. The result of the simulation indicates that the proposed algorithm performs better in case of fair distribution and balancing of the overall energy consumption comparing with other famous existing protocols.

The reminder of paper is as follows. The related work is discussed in Sect. 2, system model is clarified in Sect. 3, the Sect. 4 includes the proposed model, the result of our simulation is given in Sect. 5 and finally conclusion of our work is presented in Sect. 6.

2 Related work

Several works regarding the wireless sensor and wireless networks are found in the literature [2025]. In an effort to enhance the energy consumption of WSNs various techniques, such as data communication protocols [2631], data collection [3235], data aggregation [3638] and coverage of the network [3941] have been employed. LEACH protocol [19] which is the most primitive clustering-based algorithm was designed to reduce the energy consumption and prolonging the WSNs lifetime. In LEACH protocol, SNs are randomly arranged into pre-determined number of clusters and each cluster is allocated a CH at each round. To become a CH, a random number (between 0 and 1) is generated by each SN. SNs having generated numbers less than the threshold T(n) (Eq. 1), will become CHs for that specific round. Randomized rotation of CHs are used to avoid draining the energy of a single SN. Re-election of a SN as a CH will be possible only if all the other candidates have been elected.

$$T\left(n \right) = \left\{{\begin{array}{*{20}l} {\frac{P}{{1 - P*\left({r\bmod \frac{1}{P}} \right)}}} & {if\,n \in M} \\ 0 & {otherwise} \\ \end{array}} \right.$$
(1)

where, p stands for ratio of CHs in the WSNs (the value of p is obtained through dividing the expected number of CHs in the current round by the number of nodes in WSN), r indicates the round number and M represents the set of SNs which have not been chosen as CH in the last 1/p rounds (if n ∉ M, it won’t become a CH for that specific round as the T(n) value for that node would be set to 0).

As it was mentioned earlier, because the CHs are randomly chosen in LEACH without considering important characteristics of SNs, it could result in inappropriate distribution or improper selection of CHs. FL is a decision system technique which works similar to human logic [42] offers a simple method to reach at a confident decision based upon unclear, vague, imprecise, or absent input information. FL system with its essential components are shown in Fig. 2.

Fig. 2
figure 2

Fuzzy system architecture

In [43], FL is used to select CHs based on three fuzzy variables, node’s energy, concentration and centrality. In each round there is only one chosen CH whereas balancing the energy consumption and extending the network lifetime required more CHs to be selected.

Based on FL control in [18] a new routing protocol to extend the lifetime and throughput of WSNs has been proposed. The distance between cluster heads is not considered which might lead into improper distribution of CHs within the network. Nodes’ density, nodes’ battery level and distance of nodes form the base station are the only parameters used to select the CHs. Similarly authors in [44] present a fuzzy decision-making approach to select the appropriate CHs by using three criteria including density, distance from the BS and energy level of the nodes. In [45] authors propose a FL based energy-aware dynamic clustering technique which uses just only two inputs (node’s centrality and residual energy) and not considering many of other possible parameters (such as distance between cluster heads, vulnerability index etc.), in order to improve lifetime of the WSN in terms of last node dies (LND).

More in [46], an energy efficient clustering algorithm has been proposed for WSNs based on FL concept. The selection of CHs is done according to a threshold value. Then among the selected CHs based on some fuzzy input parameters (remaining battery power, mobility and centrality) a CH will be selected as a super cluster head (SCH) which will be responsible for sending data to the BS. The main issue with this algorithm is the absent of checking the vulnerability of the SCH as it acts as the main node to send data to BS.

In [47], to compute the chance for a node to become the CH, two fuzzy parameters, node’s energy and local distance are computed. In every round, SNs generate a random number and if the generated number is smaller than predefined threshold, the chance is calculated for the SNs. Therefore, some suitable nodes may not get selected because of this random number.

In this paper a new routing protocol based on LEACH is proposed, where a two-step FL based algorithm is used to select the appropriate CHs. The main difference of this algorithm with the existent ones, is the number of parameters involved to select the ideal CHs. the proposed algorithms uses six parameters (residual energy, density and distance to BS, vulnerability index, centrality and distance between CHs) which guarantees the ideal selection of CHs. Consideration of vulnerability index for each SN enhances the availability of the WSN as SNs having high vulnerability index have less chance to be chosen as the CHs.

3 System model

Few basic assumptions are made about the sensor nodes, which are deployed to monitor an environment. These assumptions are as follows:

  1. 1.

    WSN contains homogeneous SNs, having equivalent initial energy.

  2. 2.

    SNs are deployed randomly.

  3. 3.

    SNs and BS are kept stationary once deployed.

  4. 4.

    All the SNs have battery-limited power and battery recharge is impractical.

  5. 5.

    The distance of SNs from BS and other nodes is computed based on the strength of signals.

A simplified model [48] for radio energy dissipation is used which has been depicted in Fig. 3 and explained next.

Fig. 3
figure 3

Radio energy dissipation model [48]

The consumed energy for transmitting an l-bit message over the distance d, can be calculated with Eq. (2).

$$E_{Tx} \left({l,d} \right) = E_{Tx - elec} \left(l \right) + E_{Tx - amp} \left({l,d} \right) = \left\{{\begin{array}{*{20}l} {lE_{elec} + l\epsilon_{fs} d^{2},} & {d < d_{o}} \\ {lE_{elec} + l\epsilon_{mp} d^{4},} & {d \ge d_{o}} \\ \end{array}} \right.$$
(2)

The Eelec, ℰfs and ℰmp are the electronics energy and the amplifier energy in free space and multipath respectively. And receiving this message will consume:

$$E_{Rx} \left(l \right) = E_{Rx - elec} \left(l \right) = lE_{elec}$$
(3)

4 Proposed algorithm

Proposed algorithm uses FL system that is composed of two main steps in order to select the CHs. In the first step of FL system nodes are selected if they are in the proper locations with respects to the energy concerns. Furthermore in the second step, the level of vulnerability, centrality and desired distance between CHs of all the nodes (selected in the first step) are checked and according to the output, CHs will be elected. The second-step of the FL system enhances the availability of the network as the node with high vulnerability have less chance to be elected as CHs. The proposed FL system is explained in details as follows:

4.1 First-step of FL system

As we mentioned before the first step of the FL system selects the nodes based on their location and energy level. This step attempts, that nodes with adequate residual energy and proper location will be selected for further consideration. The input functions named, residual energy, node density and distance to BS are used to convert the crisp inputs into fuzzy sets. Different membership function is used to illustrate the different level of the input functions as shown in Table 1 as well as Figs. 4, 5 and 6.

Table 1 Input functions (first-step of FL system)
Fig. 4
figure 4

Membership functions of residual energy

Fig. 5
figure 5

Membership functions of node density

Fig. 6
figure 6

Membership functions of distance to BS

The output (fuzzy cost) of the first-step FL system, shows the probability level for each node to be chosen for further consideration in next step. The output function along with its membership functions are shown in Table 2 and Fig. 7.

Table 2 Output functions (first-step of FL system)
Fig. 7
figure 7

Membership functions of qualification in first-step of FL system

The fuzzy if–then rules which are mostly based on experience and knowledge of experts in that domain, and relationship among the fuzzy input variables are given in Table 3 and Fig. 8 respectively.

Table 3 Fuzzy if–then rules in first-step of FL system
Fig. 8
figure 8

Relationship among fuzzy inputs in first-step of FL system

4.2 Second-step of FL system

In the second-step of FL system the qualified nodes (selected in first-step) are re-evaluated and checked based on three parameters: vulnerability index, centrality and distance between CHs. The main purpose of this step is to enhance the availability of network by considering vulnerability index (Nodes with high vulnerability index have lesser chance to be elected as CHs) and proper distribution of CHs by checking their distances. Input functions of second-step of FL system along with their different membership functions are given in Table 4, Figs. 9, 10 and 11 as well.

Table 4 Input functions (second-step of FL system)
Fig. 9
figure 9

Membership functions of vulnerability index

Fig. 10
figure 10

Membership functions of centrality

Fig. 11
figure 11

Membership functions of distance B/W CHs

The output (fuzzy cost) of second-step FL system, shows the possibility of SNs to be chosen as CHs. Figure 12 and Table 5 depict the output function along with its membership functions.

Fig. 12
figure 12

Membership functions of qualification in second-step of FL system

Table 5 Output functions (second-step of FL system)

The relationship among the fuzzy input variables (vulnerability index, centrality and distance between CHs), and fuzzy if–then rules in the second-step FL system have been given in Fig. 13 and Table 6 respectively.

Fig. 13
figure 13

Relationship among fuzzy inputs in second-step of FL system

Table 6 Fuzzy if–then rules in first-step of FL system

5 Simulation and evaluation

Simulations are performed in order to verify the efficiency of the proposed algorithm. The simulation environment comprises of two different scenarios, 60 homogenous SNs deployed randomly over 120 × 120 and 60 × 60 m2 networks. Each SN has an initial energy of 0.1 J. In our experiment the communication energy parameters are set as Eelec = 50 nJ/bit, ε fs = 10 pJ/bit/m2 and ε mp = 0.0013 pJ/bit/m4 and energy for data aggregation is set as E DA  = 5 nJ/bit/signal. The proposed algorithm has been compared against LEACH [19], GUPTA [43] and CHEF [47] in case of network’s lifetime, energy dissipation and variance of energy.

The number of alive nodes with regard to network’s operation for each scenario, have been given in Figs. 14 and 15. Regarding the death time of first node, it’s well observed that, the proposed algorithm performs much better in both of the cases. However while the network size is 120 × 120 m2, the CHEF algorithm achieves slightly better performance than the proposed and other algorithms regarding the death of last node as it’s shown in Fig. 15.

Fig. 14
figure 14

Number of alive nodes (network size 60 × 60)

Fig. 15
figure 15

Number of alive nodes (network size 120 × 120)

To verify the energy effectiveness of the proposed algorithm, the residual energy of the WSN in each round has been analysed. The Figs. 16 and 17 compare the energy dissipation of different protocols. Considering these figures it’s found that in both of the situations (network size of 60 × 60 and 120 × 120 m2) the curve of the proposed algorithm is smother than the rest of protocols, which verifies its better performance in case of fair distribution and balance of the overall energy.

Fig. 16
figure 16

Residual energy of the WSN (network size 60 × 60)

Fig. 17
figure 17

Residual energy of the WSN (network size 120 × 120)

Another way to validate the reasonable consumption of the energy within the WSNs, is to study the variance of overall energy with regard to network’s operation. Having slighter variance of residual energy confirms a reasonable energy consumption. The Figs. 18 and 19 depict the variance of energy in both of the scenarios in different rounds. In both of the cases, the proposed algorithm appears to have smaller variance of energy.

Fig. 18
figure 18

Energy variance of the WSN (network size 60 × 60)

Fig. 19
figure 19

Energy variance of the WSN (network size 120 × 120)

6 Conclusion

In this paper, a new routing protocol based on fuzzy logic is proposed, where a two-step FL system is used to select the most appropriate sensor nodes as CHs. The cluster heads nodes selection is based on six descriptors; residual energy, density and distance to BS, vulnerability index, centrality and distance between CHs. Conceptually There exist several algorithms based of fuzzy logic. But it is realized that they do not take into account all the significant information of the sensor nodes in order to guarantee the optimal selection of the CHs. Comparison of our proposed routing protocol against some other similar approaches indicates that, the proposed algorithm performs better in case of fair distribution and balancing of the overall energy consumption. Additionally the result shows a smaller variance of energy for the proposed algorithm which also validates its reasonable consumption of the energy.