1 Introduction

In construction engineering, agroforestry, transportation and military application, wired sensor network is widely used to monitor and measure physical phenomena (e.g., temperature, liquid level, vibration, damage, humidity, acidity, production line generator, aviation, building maintenance, etc.). However, wired sensor network has high cost in network installation, shutdown, testing, maintenance, fault location and upgrading. Therefore, WSN (wireless sensor network) is attractive. WSN is usually used in rare and dangerous remote environment where energy cannot be supplied. Researchers are constantly searching for the most suitable routing system and algorithm in WSN [13].

According to the characteristics of WSN, the scholars have proposed related routing protocols such as DD, LEACH, PEGASIS, GITDC, etc. To delay lifetime of sensor network, energy is taken as the main factor in routing protocols. With adaptability, robustness and parallelism in nature, ant has ability in finding optimal path between nest and food source [46]. The scholars have proposed routing algorithm based on ant colony to improve network equilibrium, thus reducing energy consumption and prolonging network lifetime.

With rapid development of computer technology and network, information processing and transmission have been widely applied in fields of national economy development [7]. WSN is wireless network without infrastructure. It is widely used in many fields. Combined with modern monitoring theory and WSN technology, node arrangement can realize unattended operation. It has application value, social and economic benefit. Besides, its application in personal communication and access network reflects good business prospect [8, 9]. Therefore, WSN technology has important meaning in society and potential value in economy.

Modern research of sensor network was originated from DSN (Distributed Sensor Networks) research report by DARPA (Defense Advanced Research Projects Agency) in 1980. After that, DARPA united NSF (National Science Foundation) to establish research reports of WSN. These researches opened the door of WSN, thus affecting the whole fields of human life and production. Since 21st century, sensor network has attracted attention of academia, military and industry. Developed countries such as U.S. and Europe emphasize the development of WSN. Research reports of WSN are started one after another. Especially, U.S. has invested much capital in researches of WSN through National NSFC and DOD (Department of Defense). IEEE makes great efforts to develop WSN. Recently, Boston University has established Sensor Network Consortium to promote research and development of sensor networking technology. Besides of Boston University, Sensor Network Consortium consists of BP, Honeywell, Inetco Systems, Invensys, L-3 Communications, Millennial Net, Radianse, Sensicast Systems and Textron Systems.

China and developed countries synchronously started modern WSN and its application research. As one of five major projects, application research of modern WSN was firstly found in Research Reports in the Field of Information and Automation, Research on Field Direction of Knowledge Innovation Project by Chinese Academy of Sciences in 1999. With the development of knowledge innovation project trial, micro system research and development center was established in 2001. Harbin Institute of Technology, Beijing University of Posts and Telecommunications, Tsinghua University, etc. firstly carried out sensor network research. Colleges and research institutions participated in researches of the field. WSN researches at home and abroad have little difference. As advanced technology affecting human future life, this research will be of great significance to society and economy of the whole country.

The work proposed routing algorithm in WSN based on ant colony optimization. Ant colony optimization algorithm has advantages in implementing local work, supporting multiple paths and integrating link quality into pheromone formation. These characteristics are used to design routing algorithm in WSN based on ant colony optimization.

2 Problem Description

2.1 Wireless Sensor Network

WSN consists of sensor nodes dispersed in certain geographic area. Each sensor node has wireless communication, intelligent data and network processing capabilities. WSN can be set in remote geographic position, requiring lowest establishment and management costs. Combined with internet or wireless infrastructure network, WSN is used to broaden coverage area and develop potential application fields of Ad-Hot network. Central node has functions of connecting external network gateway and distributing sensing information (See Fig. 1).

Fig. 1
figure 1

Survey of WSN

2.2 Routing Technology in WSN

At present, routing protocol in WSN is the hot spot of research at home and abroad. In WSN structure, routing protocol design in network layer is important. The work applies flooding algorithm of flat routing protocols. Flooding is the simplest routing protocol of earliest sensor network application. In flooding algorithm, any routing algorithm and network topology are not needed. In Fig. 2, Node S uses diffusion method to send a data block to Node D. Firstly, Node S sends data copy to neighbor nodes through network. After that, each neighbor node sends data copy to neighbor nodes except Node S. The process will not stop until data copy transfers to destination node D or the life span of data copy is 0.

Fig. 2
figure 2

Information transmission diagram of blooding

