1 Introduction

A wireless Sensor Network is comprised of many sensor nodes and a base station (BS). These nodes are tiny in size and have restricted and limited, power supply, memory and processing capability. Each particular sensor is made up of four main units, power supply unit, communication unit, processing unit and a sensing unit. The Fig. 1 depicts a typical architecture of a sensor node. WSNs can be employed in number of applications such as environmental, biomedical and military applications. WSNs are expected to be joined into the ‘Internet of Things’ [1] where the WSNs join the Internet, and utilize it to work together and achieve their tasks. Despite the goals and objectives of sensor applications, the main task of wireless sensor nodes would be to sense and gather data of a potential field, and sending them to specific sites. Achievement in this task efficiently needs the design of energy-efficient routing protocol. Many routing algorithms have been optimized and developed in this regard [26]. One of the most significant routing strategy for WSNs is the hierarchal or cluster-based routing due to their high efficiency and scalability. In hierarchical routing protocol nodes with high energy are used to send data to the BS while the nodes with low energy are used to sense and collect data of a specific area. LEACH [7], TEEN [8], and PEGASIS [9] are some of well-known hierarchical routing protocol. The LEACH routing protocol was one of the earliest clustering-based routing protocol. It improves the energy consumption of the network by selecting the CH nodes randomly to allocate energy load evenly to all the nodes. SEP [10] (Stable Election Protocol) is another type of cluster-based routing protocol which includes two tier energy level, in order to prolong the lifetime of the network. Taking advantage of intelligent approaches such as fuzzy logic within the routing protocols could greatly improves the efficiency of WSNs. For those applications requiring real-time decision making, fuzzy logic is a strong and powerful tool that would make decisions no matter if there exists inadequate data. In this paper fuzzy logic control is used to enhance the process of cluster head selection in the existing SEP protocol based on three variables, distance of nodes form BS, density of nodes and the battery level of nodes to improve the lifetime of and throughput of the WSN. The result of the simulation which has been done in MATLAB [11] indicates that usage of fuzzy logic system along with the traditional threshold values used in SEP for selection of the CH improves the lifetime of the network significantly by almost 73.2 and 42.4 %, comparing with the SEP and its enhanced version SEP-E [12] protocol respectively. The reminder of paper is organized as follows. In Sect. 2 the related work is discussed, Sect. 3 discusses the proposed system model, the result of our simulation are shown in Sect. 4 and finally conclusion is given in Sect. 5.

Fig. 1
figure 1

Architecture of a typical Sensor Node

2 Related work

Different approaches and techniques regarding Energy efficiency and throughput optimization of wireless sensor networks such as data aggregation [13, 14] data collection [1517] coverage of the network [1821] and data communication protocols [2225] has been employed. Low-Energy Adaptive Clustering Hierarchy (LEACH) [7] is one of the earliest and most well-known clustering-based routing protocol, designed for WSNs to minimize the power consumption. In LEACH, the sensor nodes arrange themselves into number of clusters, with one sensor node acting as the CH at each round. LEACH uses randomized rotation of the high-energy cluster-head position in an attempt to not drain the battery of a single sensor. Additionally, LEACH does data aggregation and fusion to compress and reduce the size of data being sent to the base station, in order to enhance energy dissipation and improving system lifetime. To be a CH, all sensor nodes generate a number randomly. If the random number is less than the threshold T(n), the node will become a CH for the current round, the Eq. (1) to calculate the threshold is given as follows:

