1 Introduction

Wireless sensor networks (WSNs) are composed of a number of static or mobile sensor nodes. These nodes transmit sensory data between users under a self-organizing network communication protocol. Such networks are usually employed for environmental monitoring, military detection, and other specific tasks [1]. Nodes in WSNs have a one-time power supply, so energy is the primary factor in determining the network lifecycle [2].

The study of routing protocols is an important direction in the energy-saving research related to WSNs. To this end, ant colony optimization (ACO), a class of heuristic evolutionary algorithms that conduct efficient random searches [3], has the advantages of self-organization, positive feedback, and parallelism, and has shown good performance in solving the dynamic routing problem for WSNs [4]. A multiple Quality-of-Service (QoS) guarantee ASAR (Ant-colony optimization based Service Aware Routing) routing algorithm has been proposed in which the corresponding weighting factor is set by the weighted average network QoS parameters and the route is selected using ACO [5]. Zhu et al. design an ACO-based routing algorithm framework by constructing artificial ants, and experimentally demonstrate that this results in accelerated convergence [6]. The EEABR (energy efficient ant-based routing algorithm) algorithm [7] optimizes the network energy consumption by reducing the memory and improving the pheromone increment of the ants. Tong et al. [8] propose a modified energy-efficient routing algorithm known as IEEABR, which uses an improved ant packet structure, probability formula, and pheromone updating procedure. The above algorithms are innovative in certain ways, but they do not consider the real-time energy level of the transmission path, path management, and maintenance overhead of routing. To overcome these problems, this paper proposes the ACO Energy Aware (ACOEA) routing algorithm, which is based on ACO and the energy awareness of WSNs. The angle factor between the source node, the next-hop node, and the sink node is used to improve the path transition probability formula in the ant colony algorithm, enabling the transmission hop count of the path to be optimized. Using previous research [9] alongside the proposed algorithm, the ants can obtain multiple better transmission paths when searching. On this basis, a path decision model is established. The multipath routing helps balance the network load and energy consumption. Additionally, during network operation, a repair ant is defined to strengthen the transmission path by replacing nodes in the path whose energy is lower than some threshold with nodes that retain abundant energy. Thus, the energy of the network can be balanced and the network lifecycle can be prolonged.

The main contributions of this paper are as follows:

  1. 1.

    Less energy consumption have been ensured by using the angle factor between nodes when modifying the ant colony optimization.

  2. 2.

    The modified ant colony optimization is used to find multiple paths which are energy efficient.

  3. 3.

    Refer to the previous research, the multipath formation rules are introduced which can share the transmission burden of the optimal path.

  4. 4.

    The advantages of both determining the current optimal network routing and balancing the energy consumption have been ensured by establishing the path decision model.

  5. 5.

    A repair ant is used to strengthen the transmission path according to the remaining energy of the nodes.

  6. 6.

    The performance of ACOEA has been analyzed by comparing the performance with state of art routing methods EEABR and IEEABR by using NS-2 simulations in two metrics, energy consumption and lifetime of the network.

This paper is organized as follows. Section 2 presents the path decision model and the summary of main symbols. In Sect. 3, detailed description and components of the proposed routing algorithm ACOEA are given. In Sect. 4 simulation results are presented and effectiveness of our work is evaluated. Conclusions and future works are given in Sect. 5.

2 Model of Multipath and Summary of Main Symbols

In this section, we propose the path decision model which is helpful to balance the energy consumption of the network, and summarize the main symbols used in this paper.

2.1 Path Decision Model

In WSNs, a failure to consider the remaining energy levels of nodes during routing will result in the premature death of some low-energy nodes, leading to interruptions in communication. Eventually, this will cause the uneven distribution of network energy and seriously degrade the survival time of the network. Considering the above, and according to the energy of nodes, we propose the path decision model which makes the source node can choose the most suitable path to transmit data.

Definition 1

Least Energy (LE): Let LE(r, i, t) express the energy of node i, which has the minimum rest energy in path r at time t:

$$LE(r,i,t) \in LES(t) = \{ LE(r,i,t)\left| {LE(r,i,t)} \right. \le E(r,j,t),r \le k,j \in N(r)\}$$
(1)