The disadvantages are as follows. Firstly, there is information transmission burst. Node always sends data to its neighbor nodes no matter whether neighbor nodes have received repeated data from other originating nodes. This will result in serious information transmission burst with the increase of connected node density. Secondly, overlap phenomenon occurs. Node can receive repeated data sent by nodes monitoring the same region. In addition, node receives multiple copies of the same data (implosion). Thirdly, there is resource blindness. The operation is not adjusted according to available energy in given time. Besides, adaptive routing is selected without considering available node number.

2.3 Ant Colony Algorithm

In 1991, Italian Dorigo Maniezzo firstly proposed ant colony algorithm based on research on the collective behavior of real ants. M. Dorigo et al. pointed out that ants transfer information by means of indirect and asynchronous contact. Ants use hormone as a medium. In the process of searching food, ants leave a substance called information hormone in the place where they pass. These substances are felt by ants behind, affecting their behaviors. However, information hormone gradually decays with the time. Therefore, the ants behind will leave information hormone to strengthen the original information. The path with more ants has higher possibility to be selected by ants behind. This process will not stop until the whole ants select the shortest path. M. Dorigo solved TSP by simulating food searching process of ants based on the similarity between food searching and TSP [10]. Simply, the optimal path from ant cave to food source is found by information communication and cooperation of individuals.

TSP (the shortest circuit of n cities) is analyzed to explain the implementation procedure of ant colony algorithm.

It is assumed that m ants are put in n random cities. Every step of each ant is to select the next city based on certain evidence. Meanwhile, residual information concentrations in the whole paths are updated after a step (from one city to another) or a circle (visiting of n cities). The evidences to select the next city are as follows. The first evidence is t ij (t)—residual information concentration in the path connecting City i and j at t. It is provided by algorithm. The second is the heuristic information transferring from City i to j. This information is given by problem and achieved by certain algorithm. In TSP, \(\eta_{\text{ij}}\) is expected degree from City i to j; d ij the distance between City i and j (\(\eta_{\text{ij}}\) = l/d ij ). \(p_{\text{ij}}^{k} (t)\) is the probability that Ant k in City i selects City j as destination at t.

$$p_{ij}^{k} (t) = \frac{{\tau_{ij}^{\alpha } (t)\eta_{ij}^{\beta } }}{{\sum\nolimits_{{j \in N_{i}^{k} }} {\tau_{ij}^{\alpha } \eta_{ij}^{\beta } } }}\left( {j \in N_{i}^{k} } \right)$$
(1)

where α is the effect of accumulated pheromone concentration to path selection; β relative importance of expectation; \(N_{\text{i}}^{k}\) the whole target cities; p k ij (t) the probability that ant transfers from City i to j at k. Therefore, the probability for ant to select certain city is the function of heuristic information and residual information in the path from current city to target city.

Excessive residual information covers heuristic information. Based on this, residual information is updated to weaken the old information after visiting n cities (one circuit). Meanwhile, the newest information t ij of ant visiting path is added to derive the following equation.

$$\tau_{ij} (t + n) = \rho \tau_{ij} (t) + \sum\limits_{k = 1}^{m} \varDelta \tau_{ij}^{k}$$
(2)

where ρ is reserve part of residual information; 1—ρ weakened part of residual information (ρ < 1); Δτ k ij residual pheromone concentration of Ant k from City i to j during t − (t + n).

The process of ant colony algorithm is as follows.

  1. 1.

    Initialization of A(t) {Ant colony is initialized.}

  2. 2.

    Evaluation of A(t) {fitness of each ant is evaluated based on target function.}

  3. 3.

    Release of pheromone {Pheromone is released to the path that ants pass according to fitness and certain proportion. The higher fitness is, the more released pheromone.}

  4. 4.

    Movement of ants {Ant selects path according to pheromone left by front ants and its judgment.}

  5. 5.

    Volatilization of pheromone {Pheromone continues to disperse over time.}

WSN is a network without central control. The nodes in network cooperate to complete an assignment. Failure of a single node does not affect operation of other nodes and the whole network. Ant colony algorithm has strong reliability and scalability [1113]. In the situation without central control and global model, ant colony algorithm provides basis for solution of complicated distribution problems.

3 Routing Algorithm of WSN Based on Ant Colony Algorithm

3.1 Idea of Algorithm

In data query application of WSN, sink node requires to deliver query command to the whole nodes in monitoring region [1417]. Therefore, the algorithm is used to solve the problem. Traditional blooding method can be used to spread the query to the whole network, establishing the path from sink node to monitoring region. However, routing establishment with blooding method consumes much energy. Therefore, it is important to find the optimal routing from sink node to target region. Based on ant colony algorithm, an optimal routing algorithm is proposed to complete special data query assignment of detected region.

