1 Introduction

Wireless sensor networks (WSNs) consist of a great amount of small nodes which have sensing, computing, and communication abilities. Owing to characteristics like convenient deployment, easy self-organizing, and real-time monitoring, WSNs are extremely popular in a variety of applications such as green agriculture, healthcare, and environmental surveillance [1, 2]. However, most of the sensor nodes are battery-driven, to change or recharge their batteries is a tremendous challenge. Therefore, it is critical to design an energy-efficient routing protocol to wisely use the limited energy of WSNs [3, 4].

There are mainly two kinds of routing protocols in WSNs: flat architecture and hierarchical architecture. Flat architecture protocols suffer from data overload when the density of nodes increases and consequently result in uneven energy distribution and limited scalability. As a result, hierarchical routings have gained more and more global attentions in recent years. There are some hierarchical protocols proposed for WSNs: low-energy adaptive clustering hierarchy (LEACH) [5], adaptive threshold-sensitive energy-efficient sensor network (APTEEN) [3], and power-efficient gathering in sensor information systems (PEGASIS) [6]. Among them, LEACH is the most traditional and representative one.

As shown in Fig. 1, LEACH can divide the entire network into different layers and use cluster head to form an upper hierarchy, which may simplify the management of clusters, decrease the number of routing packets, and conserve network energy to some extent [7]. Nevertheless, due to its dynamical but random cluster-head selection approach, it suffers from unsymmetrical cluster-head distribution, imbalanced energy burden, and roundabout data transmission [8].

Fig. 1
figure 1

The network structure of LEACH

In response to these problems, this paper presents a modified cluster-head selection algorithm based on LEACH (LEACH-M). By taking residual energy and network address into account, LEACH-M can optimize cluster-head threshold equation, which ensures a relatively stable and energy-saving cluster structure.

The rest of the paper is organized as follows. Section 2 presents related works. Section 3 describes the design of LEACH-M. Section 4 evaluates the simulation results. Finally, Section 5 concludes the paper and presents our future work.

2 Related works

LEACH is regarded as the most classical cluster-based hierarchical routing strategy designed by Heinzelman from MIT [5]. By dividing the entire network into several clusters, LEACH can reduce the number of data transmitted to base station (BS) and save network energy to some extent. However, it utilizes a random way to choose cluster head, which leads the selected cluster head may not be optimal, and even drawbacks like uneven energy consumption, short lifetime, and limited communication range.

In order to ameliorate these shortcomings, a great deal of researches have been expanded. Several valuable developments of original LEACH algorithm are carried out in what follows.

LEACH-C (centralized LEACH) [9] was a kind of improved LEACH protocol. By minimizing the total sum of squared distances between all cluster members and the closest cluster head, LEACH-C reduced the amount of energy consumption caused by transmitting data from non-cluster-head nodes to their cluster-head. However, isolated nodes cannot transmit their coordinates and residual energy to the BS, which may result in serious data loss and degrade the network performance.

LEACH-F (fuzzy LEACH) [10] was another type of improved LEACH algorithm. Different from LEACH-C, BS offered a cluster-head list for every cluster so that the cluster head was elected in order of the list. Although this method decreased clustering overhead, the unreasonable circumstance that nodes with less remaining power became cluster head may sometimes happen.

Arumugam and Ponnuchamy [11] introduced an energy-efficient LEACH (EE-LEACH) protocol for data gathering. It helped to provide better packet delivery ratio with less energy utilization. But it may suffer from security attacks because they only focused on reducing the energy consumption and ignored the confidentiality and integrity of data.

Pachlor and Shrimankar [12] presented a centralized routing protocol called Base-station controlled dynamic clustering protocol (BCDCP), which evenly distributed the energy dissipation among all sensor nodes to average energy savings and improve network lifetime. Nevertheless, the design idea and algorithm process of BCDCP were not given in detail.

By considering the advantages of channel resource and employing uneven clustering method, Pei et al. [13] developed a low-energy adaptive uneven clustering hierarchy (LEAUCH) for cognitive radio sensor network (CRSN). It can not only remarkably balance network load in CRSN but also efficiently extend network life span. However, most of the existing WSNs operate in the crowded public unlicensed spectrum band while LEAUCH was only experimented and evaluated in CRSN; thus, it may not be suitable for real applications in WSNs.