$$T\left( n \right) = \left\{ {\begin{array}{*{20}c} {\frac{P}{{1 - P*\left( {r {{\rm mod}} \frac{1}{P}} \right)}} \quad if\,n\,\in M} \\ {0 \qquad\qquad otherwise} \\ \end{array} } \right.$$
(1)

where, n stands for a set of given nodes, p is the desired percentage of CHs, r indicates the present round being elected as a CH and M stands for the set of sensor nodes which haven’t been elected as CH in the previous 1/p rounds. One of the biggest drawback of leach protocol would be considering all the nodes having the same energy value which might not be the case for many applications.

A Stable Election Protocol (SEP) [10] is an enhanced version of LEACH protocol. It has been designed for two-level heterogeneous networks. The protocol includes two types of nodes advanced and normal nodes, different from one another in term of their initial energy. The protocol working is almost same as LEACH but with this distinction that in SEP advanced nodes that have a higher initial energy get more frequently elected as CHs. This is to assure a uniform usage of node energy and prolong the lifetime of the network. In case of SEP protocol the p (desired percentage of CHs) for normal and advance nodes has been given in Eqs. (2) and (3) respectively.

For normal nodes:

$$p_{norSEP} = \frac{{p_{opt} }}{1 + \alpha .m}$$
(2)

For advance nodes:

$$p_{advSEP} = \frac{{p_{opt} }}{1 + \alpha .m} \times \left( {1 + \alpha } \right)$$
(3)

where m is the percentage of advanced nodes, a stands for additional energy of advanced nodes and popt is the optimal probability of a given node to become the CH.

The new advanced nodes does not have any effect on the density of the network but, the overall energy of the network changes. Energy level of the every advanced node rises by (1 + a) times and energy level of the whole network by (1 + a.m). Presume that E0 is the initial energy level for every normal sensor, so energy of each advanced nodes and the total network can be calculated respectively as:

$$E_{advanced } = \left( {1 + \alpha } \right).E_{0}$$
(4)
$$E_{totalSEP} = n.E_{0} \left( {1 + \alpha .m} \right)$$
(5)

In SEP protocol there are two different threshold equations for the normal nodes and advanced nodes which are given as follows: For normal nodes:

$$T\left( {n_{{normSEP}} } \right) = \left\{ {\begin{array}{ll} {\frac{{p_{{normSEP}} }}{{1 - p_{{normSEP}} *\left( {r\,\bmod \,\frac{1}{{p_{{normSEP}} }}} \right)}}} & {if\quad n_{{normSEP}} \in M^{I} } \\ 0 & {otherwise} \\ \end{array} } \right.$$
(6)

For advanced nodes:

$$T\left( {n_{advSEP} } \right) = \left\{ {\begin{array}{*{20}c} {\frac{{p_{advSEP} }}{{1 - p_{advSEP} *\left( {r \bmod \frac{1}{{p_{advSEP} }}} \right)}}\quad if\,n_{advSEP} \in M^{II} } \\ {0 \qquad\qquad otherwise} \\ \end{array} } \right.$$
(7)

Fuzzy logic [26] is basically a decision system technique which works almost same to human logic. In [27] the concept has been employed for Strategic QoS Routing in Broadband Networks. It is a convenient method as it uses human language to explain inputs, outputs, as well as providing a simple method for coming to a conclusion from uncertain and vague input information. A fuzzy logic system along with its essential input–output relationship is comprised of four main components named, fuzzification, defuzzification, inference engine and a fuzzy rule base as shown in Fig. 2.

Fig. 2
figure 2

Fuzzy system architecture

Within the fuzzification module with the help of a fuzzification function the system inputs are converted into fuzzy sets. The interface engine task is to simulate human reasoning procedure on fuzzified inputs by referring to the fuzzy rule base which stores the IF–THEN rules. Then the defuzzification module will transform the obtained values from fuzzy interface engine into crisp values and provide them as the output of the fuzzy system. In [28], the fuzzy system has been used to elect cluster heads. The algorithm uses three fuzzy variables (Energy, centrality and concentration of a node) for selection of CHs. In this approach, the essential information are collected by the BS and then according to the rules of fuzzy logic system a node is elected as a CH. In [29] also the CHs are elected based on fuzzy logic rules. The fuzzy set contains the energy levels of nodes as well as their distances. In [29] a random number for each node is generated, and if the generated number is less than a specific threshold, the node might be discarded from becoming CH although it could be a qualified one. Head. Authors in [30] use three linguistic variables to elect nodes as CH with attention on nodes having high probability, as well as high initial and final energy.

In this paper, our approach uses fuzzy logic based on node’s energy, its distance to the BS, node’s density, along with its threshold value which will be calculated independently. Thus CHs election is dependent on all the crucial factors needed. Combination of all the mentioned factors will lead to the election of best possible nodes as CHS. In this approach contrasts with [28] the CHs are elected within the cluster by sensor nodes not BS.

3 Proposed system model

The fuzzy logic has been employed to enhance the cluster head selection and prolong the lifetime of the SEP protocol. Three input functions namely battery level, distance and node density were used to convert the crisp inputs into fuzzy sets. Each one of the input functions possesses three membership functions which typically illustrates the different level of the functions. Table 1 shows the input functions along with their membership functions.

Table 1 Input functions

The fuzzy system output shows one of the probability level (Another probability will be computed using traditional threshold) for each node to be chosen as a cluster head. The output function of our proposed approach which contains 9 membership functions is shown in Table 2.

Table 2 Output functions

The following surface plots Fig. 3, shows the relationship among the fuzzy input variables used in our fuzzy logic approach.

Fig. 3
figure 3

Relationship among fuzzy inputs

To elect nodes as CHs most efficiently in order to prolong the lifetime of the network we first compute the battery level, node density and distance to the base station, for each and every sensor node and then calculating the probability by considering fuzzy rule base given in Table 3. Then the computed probabilities for each node is stored in some variables.

Table 3 Fuzzy if–then rules

The next step would be to compute the threshold value for each node (Eqs. 6, 7) and then storing them in separate variables. The two variant probabilities obtained from our fuzzy logic system and the threshold equations will be used to find the most suitable nodes as CHs. We finally calculate the weighted probability by considering the mean of the previous probabilities for each and every node and then sorting them according to their value, nodes having height weighted probabilities would be elected as the CHs. As we can see here we used the old threshold equations as well as considering other properties of each node (battery level, node density and distance to the base station) to elect the most suitable nodes as CHs in order to prolong the network lifetime and increase its efficiency. The working procedure of the protocol is given below:

Step 1 :

Calculating the battery level, distance and node density for each and every node

Step 2 :

Computing the first probability, by entering the computed values (step 1) into the fuzzy interface system

Step 3 :

Computing the second probability for each node using threshold values (Eqs. 6, 7)

Step 4 :

Using the mean value of the obtained probabilities of each node and compute the weighted probability for each node

Step 5 :

Sorting the weighted probabilities

Step 6 :

Election of nodes having highest weighted probability as the CHs

4 Simulation and results

In order to evaluate the performance of the SEPFL and compare it with SEP and its existing enhanced version SEP-E, simulation tests have been carried out in MATLAB (2014a) [11]. 100 nodes have been deployed and distributed randomly within an area of 100 × 100 m. Energy model used here is the same as in SEP protocol. A list of simulation parameters are given in Table 4. In case of SEP protocol 20 % of the total nodes are advanced nodes having 100 % more energy than the normal ones and for SEP-E protocol 20 % of the nodes deployed are advanced with 100 % more energy than normal nodes, 10 % nodes are intermediate nodes with 50 % more energy than normal nodes.

Table 4 Simulation parameters

4.1 Lifetime of network

Figure 4 depicts the total of alive nodes with respects to the functioning of the network in different rounds. Considering Table 5, it is clearly observed that in the proposed algorithm the death of the first node as well as the last node have been prolonged by 18.57 and 73.2 % respectively comparing with SEP protocol. Bearing in mind the result obtained from SEP-E routing protocol we notice that improvement for the first node death and the last death is 6.45 and 42.4 % respectively. Therefore the proposed algorithm improved the overall lifetime of the network significantly.

Fig. 4
figure 4

No. of alive nodes versus Rounds

Table 5 Comparison of algorithms results

4.2 Residual energy of network

Analysing the Residual energy of network can be very handy to determine the energy efficiency of an algorithm. The Fig. 5 shows the comparison of energy consumption of SEP, SEP-E and SEPFL protocols. As we observe the curve of SEPFL is smother than the other compared protocols thus it has a better performance in terms of balancing and distributing of the overall energy.

Fig. 5
figure 5

Energy dissipation of network versus rounds

4.3 Throughput of network

By term throughput we mean the number of packets which have been sent to the base station/sink. Considering Fig. 6 we notice that our proposed algorithm has a higher throughput, about 68.54 % comparing with SEP and 33.5 % while taking into account the result obtained from SEP-E routing protocol.

Fig. 6
figure 6

Packet sent to the BS versus rounds

5 Conclusion

In this paper the SEP protocol has been optimised, using the concept of fuzzy logic system. This is done by balancing the energy load of the network. Nodes with high residual energy, high probability, and requiring less energy for communicating with other nodes as well as the BS are elected as the CHs. The new proposed algorithm shows more stability and runs for a longer time. The lifetime of the network has been extended by 73.2 and 42.4 %, in comparison with the SEP and SEP-E protocols respectively. The result also declares the throughput of the network to be improved by 68.54 and 33.4 % compared with the mentioned protocols.