1 Introduction

Wireless sensor network (WSN) has many characteristics, such as low power consumption, low cost, self-organization, distribution, and small size, and has broad application prospects [1, 2]. The wireless sensor network can determine the location of the event, which is its most basic function. Moreover, its location information is very important for the monitoring activities in the whole wireless sensor network, and the monitoring data without location information is always meaningless [3, 4]. Therefore, the fast and accurate location on sensor nodes plays an important role in various applications, and its location technology has become a research hotspot in the field of wireless sensor networks [5, 6].

The researches on the location methods for wireless sensor network node mainly focus on the location algorithm based on distance measurement and the location algorithm without distance measurement. Among them, the location algorithm based on distance measurement needs additional hardware to support the distance measurement between nodes [7, 8]. Compared with the location algorithm based on distance measurement, the location algorithm without distance measurement does not need external hardware, and the cost of network nodes is low. Only through the known location information of the beacon nodes and the connectivity between nodes in the whole network, the location information of unknown nodes can be estimated. Therefore, the location method without disturbance measurement has been paid more and more attention.

Among them, distance vector hop (DV-Hop) algorithm is a typical node location algorithm without distance measurement, which is simple and widely used [2, 9]. At present, the researches of the DV-Hop algorithm are mainly to improve the shortcoming in one aspect to a certain extent, so as to achieve the purpose of improving the location accuracy of nodes. In [10], the concept of the distance correction factor is introduced to modify the estimated hop distance of unknown nodes, so as to reduce the distance error. In [11], an improved algorithm based on the combination of shuffled frog leaping algorithm (SFLA) and particle swarm optimization (PSO) algorithm is proposed, which can effectively improve the positioning accuracy, but it becomes more difficult to use two large-scale optimization algorithms. In [12], the mean of the minimum and maximum average hop distance of all beacon nodes in the network is regarded as the average hop distance of the whole network, and the unknown nodes are finally located by bacterial foraging optimization (BFO) algorithm, which can effectively improve the positioning accuracy when the sensor nodes are irregularly distributed. In [13], a new method for calculating the average hop distance is proposed, and the percentage error is used as the reference of the weighting coefficient to calculate the average hop distance of unknown nodes, which improves the positioning performance.

In order to solve the problem that the traditional DV-Hop location algorithm has a large error in locating unknown nodes, this paper proposes an improved DV-Hop algorithm based on dual communication radius. By adding a communication radius, the algorithm updates the minimum hop number obtained by the unknown node closer to the beacon node to a smaller hop value and keeps the minimum hop number information of unknown nodes farther away. This method reflects the gap between the actual distances in terms of hop number, which solves the problem of the large difference between the actual distances of the same hops to a certain extent. Therefore, it is more advantageous to estimate the more accurate average jump distance and can calculate the more precise distance between them and obtain the more precise coordinates of unknown nodes. The improved algorithm improves the location accuracy and stability compared with the traditional DV-Hop location algorithm.

2 Principle and error analysis of traditional DV-Hop location algorithm

2.1 The Principle of Traditional DV-Hop Location Algorithm

The DV-Hop algorithm is one of a series of distributed location algorithms called Ad Hoc Positioning System (APS) based on distance vector routing [14, 15]. The DV-Hop algorithm is the meaning of “distance vector routing”. As the name implies, the DV-Hop algorithm is a location mechanism of distance vector hop.

DV-Hop location algorithm can be divided into the following three stages.

2.1.1 The First stage: the distance vector exchange

Through the step of distance vector exchange, all nodes can get the minimum hop information with respect to beacon nodes. That is to say, at the beginning of positioning, the beacon node transmits the data packets containing its own information to the unknown nodes in the network in the way of flooding. This information includes the ID of the beacon node, the coordinates of the beacon node, and the hop value between the beacon node and the receiving information node.

2.1.2 The second stage: the correction and broadcasting of the estimated average hop distance

After the location of the beacon node is known, the average hop distance between the beacon nodes is estimated by using the hop information with respect to other beacon node obtained in the first stage. The average hop distance of beacon node i is shown in Eq. (1):

$$ {\mathrm{HopSize}}_i=\frac{\sum \limits_{i\ne j}\sqrt{{\left({x}_i-{x}_j\right)}^2+{\left({y}_i-{y}_j\right)}^2}}{\sum \limits_{i\ne j}{h}_{ij}} $$
(1)

The coordinates of beacon node i are (xi, yi), the coordinates of beacon node j are (xj, yj), and hij is the minimum hop between beacon nodes i and j (i ≠ j). After calculating the average hop distance of the beacon node, it will carry out flood broadcast again in the network. Moreover, the unknown node will only receive the first received data, take the average hop distance as its average hop distance, and no longer use and retain all the subsequent corrections, in order to ensure that the average hop distance is transmitted from the nearest beacon node to the undetermined node.