This study proposes a modified cluster-head selection algorithm based on LEACH——LEACH-M. Based on distributed address assignment mechanism (DAAM) of ZigBee, LEACH-M takes both residual energy and network address into account to adjust cluster-head threshold equation, which ensures a relatively stable and energy-saving cluster structure. Furthermore, the leveraging of a cluster-head competitive mechanism in LEACH-M balances the network energy burden, which dramatically improves energy efficiency and prolongs the network lifecycle.

3 The design of LEACH-M

3.1 Proposed algorithm

In this study, the aim is to solve the problems of unreasonable cluster-head selection and excessive energy consumption in LEACH. Similar to LEACH [5], LEACH-C [9], and EE-LEACH [11], LEACH-M also uses a general radio model. If a k-bit data message is forwarded between two nodes separated by a distance of r meters, then the energy expanded can be described as:

$$ {E}_{Tx}\left(k,r\right)={E}_{Tx}(k)+{E}_{mp}\left(k,r\right)=\left\{\begin{array}{cc}{kE}_{Tx}+{ke}_{fs}{r}^2,& r<{r}_0\\ {}{kE}_{Tx}+{ke}_{mp}{r}^4,& r\ge {r}_0\end{array}\right. $$
(1)
$$ {E}_{Rx}(k)={kE}_{Rx} $$
(2)

where ETx and ERx are the per bit energy dissipations for transmission and reception, respectively, efs and empdenote transmit amplifier parameters corresponding to the free-space and the two-ray models, respectively, and r0 is the threshold distance given by

$$ {r}_0=\sqrt{e_{fs}/{e}_{mp}} $$
(3)

Assume that there are N nodes distributed uniformly in a M × Mregion. If dtoBSis the distance from the cluster head node to the BS, then we can find the optimal number of clusters by

$$ {K}_{\mathrm{opt}}=\sqrt{\frac{N}{2\pi }}\sqrt{\frac{e_{fs}}{e_{mp}}}\frac{M}{d_{\mathrm{toBS}}^2} $$
(4)

Different from LEACH, LEACH-C, and EE-LEACH, LEACH-M uses the network address of every node to modify their cluster-head threshold. In order to calculate the network address of them, DAAM of ZigBee is utilized.

In a ZigBee cluster-tree WSN, network nodes can be divided into three categories: coordinator, router nodes, and end nodes. If the network depth of a sensor node is d, then its address space Cskip(d) can be calculated by

$$ {C}_{\mathrm{skip}}(d)=\left\{\begin{array}{cc}1+{C}_m\cdotp \left({L}_m-d-1\right),& {R}_m=1\\ {}\frac{1+{C}_m-{R}_m-{C}_m\cdotp {R_m}^{\left({L}_m-d-1\right)}}{1-{R}_m},& {R}_m\ne 1\end{array}\right. $$
(5)

where Cm reflects the maximum number of child nodes, Rm indicates the biggest amount of router nodes, and Lm is the inmost depth of network.

According to different types of child nodes, calculation approach of their network address varies [14]. If the short address of a father node is Af, then the network address of its ith router node and jth end node should meet (6) and (7), respectively:

$$ {A}_i={A}_f+1+{C}_{\mathrm{skip}}(d)\cdotp \left(i-1\right),\kern0.5em 1\le i\le {R}_m $$
(6)
$$ {A}_j={A}_f+{C}_{\mathrm{skip}}(d)\cdotp {R}_m+j,\kern0.5em 1\le j\le {C}_m-{R}_m $$
(7)

Pioneered by the “exchanging depth for width” address allocation scheme in reference [15], the proper parameters are set as: Cm = 5, Rm = 3, and Lm = 4.

One example to calculate Cskip(d), Ai and Ais as follows:

If d = 2 and Af = 2, then Cskip(d) = 6, Ai = 3 = 15 and Aj = 2 = 22.

The main contribution of LEACH-M is that it utilizes network address Ai, j figured out by (6) or (7) and residual energy Eres to adjust the calculation equation of T(n):

$$ T(n)=\left\{\begin{array}{cc}\frac{p}{1-p\left[r\operatorname{mod}\left(1/p\right)\right]}\times \left[{w}_1\times \frac{E_{\mathrm{res}}}{\left(1-r/n\right){E}_{\mathrm{init}}}+{w}_2\times \frac{A_{i,j}-{A}_{i,j\min }}{A_{i,j\max }-{A}_{i,j\min }}\right]& n\in G\\ {}0& n\notin G\end{array}\right. $$
(8)

The definitions of notations in (8) are shown in Table 1.

Table 1 Notation definitions

Equation (8) means nodes with more residual energy and better network address will have higher cluster-head threshold, that is, they are more likely to become cluster head, which can effectively improve the robustness of the whole network and make the cluster-head selection more reasonable.

The modified cluster-head selection strategy used in LEACH-M is expressed in the pseudo code below.

figure a

3.2 A cluster-head competitive mechanism

In a conventional cluster-tree WSN, a cluster head should not only forward the messages from cluster members but also communicate with other cluster heads and BS. Hence, they consume excessive energy and tend to die too early and too fast, which leads deteriorating and even paralyzed network routes.

Aiming at this problem, this section integrates a cluster-head competitive mechanism into LEACH-M to balance the network energy load. As shown in Fig. 2, at the beginning of every round, BS will count current Eres of every node and then calculate average energy Eaver by

$$ {E}_{\mathrm{aver}}=\frac{\sum \limits_{i=0}^{N-1}{E}_{\mathrm{res}}^i}{N} $$
(9)
Fig. 2
figure 2

The flowchart of a cluster-head competitive mechanism

Once Eres of a certain cluster head is less than current Eaver, BS will announce a cluster-head election news to dismiss this old cluster heads and vote for a new one. After receiving the election news, all other nodes will report their current Eres and Ai, j to BS for making a cluster-head request. If their Eres is less than Eaver, BS will ignore their requests because they consume a lot of energy in the past several rounds and hence are not qualified candidates. Otherwise, BS will use (8) to calculate their T(n) and designate the candidate whose T(n) is the largest to be cluster head. Then, new cluster head will broadcast its ID number and wait for child nodes joining its cluster.

One great advantage of this mechanism is that the ex-cluster head avoids running out of its energy and still serves as a “subordinate” for the new “commander” after becoming ordinary child node. Using this intelligent mechanism, LEACH-M successfully maintains the integrity of original WSN structure within a certain period.

4 Results and discussion

In this section, we adopt a useful network simulation platform named NS-2.35 to compare the performance of our proposed LEACH-M with the existing LEACH-C [9], EE-LEACH [11], and original LEACH [5]. The main steps of simulation experiments are as follows:

  1. 1.

    Install VMware Workstation 12.0 (VM12) in Windows 7.

  2. 2.

    Run Ubuntu 16.04 in VM12 and download NS-2.35 software in Ubuntu 16.04 operating system.

  3. 3.

    Obtain the original LEACH package (mit.tar.gz) from MIT μAMPS project.

  4. 4.

    Modify the network layer codes of LEACH.

  5. 5.

    Program TCL scripts to perform simulation experiments.

  6. 6.

    Utilize Linux Shell to extract significant data from trace file and use Gnuplot to draw comparison figures.

Simulation experiments are performed under two different topology scenarios: 100 × 100m2 and 300 × 300m2. Table 2 summarizes the detailed simulation parameters.

Table 2 Detailed simulation parameters

4.1 Simulation results of a 100 × 100m2 network topology

In this section, Mis set as 100. Figure 3 shows there are 50 sensor nodes randomly distributed in a 100 × 100m2 network topology. The simulation experiments of LEACH-M include three performance standards: network lifetime, energy consumption, and number of data received at BS. Except for energy consumption, the other two indexes are evaluated by using the assessment criteria in reference [16]: first node dies (FND), half of the nodes alive (HNA), and last node dies (LND).

Fig. 3
figure 3

The distribution of 50 sensor nodes in a 100 × 100m2 network topology

As shown in Fig. 4, the number of alive nodes of four algorithms decreases over time. However, their FND, HNA, and LND vary a lot. Table 3 demonstrates that the FND, HNA, and LND of LEACH-M are 500 s, 590 s, and 650 s, respectively, which are much larger than that of LEACH, LEACH-C, and EE-LEACH. Compared with LEACH-C and EE-LEACH, LEACH-M outperforms them 16% and 28% in FND, 18% and 9% in HNA, and 14% and 8% in LND, respectively. Hence, LEACH-M can better equal the energy load and dramatically extend network lifecycle.

Fig. 4
figure 4

The comparison of alive nodes for LEACH, LEACH-C, EE-LEACH, and LEACH-M in 100 × 100m2

Table 3 The statistics of alive nodes of four algorithms in 100 × 100m2

Figure 5 shows that energy consumption of four algorithms gradually increases with time. Obviously, the total energy consumption of LEACH-M is much lower than that of LEACH, LEACH-C, and EE-LEACH all the time. Specifically, Table 4 indicates that the energy usage of LEACH in 200 s, 350 s, and 500 s is 21.59 J, 48.15 J, and 78.79 J, respectively. Compared with LEACH-C and EE-LEACH, LEACH-M reduces power consumption by 46% and 34% in 200 s, 31% and 23% in 350 s, and 18% and 15% in 500 s, respectively. Therefore, LEACH-M can lower battery consumption and raise energy utilization.

Fig. 5
figure 5

The comparison of energy usage for LEACH, LEACH-C, EE-LEACH, and LEACH-M in 100 × 100m2

Table 4 The statistics of energy consumption of four algorithms in 100 × 100m2

Figure 6 shows all of these algorithms have a climbing tendency of data received at BS. As is expected, LEACH-M has bigger packets quantity of BS, especially after 200 s. Table 5 illustrates that the data received at BS of LEACH-M in FND, HNA, and LND are 731883 bit, 753875 bit, and 762024 bit, respectively. Compared with LEACH-C and EE-LEACH, LEACH-M increases data quantity by 37% and 36% in FND, 35% and 15% in HNA, and 33% and 14% in LND, respectively. Thus, LEACH-M can provide a greater number of data received at BS whether in FND, HNA, or LND.

Fig. 6
figure 6

The comparison of received data at BS for LEACH, LEACH-C, EE-LEACH, and LEACH-M in 100 × 100m2

Table 5 The statistics of received data at BS of four algorithms in 100 × 100m2

4.2 Simulation results of a 300 × 300m2 network topology

Similar to Section 4.1, M is set as 300 to perform simulations again while maintaining all other parameters unchanged.

Figure 7 shows there are 50 sensor nodes randomly distributed in a 300 × 300m2 network topology.

Fig. 7
figure 7

The distribution of 50 sensor nodes in a 300 × 300m2 network topology

As shown in Fig. 8, the number of alive nodes of four algorithms reduces over time. Similar to Table 3, Table 6 also shows that LEACH-M outperforms LEACH-C and EE-LEACH in terms of FND, HNA, and LND. However, its FND, HNA, and LND are smaller than that in 100 × 100m2. This is because when the region becomes larger, the distance from one node to another also gets bigger. Hence, transmitting a same k-bit data message will consume more energy, which leads sensor nodes to die in advance.

Fig. 8
figure 8

The comparison of alive nodes for LEACH, LEACH-C, EE-LEACH, and LEACH-M in 300 × 300m2

Table 6 The statistics of alive nodes of four algorithms in 300 × 300m2

Figure 9 shows that energy consumption of four algorithms increases a lot along with time. Table 7 demonstrates that LEACH-M expends less energy than LEACH-C and EE-LEACH during the whole period. Nevertheless, when the range of region enlarges from 300 × 300m2 to 100 × 100m2, the total energy consumption of LEACH-M is always higher than before, whether the time is 200 s, 350 s, or 500 s.

Fig. 9
figure 9

The comparison of energy usage for LEACH, LEACH-C, EE-LEACH, and LEACH-M in 300 × 300m2

Table 7 The statistics of energy consumption of four algorithms in 300 × 300m2

Similar to Fig. 6, Fig. 10 also shows four algorithms have an increasing tendency of data received at BS. Table 8 illustrates that compared with LEACH-C and EE-LEACH, LEACH-M does receive more data at BS. However, when the area is enlarged to 300 × 300m2, the amount of data packets sent to BS becomes smaller. This is because after some nodes suffer an early death, there are less alive nodes transmitting their sensory data to BS in the whole WSN.

Fig. 10
figure 10

The comparison of received data at BS for LEACH, LEACH-C, EE-LEACH, and LEACH-M in 300 × 300m2

Table 8 The statistics of received data at BS of four algorithms in 300 × 300m2

5 Conclusion

This paper presents a modified LEACH-based cluster-head selection algorithm for WSNs. Based on DAAM of ZigBee, LEACH-M synthetically considers both remaining energy and network address to revise cluster-head threshold equation and exploits a cluster-head competitive mechanism to average the network energy load. Simulation results demonstrate that whether region is in a 100 × 100m2or in a 300 × 300m2, the proposed algorithm outperforms LEACH, LEACH-C, and EE-LEACH in aspects like network lifetime, energy conservation, and amount of data.

In the future, factors such as distance between cluster head and BS, space from a cluster member to its cluster head, and energy consumption in last round will be taken into consideration to optimize LEACH-M and to provide a more reasonable and reliable cluster-head selection.