where K is the total number of selected paths from the source node to the sink node using the ant colony algorithm, LES(t) is the set of all minimum rest energy nodes of all paths at time t, N(r) is the set of all nodes on path r, and E(r, j, t) expresses the rest energy of node j, which belongs to path r, at time t.

Definition 2

Path Selection Probability (LER): The selection probability of a path according to the energy levels of all paths is expressed as follows. Let LER(r, t) express the relative probability of selecting path r as the current transmission path at time t:

$$LER(r,t) = 1 - \frac{VE(r,t)}{{\sum\nolimits_{r = 1}^{k} {VE(r,t)} }}\quad \left( {LE(r,i,t) \ne \hbox{min} (LES(t))} \right)$$
(2)

where VE(r, t) is the variance of the rest energy of nodes in path r at time t. Meanwhile the selected path cannot include the node which has the minimum rest energy in LES(t).

2.2 Meaning of Main Symbols

In order to understand the paper better, the main symbols used in this paper and their meanings are summarized in Table 1.

Table 1 Symbols used and their meaning

3 ACOEA Routing Algorithm

To reduce energy consumption and prolong the lifecycle of a network, we propose the ACOEA routing algorithm. In this section, the detailed description of the proposed algorithm and its components are explained below.

3.1 Network Model

Combined with the characteristics of ACO, a WSN is abstracted as a weighted undirected graph G = <V, A>, V = {V0,V1,…,VN−1,VN}, where V is the set of nodes in the network, V0 is the source node, VN is the sink node, and A is the set of (weighted) edges. In the proposed method, A represents the ants’ pheromone. Every node has a unique ID and its own energy, network location, and communication radius. The purpose of the modified ant colony optimization is to search for multiple better transmission paths from V0 to VN in graph G.

3.2 Routing Initialization

During the routing initialization stage, the sink node broadcasts its network location to the entire network. Other nodes broadcast their own ID and network location over a single hop. Each node builds a neighbor node table, and records their network location using the received radio information.

3.3 Multipath Routing Formation Based on ACO