2.1.3 The third stage: the location calculation on the unknown node

The distance between the unknown node and each beacon node can be estimated by using the hop number received by the unknown node with respect to the nearest beacon node, as well as the calculated correction value of the average per-hop distance of the beacon node [16, 17]. Then, the coordinates of the nodes to be determined can be calculated by using the corresponding positioning algorithm.

As shown in Fig. 1, A, B, and C are beacon nodes, and their location coordinates information is known. Then, assume that the actual distance between them is AB = d1, BC = d2, and AC = d3, where d1, d2, and d3are all known. Through the first and second stages of the DV-Hop algorithm, we can obtain the minimum hop information between the unknown node and beacon node and the estimated average hop distance HopSizei of the beacon node. If the minimum hop number between A and B is 2, the minimum hop number between B and C is 5, and the minimum hop number between A and C is 6, then the average hop disturbance HopSizeA, HopSizeB, and HopSizeC of the beacon nodes A, B, and C are respectively shown in Eqs. (2)–(4):

$$ {\mathrm{HopSize}}_A=\frac{d_1+{d}_3}{2+6} $$
(2)
Fig. 1
figure 1

Schematic diagram of DV-Hop positioning algorithm

$$ {\mathrm{HopSize}}_B=\frac{d_1+{d}_2}{2+5} $$
(3)
$$ {\mathrm{HopSize}}_C=\frac{d_2+{d}_3}{5+6} $$
(4)

The unknown node M takes the average per-hop distance of the nearest beacon node B as its own average per-hop distance value. According to the hop numbers from unknown node M to beacon nodes A, B, and C, as well as the equation d = HopSize × h, the distance between different beacon nodes and unknown nodes can be estimated by dAM = 3HopSizeB, dBM = 2HopSizeB, and dCM = 3HopSizeB.

Finally, the coordinates of the node m to be determined will be calculated.

2.2 Error analysis

Only using the coordinate information of the beacon node and the hop value in information transmission to locate, the error between the real coordinates and the positioning coordinates is very large [18, 19].

As shown in Fig. 2, there are three beacon nodes A, B, and C distributed in the network, and others are unknown nodes. The average hop distance of beacon node B is \( {d}_{{\mathrm{Hop}}_B}=\left({d}_1+{d}_2\right)/\left(2+6\right) \), and the calculated average hop distance of beacon node B is smaller than the actual average hop distance, which means the error is large. Moreover, the length of each hop from beacon node B to beacon nodes A and C is different, and there is an angle (not 180°) between each two hop segments. Therefore, one divides the linear distance by the number of hops to get the average hop distance of the beacon node, which is regarded as the correction value and the error of this correction value is very large. The distance between the unknown node and the beacon node is estimated by multiplying the correction value by the minimum hop value, which results in a large error in the estimated distance and ultimately affects the accuracy of the positioning results. Generally, unknown nodes account for the majority and beacon nodes account for the minority. The distribution density of unknown nodes is much higher than that of beacon nodes. In addition to the random distribution of beacon nodes, the distance between beacon nodes is large or small, which results in the error fluctuates greatly when the average hop distance of beacon nodes is calculated.

Fig. 2
figure 2

Network topology diagram

3 Improved DV-Hop algorithm

In the distance vector exchanging stage for the traditional DV-Hop algorithm, as long as the distance between the beacon node and the unknown node is less than the communication radius R, the hop number is recorded as 1. This means that there may be a large actual distance difference between two groups of unknown nodes with the hop number of 1 and beacon nodes. As shown in Fig. 3, there are some unknown nodes B and C around beacon node A, and the hop value of the unknown node and beacon node is also 1, but the actual distance between the two unknown nodes and beacon node is very different. Generally taking the hop value between them and the beacon node as 1 will reduce the positioning accuracy of the DV-Hop positioning algorithm and the stability of the algorithm.

Fig. 3
figure 3

Distribution diagram of unknown nodes within the communication radius of beacon nodes

In order to deal with this situation better, this paper proposes an improved DV-Hop algorithm based on dual communication, which requires beacon nodes to broadcast with communication radius R at the first time, and then broadcast with communication radius 0.5R at the second time, as shown in Fig. 4.

Fig. 4
figure 4

Distribution diagram of unknown nodes within the two communication radius of beacon nodes

As shown in Fig. 4, when the beacon node broadcasts in the network with a communication radius of 0.5R, the hop value between the unknown node C and beacon node A is 0.5, instead of the previous 1, so that the optimization on the hop value can better reflect the location of the unknown node and beacon node. Furthermore, the hop value of beacon node A and unknown node C is closer to the real hop value. Therefore, the estimated distance is closer to the real value, which improves the positioning accuracy and the stability of the algorithm.