The basic idea of algorithm is as follows. (1) Artificial traverse network nodes are used to generate the optimal routing from sink to target node. (2) Local search of ants is conducted to establish routing with an incremental method. (3) Tentative information is used to guide search of each ant, achieving data gathering. (4) Global network state is not maintained by sensor nodes. (5) It is not necessary for ant to transverse the whole nodes in node topology graph. Therefore, the algorithm has better flexibility. Test results show that new routing algorithm has good performance.

Based on location information of nodes in monitoring region, ant colony optimization routing algorithm is used to establish optimal routing from monitoring region to sink node. Therefore, flooding propagation mode is avoided to reduce network energy consumption.

Firstly, the algorithm is assumed as follows in WSN.

  1. 1.

    The initial energy of each node is equal, and the energy is finite.

  2. 2.

    Each node has the ability to perform certain information processing.

  3. 3.

    Each node has a unique ID number.

  4. 4.

    For each node, omnidirectional antenna is used to provide certain communication range.

  5. 5.

    There is no one-way link between nodes. Nodes A and B can mutually communicate with each other.

It is assumed that each sensor node can obtain its own coordinate information by GPS. Each node maintains a coordinate table of neighbor node. The node updates information in table by periodically exchanging few data with neighbor node. When the energy of node is lower than certain value, then the communication distance between the node and the neighbor node will be the maximum of settings. When voltage is less than 2.7, the node will not work normally. Therefore, part of the energy is conserved to satisfy data collection. It is considered that the energy consumed by data transmission is proportional to the square of physical distance. Meanwhile, voltage cannot change linearly. A function is introduced into routing algorithm. When node voltage tends to threshold, then communication distance will change very fast. The topology structure of sensor network can be seemed as an Undirected Graph G = (V, E), where V is vertex set consisting of the whole sensor nodes; E edge set consisting of the whole links. It is assumed that Graph G is connected according to denseness of sensor network nodes. The following definitions are given.

  1. 1.

    Neighbor nodes

If Nodes a and b are within effective communication range of both sides, then they are called neighbor nodes.

  1. 2.

    Physical distance

It is denoted that Nodes a and b are adjacent. Then the actual distance from a to b is called physical distance. Physical distance is expressed as Eq. (3).

$${\text{L}}{<}{\text{a,b}}{>} = {\text{sqrt}}\left( {\left( {a \cdot x - b \cdot x} \right)^{2} + \left( {a \cdot y - b \cdot y} \right)^{2} } \right)$$
(3)

where a(x, y) and b(x, y) are the coordinates of Nodes a and b, respectively.

  1. 3.

    Threshold voltage

Threshold voltage is the minimum voltage value that enables the sensor to work properly.

  1. 4.

    Communication distance

It is denoted that Nodes a and b are adjacent. Then WL <ab>  is communication distance between a and b.

$$WL {<}a,b{>} = K*(L {<}a,b{>})^{2}$$
(4)

where K is coeffcient of proportionality.

$${\text{K}} = 1/\left( {V_{0} - V_{\hbox{min} } } \right)$$

where V 0 is current operating voltage value of sensor (initial value = 3 V); V min threshold voltage (initial value = 2.7 V). When system works, V 0 will be voltage value of wireless sensor node sent to sink node at regular time.

In Eq. (2), the energy consumed by information transmission is proportional to distance between nodes, considering convergence speed of K value.

Node energy of WSN is finite. It is assumed as follows. If node voltage is less than threshold voltage, then node will not transfer data properly.

Position coordinates sent by the whole nodes are stored in database. Equation (4) is used to calculate and update communication distance between any two nodes within prescribed time. It the node is not updated within limited time, then it will be unreached. The communication distance from any node to this node is set as a maximum constant.

  1. 1.

    After circle starts, the maximum cycle time is set.

  2. 2.

    The whole ants traverse network nodes in proper order.

  3. 3.

    The next node is selected according to Eq. (1).

  4. 4.

    The current node is added in tabu list.

  5. 5.

    If current node is target node, then the next ant will start to traverse.

  6. 6.

    After calculating path length of each ant, the optimal solution is stored in a global variable.

  7. 7.

    Pheromone is updated in the path each ant passes through according to Eq. (2).

  8. 8.

    Repeat Step 3, until the results are output.

3.2 Improvement of the Algorithm