Though there has been a successful study of the backup route [10], but it is not very suitable for the ACO. So we form the multipath in another way. In this algorithm, the ants are divided into three groups: (1) the search path ants that are sent by the source node; (2) the back-off ants that return from the sink node to the source node; and (3) the repair ant that conducts routing maintenance.

  1. 1.

    There are m ants starting from the source node. They select the next hop node according to the transition probability given in Eq. (3), and record the remaining energy of the selected node.

    $$P_{ij}^{a} (t)\left\{ {\begin{array}{*{20}l} {\frac{{[T_{ij} (t)]^{\alpha } \cdot [\eta_{ij} (t)]^{\beta } }}{{\sum\nolimits_{s \in N\left( i \right)} {[T_{is} (t)]^{\alpha } \cdot [\eta_{is} (t)]^{\beta } } }},} & {j \in N(i)} \\ {0,} & {otherwise} \\ \end{array} } \right.$$
    (3)

    where P a ij (t) is the probability that ant a selects node j as its next hop node at time t when it is currently at node i; N(i) is the set of neighbor nodes of node i; T ij (t), η ij (t) are the pheromone concentration [11] and heuristic value of the link between nodes i and j at time t, respectively; α is the pheromone weight; and β is the heuristic value weight. We set α = 1 and β = 2. To reduce the energy consumption and optimize the path performance, the angle factor between the source node, the next-hop node, and the sink node is used to improve η ij (t). We select the node that forms the largest angle between sink and source node as the next hop node. A diagram of the angle factor is given in Fig. 1.

    Fig. 1
    figure 1

    Angle factor between nodes

Definition 3

Angle factor θ ijs : \(\theta_{ijs} = arc\frac{{a^{2} + b^{2} - c^{2} }}{2ab}\), where the length of edges a, b, c can be calculated from the node coordinates.

By considering the distance attribute, we can write:

$$\eta_{ij} (t) = {\raise0.7ex\hbox{${\left( {\theta_{ijs} } \right)^{{\lambda_{1} }} }$} \!\mathord{\left/ {\vphantom {{\left( {\theta_{ijs} } \right)^{{\lambda_{1} }} } {\left( {d_{ij} } \right)^{{\lambda_{2} }} }}}\right.\kern-0pt} \!\lower0.7ex\hbox{${\left( {d_{ij} } \right)^{{\lambda_{2} }} }$}}$$
(4)

where λ 1 and λ 2 are the weight coefficients for the angle factor and the distance factor. These parameter weights must be adjusted to adapt to different network environments.

  1. 2.

    From source node to sink node, the multipath formation rules applied to the same batch ants are as follows:

    First step: If the entry link of the newly received search path ant is not the same as that of the ants in the access list of the current node, as long as d new  < d (d new is the delay of the newly received search path ant, d is the delay of the same kind of ant in the ants access list of the current node), the newly received search path ant can be accepted.

    Second step: If the entry link of the newly received search path ant is the same as that of the ants in the access list of the current node, then we check whether the first hop of the two ants is the same. If it is not, as long as d new < d, the newly received search path ant can be accepted.

    Third step: If the entry link and the first hop of the newly received search path ant are the same as that of the ants in the access list of the current node, as long as H new < H (H new is the hop count of the newly received search path ant, H is the hop count of the same kind of ant in the ants access list of the current node), the newly received search path ant can be accepted.

    Fourth step: If none of the above is satisfied, the current node discards the newly received search path ant.

The same kind of search path ant can be forwarded to the next hop if it satisfies the above rules. To search more paths, remaining links that have not forwarded search path ants are selected successively to receive ants using the transition probability formula.

  1. 3.

    When the same batch of ants arrives at the sink node, we obtain the multiple paths from source node to sink node. The sink node then converts the search path ants to back-off ants, and the back-off ants return to the source node along their original paths. In the process of returning, the back-off ants update the path pheromone concentration according to Eq. (5) and Eq. (6), causing every node in the path to generate a routing table that includes the newest pheromone. The back-off ants also record the remaining energy of all nodes along their paths.

    $$T_{ij} (t + 1) = \rho T_{ij} (t) + \varDelta T$$
    (5)
    $$\varDelta T = Q\left( {\frac{{\lambda_{3} }}{hop(r)} + \frac{{LE(r,u,t)\lambda_{4} }}{E}} \right)$$
    (6)

    where T ij (t) is the pheromone concentration between nodes i and j at time t, ρ is the evaporation factor, ΔT is the pheromone concentration increment, Q is a constant, hop(r) is the hop count from the source node to the sink node, E is the initial energy, and λ 3 , λ 4 are weight coefficients. After updating the pheromone concentrations along the multipath, the routing table of each node can be optimized and updated. Thus, when the back-off ants reach the source node, the routing optimization has been finished once. The back-off ants are then terminated by the source node. At the same time, new search path ants are generated by the source node for a new round of path searching and optimization.

By the above method, after finishing the number of iteration specified, multiple better transmission paths are obtained from the source node to the sink node. When the current transmission path fails, data can be sent through other paths. Thus, the load and energy consumption of the network achieve a better balance.

3.4 Multipath Decision

When the source node wishes to send data to the sink node, it is important to choose the best path for data transmission according to the different energy levels of the nodes. This will improve the transmission efficiency and balance the energy consumption of the network. Thus, based on the energy awareness of the nodes and paths, the path decision model is used to select path r, which has the largest LER(r,t) value given by Eq. (2), as the current transmission path.

3.5 Routing Maintenance

Regularly executing the routing algorithm to update the network paths will consume a considerable amount of energy [12]. However, an adaptive strategy of routing updating and maintenance can overcome this problem [13]. Hence, we use a repair ant to update and maintain the routing.

The source node sends a repair ant after it has sent N data packets. The repair ant selects a path to the sink node at random according to the selection probability in Eq. (7):

$$P\;(i,j) = \frac{{\left[ {T(i,j)} \right]^{\varphi } }}{{\sum\nolimits_{s \in N(i)} {\left[ {T(i,s)} \right]^{\varphi } } }}$$
(7)

where P(i,j) is the random selection probability, and we set φ = 2. The repair ant records the remaining energy of all nodes along its path, and judges whether LE(r, i, t) is less than E min (a pre-set energy threshold of the nodes). If so, the path is defined in the state of energy bottleneck. The repair ant replaces the problem node with one of its neighbor nodes that has abundant remaining energy. Otherwise, the repair ant reaches the sink node and calculates the newest pheromone concentration, then returns to the source node with the pheromone concentration increment. On the way back, it performs the same function as the back-off ants, updating the pheromone concentration. When the repair ant reaches the source node, it is also terminated. After the repair ant has completed its journey, paths containing energy bottlenecks can be repaired and the routing can be updated so as to maintain an optimal state. Thus, the energy consumption is balanced and the lifecycle of the network is prolonged.

4 Simulation Results and Analysis

To test the validity of the proposed algorithm, we use the well-known NS-2 simulator. The ACOEA algorithm is compared with the EEABR and IEEABR algorithms. Because the most important QoS issues while designing routing protocols for WSN are energy and network lifetime, so the two metrics are used to compare the performance of the algorithms: the energy consumption of the network, which gives the average energy consumption of all nodes in the network at the end of the simulation, and the lifetime of the network, which is expressed as the time at which the first node dies and the number of live nodes remaining in the network. To better understand the differences between the three algorithms, two distinct scenarios are used. Scenario 1 assumes a simulation area of 800 m × 600 m and 100–500 sensor nodes. In scenario 2, the simulation area is 600 m × 600 m and there are 300 sensor nodes. The sink node is located in the center of the simulation area, and the other nodes are deployed in a random fashion. The initial energy of every node is 2 J and the data packets contain 256 bytes. The simulation time is 200 s and the MAC layer uses the IEEE 802.11 protocol.

4.1 Energy Consumption of the Network

As shown in Fig. 2, as the number of nodes increased, the ACOEA algorithm achieves an obvious advantage in terms of the average energy consumption of the network. Under scenario 2, as shown in Fig. 3, when the simulation finishes, the ACOEA algorithm has consumed 47 and 29 % less energy than the EEABR and the IEEABR algorithms, respectively. This significant reduction is because the ACOEA algorithm considers the angle factor between nodes when selecting the next hop. This optimizes the hop count of the paths and reduces energy consumption. Compared with regularly performing the routing algorithm to update the network path list, the adaptive strategy of routing updating and maintenance using the repair ant can further reduce the energy consumed by the network.

Fig. 2
figure 2

Average energy consumption of the network with respect to the number of nodes in scenario 1

Fig. 3
figure 3

Average energy consumption of the network with respect to the simulation time in scenario 2

4.2 Lifecycle of the Network

As shown in Fig. 4, the time of death of the first node under the ACOEA algorithm is after approximately 120 s. In scenario 2, illustrated in Fig. 5, the ACOEA algorithm has 15 and 10 % more nodes alive at the end of the simulation than the EEABR and IEEABR algorithms, respectively. This shows that the ACOEA algorithm’s path decision model, which considers the energy level of paths when transmitting data and replaces low-energy nodes along paths, produces a better balance in the network, effectively prolonging the network lifecycle.

Fig. 4
figure 4

Time of death of the first node in the network with respect to the number of nodes in scenario 1

Fig. 5
figure 5

Time of death of the first node in the network with respect to the simulation time in scenario 2

5 Conclusions and Future Works

In this paper, we have described the application of ACO to the routing problem in WSNs. An optimized ant-based routing algorithm is proposed, and several improvements inspired by the features of WSNs (low energy levels, low processing and memory capabilities) are considered and implemented. The resulting routing protocol, called ACOEA, optimizes the ant colony algorithm in terms of the angle and distance between nodes to obtain multiple better transmission paths. After considering energy levels of paths and nodes, a path decision model is built and a repair ant is employed to implement the adaptive strategy of routing updates and maintenance. The simulation results in this paper show that the proposed algorithm produces good results in different WSN scenarios. Our method achieves good performance in terms of the energy cost and energy balance, and is of vital significance in prolonging the lifecycle of the WSN.

In future work, we intend to study an algorithm that combines ACO with other techniques to solve the routing problem in WSNs more efficiently and optimize the network performance.