The specific process of the DV-Hop algorithm based on dual communication radius is expressed as follows. In the stage of distance vector exchange, the beacon node first broadcasts with the communication radius R, the hop number between the unknown node and the beacon node within its communication radius is recorded as 1, and the unknown node group 1 is generated. Then, when the beacon node broadcasts with the communication radius r ⋅ R(0 < r < 1), the hop number between the unknown node and the beacon node within its communication radius is recorded as r and unknown node group 2 is generated. Because of the communication radius R > r ⋅ R, unknown node group 2 is a subset of unknown node group 1. The minimum hop values of the same unknown nodes in unknown node group 1 and unknown node group 2 are recorded as r, while the minimum hop values of other unknown nodes are still kept as 1. In this process, only beacon nodes broadcast twice, and the unknown nodes broadcast with communication radius R after obtaining the minimum hop information between beacon nodes.

Obviously, the hop value obtained by the improved DV-Hop algorithm based on double communication radius is not an integer, but is an integer plus R. Compared with single communication radius R, the minimum hop between nodes is more accurate. The improved DV-Hop algorithm based on double communication radius proposed in this paper updates the minimum hop number obtained by the unknown node which is closer to the beacon node to a smaller hop number by adding a communication radius and keeps the minimum hop number information of the unknown node which is far away from the beacon node at the same time. It shows the difference of the actual distance in terms of the hop number, which solves the problem of the large difference between the actual distances of the same hops to a certain extent, and then is helpful to estimate the more accurate average jump distance.

4 Analysis of simulation and results

In order to study the performance of improved algorithm based on dual communication radius, this paper simulates on the traditional DV-Hop algorithm and improved the DV-Hop algorithm by using MATLAB platform and compares the performance of the two algorithms under different communication radius and different beacon proportion.

During the simulation experiment, the experimental environment and parameters are set as follows:

(1) The nodes of the WSN are randomly deployed in a square area of 100 m × 100 m. It is assumed that all nodes can communicate freely within the communication radius, and all nodes have the same communication ability. Moreover, the nodes have a symmetrical communication ability.

(2) Suppose that the number of nodes distributed in the plane area is 100, and all the unknown nodes are randomly distributed.

(3) Under the same network condition, according to the experimental results, the location relative error is analyzed and compared with the traditional DV-Hop algorithm.

The relative location error is shown as the following equation:

$$ Error=\frac{\sum \limits_i{D}_i/{U}_n}{R} $$
(5)

where \( {D}_i=\sqrt{{\left({x}_i-{x}_r\right)}^2+{\left({y}_i-{y}_r\right)}^2} \) denotes the distance difference between the estimated location (xi,yi) calculated by the location algorithm and the actual location (xr,yr), R is the communication radius, and Un is the total number of unknown nodes. The smaller the location error, the higher the location accuracy is.

Figures 5, 6, and 7 show the relationship between the relative positioning error and beacon node number when communication radius is 20 m, 30 m, and 40 m, respectively.

Fig. 5
figure 5

Relationship between relative positioning error and beacon node number when communication radius is 20 m

Fig. 6
figure 6

Relationship between relative positioning error and beacon node number when communication radius is 30 m

Fig. 7
figure 7

Relationship between relative positioning error and beacon node number when communication radius is 40 m

It can be seen from Figs. 5, 6, and 7 that compared with the traditional DV-Hop algorithm, the relative positioning error of the improved DV-Hop algorithm based on the dual communication radius is smaller and the positioning accuracy is higher. When the total number of nodes and the communication radius of the two algorithms are all same, the relative positioning error increases with the increase of the beacon nodes. Moreover, in the condition that the communication radius is 20 m, 30 m, and 40 m respectively, the relative error of the DV-Hop algorithm based on dual communication radius can be approximately reduced by 9~25% compared with traditional DV-Hop algorithm.

In addition, it can be seen from Fig. 5 that when the communication radius is 20 m, the relative positioning errors of the two algorithms fluctuate with the increase of beacon nodes. Therefore, the communication radius should be greater than 20 m in practical application.

5 Conclusions

From the simulation results, it can be seen that compared with the traditional DV-Hop algorithm and the improved DV-Hop algorithm based on the dual communication radius, the relative positioning error of the dual communication radius algorithm is smaller and the positioning accuracy is higher. When the total number of nodes and the communication radius of the two algorithms remain unchanged, the relative positioning error increases with the increase of the beacon nodes, and the relative positioning error decreases accordingly. Furthermore, when the communication radius is 20 m, 30 m, and 40 m, respectively, the relative error of the DV-Hop algorithm based on dual communication radius can be approximately reduced by 9~25% compared with traditional DV-Hop algorithm.