Since Ant Colony Routing Algorithm is abstracted from artificial ants, so it doesn’t have capacity and efficiency of real ants in solving practical problems. As a new type of algorithm, Ant Colony Routing Algorithm is not very mature in research, without complete solid mathematical basis like genetic algorithm and simulation algorithm. There are many shortcomings and problems to be improved as below:

  1. 1.

    Slow solving speed at the beginning of the algorithm In the initial stage of the algorithm, ants’ search shows serous blindness because the concentrations of pheromone on each path are similar. Only after a long period of time, the concentration of pheromones shows a significant role in guiding.

  2. 2.

    Resource management issues Ant Colony Routing Algorithm is flat routing protocol, which lacks network management node and optimization management in communication resources. These shortcomings are not conducive to improving the energy consumption level.

  3. 3.

    As a positive-feedback algorithm, ant colony has faster convergence speed, but easily becomes local optimization. In ant colony system, the initial information of each path is the same, and the information used to find the first path is the distance information between each node. In this case, the ant colony algorithm is similar to greedy algorithm, and the pheromone left in ant colony’ path cannot necessarily reflect the optimal path. It is determined by heuristics information. In particular, for colony with smaller number of individuals or more combinations of paths, the algorithm cannot guarantee that the first path found will guide ant colony to the optimal solution. In this cycle, the left pheromone will mistakenly make this path as the dominant information due to positive feedback, thus limiting the final ants to find the optimal solution.

  4. 4.

    Stagnation problem The problem is similar to the fast convergence of algorithms: during the steps of the algorithm, ant colony may occur in stagnation around some local optimal solution after a certain number of cycles. And pheromones have been repeatedly enhanced in this area, so ants are difficult to leave this area. Even if they leave this area, it will increase network latency and the number of cycles, reducing the performance of the algorithm.

Some supplementary rules and methods can optimize and improve the global search ability and solving speed of ant colony algorithm. The main improvements and optimization methods are partition solution, the introduction of self-adaptive evaporation coefficient, maximum and minimum ant colony algorithm, variation of genetic algorithm and hybrid algorithm [18, 19]. These methods have enabled colony algorithm to overcome the shortcomings while keeping some advantages of its own, with fast convergence and robustness. Under the consideration of the residual energy in the chosen path, the path with largest average energy is regarded as the optimal path [20]. However, these algorithms do not take into account the energy consumption at the nodes of selected transmission path. Simple pursuit of maximum average residual energy will result in longer path, more nodes of transmission and excessive energy consumption during information transmission.

To solve this problem, this work proposes a multi-population ant colony optimization routing algorithm (O_ARA). The algorithm designs a selection probability model of ants’ forward movement, with the balanced consideration of transport energy consumption and node energy. It can proportionate network consumption and extend network lifetime [21, 22]. Network congestion and stagnation can also be effectively solved by obtaining multiple optimal paths.

In O_ARA, the ant k in population m rules determines which node to move next, according to below selection rules of probability behavior. In particular, the probability of ant k at node i selecting node j as the access node is:

$$P_{ij}^{k} = \lambda_{1} \left[ {\tau_{ij}^{m} } \right]^{\alpha } \left[ {\eta_{ij} } \right]^{\beta } /\sum\limits_{{l\; \in \;allow_{i}^{k} }} {\left[ {\tau_{ij}^{m} } \right]}^{\alpha } \left[ {\eta_{ij} } \right]^{\beta } + \lambda_{2} \left[ {\tau_{ij}^{m} } \right]^{\alpha } \left[ {E_{ij} } \right]^{\beta } /\sum\limits_{{l\; \in \;allow_{i}^{k} }} {\left[ {\tau_{ij}^{m} } \right]}^{\alpha } \left[ {E_{ij} } \right]^{\beta }$$
(5)

where τ m ij is the pheromone concentration node of population m at the edge of node I and node j; η ij heuristic information of transmission energy consumption. The energy consumption is mainly related to the square or the biquadratic of the distance. Therefore, heuristic information of node energy consumption is defined as follows:

$$\eta_{ij} = \left\{ {\begin{array}{*{20}l} {1/{\text{d}}_{ij}^{2} ;d_{ij} < d_{0} } \hfill \\ {1/d_{ij}^{4} ;d_{ij} < d_{0} } \hfill \\ \end{array} } \right.$$
(6)

As the heuristic information of node quantity, E ij  = 1/C + e j , where C represents the initial energy of nodes; e j the remaining energy of node j; parameters α and β adjustable weight of pheromone concentration and heuristic information. For the ant k, smaller d 2 ij and d 4 ij (smaller node energy consumption), and larger (greater residual energy node) mean the greater value of \({\text{p}}_{\text{ij}}^{k}\). With two different angles, the two heuristic functions express the expected degree of ants moving from node i to j.

Through flexible use of routing strategy, this model tries to find a path with the minimum energy consumption and maximum residual energy in transmission, prolonging the lifetime of the whole network.

\(allow_{\text{i}}^{k}\) represents the addressable neighbor nodes of ant k at node i. Node j stratifying the following three requirements belongs to \({\text{allow}}_{i}^{k}\): (1) within the effective communication range of node i; (2) node j has not been accessed by ant k; (3) node j is farther from source node than node i, but closer to the destination node.

Third requirements mentioned are mainly used to control the direction of ants’ movement, so ants can move closer and quickly reach the destination node, accelerating the convergence speed. λ 1 > 0, λ 2 > 0 and λ 1 + λ 2 = 1.

3.3 Algorithm Description

O_ARA ACO strategy is proposed by the constructed probability model of ant forward movement. The steps are as follows:

m populations of ant are placed in the source node, with n ants in each population. Ants of different populations are different, and ants of one population are the same ant. At set intervals, different populations of ants start to move and search a path to the destination node. Each ant needs to carry the information including ID number of the source nodes, ID number of the intermediate nodes, the average residual energy of the intermediate nodes, the minimum residual energy of intermediate nodes and the distance between the intermediate nodes.

When the ant at node i accesses the next node, its pheromone is unique in the population. Pheromone of different populations released through the node is different, and some populations of ants select the next access node only based on their pheromone. After reaching the next node, the local update of the population pheromone will be conducted in accordance with following rules:

$$\tau_{ij}^{m} \leftarrow (1 - \xi )\tau_{ij}^{m} + \xi \tau_{0}$$
(7)

where ξ and τ 0 are two parameters; ξ meets 0 < ξ < 1; τ 0 the initial value of the pheromone. When the ant reaches the destination node, the information carried are stored in the destination node to select and record the optimal path; ants are sent out on the optimal path, and the global update of pheromone will be conducted according to the following rules:

$$\tau_{ij}^{m} \leftarrow (1 - \rho )\tau_{ij}^{m} + \rho \Delta \tau_{ij}^{m} ,\quad \forall (i,j) \in T^{bs}$$
(8)

where \(T^{\text{bs}}\) is optimal path; \(\Delta \tau_{\text{ij}}^{k} = 1/C^{bs}\) the pheromone increment; C bs the length of the optimal path; parameter ρ the pheromone evaporation rate.

When the ants return to the start point, the second batch of ants will be sent out until meeting the stop condition. Each population can finally get an optimal path, and multiple populations get multiple optimal paths.

As wireless sensor network nodes are prone to break down, multi-path transmission can improve the reliability of data transmission. In the optimization program, different species of ants are independently routed with each other, thus improving network reliability.

4 Simulation Example

4.1 Simulation Test of Wireless Sensor Network Routing Algorithm Based on Ant Colony Algorithm

For WSN, there is no unified standard to evaluate different routing protocols at present. According to actual situation, the following parameters are used to evaluate the effect of routing protocol of WSN based on ant colony algorithm.

  1. 1.

    Average energy consumption

Average energy consumption is the average of consumed energy that each sensor node sends data packet to sink node. It is an important indicator reflecting algorithm energy efficiency. For the whole network of data, the ratio of energy consumption and transmitted data amount is also an important indicator reflecting algorithm energy efficiency.

2. Average delay

Average delay is the ratio of the whole hop number and transmitted data amount for valid data transmission.

The equation of the algorithm involves parameters set according to experiences and situation in the work. For each wireless sensor node, the initial energy is 5 J; energy threshold 0.5 J. Data packet transmitted in network layer has a size of 32 bytes. In pheromone equation, ρ is set as 0.3. If residual node energy is larger than energy threshold, α and β will be set as 1 and 0.01; otherwise, α and β as 0.01 and 0.01, respectively. If one data packet passes through node link, then pheromone concentration will increase by 0.02. If residual energy of neighbor node is less than energy threshold, then pheromone concentration of the node link will decrease to 0.1 times the initial value. Then, volatility coefficient is 0.1. Sink node broadcasts Ant Packet query information every 10 s in network. After that, 20 source nodes are randomly selected from the whole nodes to send data to sink node.

To compare the performance of algorithms, Directed Diffusion routing protocol is introduced as a data-centric routing protocol, which is a different implementation mechanism from the existing routing protocol. With the introduction of gradient, it describes the possibility of continuing search in this direction and obtaining matching data for intermediate network node.

Directed diffusion routing protocol is introduced for performance comparison of algorithms. This data-centered routing protocol has different implementation mechanism with presented protocols. Gradient is introduced to describe the possibility that intermediate node obtains matched data by continuous searching in this direction.

ARA, DD and Flooding algorithms are simulated to derive simulation data and comparison graph. Figure 3 is simulation data of average energy consumption in different network scales. The results are the averages of 30 operations for each algorithm in different network scales.

Fig. 3
figure 3

Average energy consumption

In Fig. 3, average energy consumption of DD is half that of Flooding algorithm. ARA has smallest average energy, which is 85 % of DD. Besides, ARA algorithm has longest life cycle of node and network, achieving design goals including energy consumption reduction, energy efficiency enhancement and network life cycle maximum.

Figure 4 shows average delay of data packets received in different network scales by three algorithms. Each network scale runs for 30 times. In Fig. 4, Flooding has largest average delay. Average delay of DD is smallest. This is because data packets are sent to sink node along the shortest path with largest gradient in DD algorithm. DD algorithm has optimal average delay. Average delay of AR is slightly larger than that of DD. In routing selection by ARA, the shortest path is selected, considering residual energy of node. In addition, the next hop is selected according to certain probability. Therefore, data packets transfer along different paths, thus causing uncertainty of routing selection and increase of delay.

Fig. 4
figure 4

Average time delay

With the increase of network scale, average energy consumption of ARA slightly increases; that of DD slightly decreases; that of Flooding obviously increases. For average delay, DD is optimal. Average delay of ARA slightly increases with the increase of network scale. Flooding has largest average delay proportional to network scale. Therefore, routing algorithm of WSN based on ant colony algorithm has good scalability in network scale and performance in average energy consumption and time delay.

4.2 Simulation Comparison of Optimized Ant Colony Algorithm

Figure 5 is the simulation results of O_ARA and ARA arithmetic average energy consumption under different network size (number of nodes), which is obtained by taking the average of 30 times of results under different network size. From the figure, the improved Ant Colony Routing Algorithm has relatively less average energy consumption that basic arithmetic. Its energy consumption is less than ARA algorithm because ARA finds the shortest path, but the shortest route doesn’t necessarily have the minimal energy consumption. Therefore, O_ARA algorithm considering the balance between energy consumption and node residual energy has less average energy consumption.

Fig. 5
figure 5

Average energy consumption

Figure 6 is the comparison of two algorithms on their average delay of receiving packet all under different size of network. In the figure, the improved Ant Colony Routing Algorithm has smaller average delay than basic Ant Colony Routing Algorithm. This is because the improved one adopts the strategy of controlling the moving direction of ants. The ants move closer toward the destination node, accelerating the convergence speed.

Fig. 6
figure 6

Average time delay

4.3 Results of Ant Colony Optimization Algorithm

Figures 7 and 8 is the simulation experiment graph obtained by optimization algorithm, drawing the shortest path map, the length of the shortest path of each cycle and average length of the path. Experiments show that this algorithm meets the basic ideas of ant colony count algorithm, with fine operation. It is a new way of optimization for wireless sensor network routing algorithm. Simulation result shows that the optimization greatly improves the global search capability of basic ant colony algorithm, accelerating the speed of obtaining optimum solution. In favor of the application and expansion of ant colony algorithm, it is more suitable for some complex environment, ensuring real-time, stable and reliable monitoring of environmental data collection and transmission.

Fig. 7
figure 7

Length of the shortest path of each cycle and average length of the path

Fig. 8
figure 8

Optimal path

5 Conclusions

Based on routing protocols of WSN, the work designs routing algorithm of WSN based on ant colony optimization. The algorithm establishes and updates pheromone concentration of gradient field and path by broadcasting messages and exchanging hops between neighbor nodes in the whole network. Gradient is integrated into formation and updating of pheromone. After that, the next hop is selected by calculating the corresponding probability of neighbor nodes. Routing is selected by considering shortest path and residual energy.

In routing maintenance process, data are transferred to increase pheromone concentration in the path, simulating volatilization process of pheromone. Therefore, energy consumption of the whole network is more average while data packet is sent along the shortest path. Consequently, lifetime of network is effectively prolonged. Besides, the control of special regions cannot be lost because of rapid death of nodes in shortest path.