1 Introduction

Wireless sensor network (WSN) refers to a group of spatially dispersed and dedicated sensors for detecting and recording the physical conditions of targets and resolving the signals at a central location [1]. WSNs have become extremely popular in the present day due to their expanding ability to monitor and interact remotely with the world [2]. In a WSN, a large number of autonomous low-complexity sensor nodes are deployed to generate collaborative networks by collecting, transmitting and analyzing data [3]. Since sensor nodes measure the physical conditions at a given position, the signals delivered by each sensor are relevant only if tagged with the accurate locations of the sensor nodes [4, 5]. In addition, the trend towards the wireless sensing system is intended to employ energy-efficient algorithms and save resources [6, 7]. For this reason, the investigation of node positioning is imperative. Therefore, the localization strategy is deemed best able to meet the high accuracy and low power consumption demands [8].

Research is ongoing to take this localization methodology into widespread use. In most cases, the problem of sensing node positioning can be described as follows: On the foundation of the pairwise distance measurement, an unlocalized node is determined via the information exchanging principle, whose position or coordinate is in reference to the number of neighboring nodes and the distance to them. Current methods, such as the use of the global positioning system (GPS), have become significant in node localization in WSN. However, it is difficult to use this method to assign location data to all sensor nodes in a large-scale network because the per-node manual configuration is difficult and equipping each node with a GPS receiver is overly expensive. Typically, the localization algorithm can be categorized as a range-free approach, while the measuring of the actual distance between nodes can be categorized as a range-based approach [9,10,11]. Previous work in range-free localization schemes is heuristic, simple, and allows distributed implementation, which depends on merely the connectivity information (i.e., whether a node is in the transmission range of another node) [12]. For example, the approximate point in triangulation algorithm uses the triangle formed by any three anchors that contain the unlocalized node and estimates the position by identifying the center of the intersection of all these triangles [13, 14]. However, the range-free solutions have barriers to scalability due to error accumulation and due to power consumption because of centralized computation. In addition, range-based localization algorithms provide more reliable sensor positioning by using pairwise time-of-arrival (TOA), time-difference-of-arrival (TDOA), received signal strength (RSS), and/or angle-of-arrival measurements [15, 16]. As such, there are special hardware requirements for running the algorithms. There are still many challenges to locating sensor nodes in WSNs. For this reason, new methodologies are required for developing sensor node localization approaches.

During the methodology devising process, issues of positioning accuracy, scalability, and energy consumption must be evaluated to establish the system baseline. The sensor node localization algorithm is therefore of great significance for network deployment [17]. In this paper, a sensor node localization method called the distance mapping algorithm (DMA), which is distinctive from the aforementioned approaches, is devised and developed. We focus here not only on the precision of localization accuracy but also on reducing microsensor energy usage. The remainder of the paper is arranged in the following order:

In Sect. 2, we review the basic working foundation of node localization algorithm deployment as well as the theory of genetic algorithms for parameter optimization. Our proposed approach is described with detailed working procedures in Sect. 3. We then describe the performed simulation of the localization algorithm together with the result analysis in Sect. 4. The research findings and future expectations are provided in Sect. 5.

2 Preliminaries

We now briefly describe the basic principle of distance measurement in WSNs to facilitate the description of subsequent algorithm deployment. For more details, see the work done by Guillermo Molina et al. and Feng Jun et al. [18, 19]. In addition, the genetic algorithm is used to facilitate the localization process. As a class of optimization heuristics based on natural selection and genetic evolution, the genetic algorithm is employed to identify the optimum solution of the parameter.

2.1 Distance Resolving

To start with, we identify the nodes with known positions as anchor nodes or reference nodes and those with unknown positions as nonanchor nodes or unlocalized nodes. In a WSN, nonanchor nodes and anchor nodes communicate with each other to estimate locations. Suppose there are \( M \) anchor nodes \( \left\{ {S_{1} , S_{2} , \ldots S_{M} } \right\} \) in one network and the \( ith \) node \( S_{i} \) in the M—dimensional space can be expressed via the estimated vector, which is

$$ P_{i} = \left\{ {p_{i1} , p_{i2} , \ldots , p_{iM} } \right\}T $$
(1)

where \( p_{ij} \) indicates the measurement estimation between node \( S_{i} \) and node \( S_{j} \) while \( p_{ii} = 0 \). \( T \) represents the function of linear transformation.

In this way, the embedded M—dimensional space is defined by the following estimation matrix

$$ P = \left[ {P_{1} , P_{2} , \ldots ,P_{M} } \right] $$
(2)

Similarly, the node distances can be depicted by

$$ L_{i} = \left\{ {l_{i1} , l_{i2} , \ldots ,l_{iM} } \right\}T $$
(3)

where, according to Eq. (1), \( l_{ij} \) indicates the distance between node \( S_{i} \) and node \( S_{j} \) while \( l_{ii} = 0 \). Thus, the distance matrix is presented as

$$ L = \left[ {L_{1} , L_{2} , \ldots ,L_{M} } \right] $$
(4)

We shall thus say that an optimal linear transformation can be calculated to provide a mapped relationship between the estimation matrix and the distance matrix. For each nonanchor node with an estimated vector, the corresponding vector distance is obtained, from which its coordinate can be computed.

Specifically, the function \( T \) is preset as a \( M \times M \) matrix, while each row is determined via the resolving of minimal variance:

$$ e_{i} = \mathop \sum \limits_{k = 1}^{M} \left( {l_{ik} - t_{i} p_{k} } \right)^{2} = \left\| {l_{i}^{T} - t_{i} P} \right\|^{2} $$
(5)

where \( t \) represents the row of the matrix. As long as we have:

$$ \left[ {L_{1} , L_{2} , \ldots ,L_{M} } \right] = \left[ {P_{1} , P_{2} , \ldots ,P_{M} } \right]T $$
(6)

the row vector of matrix \( T \) can be written as

$$ t_{1} : t_{i} = l_{i}^{T} PT\left( {PP^{T} } \right)^{ - 1} $$
(7)

together with the matrix as

$$ T = LPT\left( {PP^{T} } \right)^{ - 1} $$
(8)

Calculation with the target matrix is facilitated by using the singular value decomposition (SVD) principle. Owing to the noise within the measuring output, we remove data points with values close to zero during the computation.

2.2 Genetic Algorithm

The genetic algorithm (GA) is a metaheuristic inspired by the process of natural selection in the field of evolutionary biology [20]. The evolutionary algorithms, however, have already shown their specific capabilities in optimizing problems relating to the parameter evaluation [21, 22]. Genetic algorithms are generally applied to generate high-quality solutions to where the variables to be optimized (genes) can be encoded to form a string (chromosome) [23]. In a GA, every string stands for one trial solution of the problem. A GA aims to find better solutions by exchanging information between the strings.

Commonly, parameter optimization originates from the real problem of addressing the system objective function, which links to different formulations [24]. A theoretical curve produced by a GA is desired to contrast with the field data. The working procedures of a GA are given as follows:

  1. 1.

    Initialization: a population of chromosomes, which represent the individuals, are created at the first stage. Concretely, each chromosome contains genes with alleles, which indicate the actual parameters [25]. The initial parameter values are randomly assigned.

  2. 2.

    Fitness calculation: the fitness of each individual in this population is computed, which will become a variable in future steps.

  3. 3.

    Individual selection: individuals with better fitness outcomes are able to produce the next generation because the selection mechanism allows only a small portion of chromosomes to evolve further [26]. Variable fitness levels allows for selection among random competitors. The selected individuals, which come from the current population, are then inserted into a mating pool.

  4. 4.

    Reproduction: a new set of individuals in every generation is reproduced from the parents in the mating pool. Generally, reproduction involves the operation of both crossover and mutation [27]. Reproduction is the process of crossover of the genetic information. Altering the alleles randomly ensures the genetic diversity of the subsequent generations of offspring. The mutation probability is commonly less than 1%. Thus, a new individual can be created that shares major commonalities and minor differences with the parents [28].

  5. 5.

    The initial population is replaced with the new population. After the repeated iterations of the processes, a solution is found that caters to the minimum criteria. Successive iterations no longer produce better results.

3 Methodology

This section comprehensively introduces the design principle of the sensor node localization algorithm and the positioning process.

The proposed localization algorithm, DMA, has three stages: preprocessing, parameter determination and nonanchor localization. Figure 1 illustrates the flow chart of the approach.

Fig. 1
figure 1

Overview of DMA

Preprocessing: the WSN is enabled for both anchor node and nonanchor node communication.

Parameter determination: related variables, such as the estimation matrix, the distance matrix and the linear transformation function, are derived from the measurement distances.

Localization: The nonanchor node is localized by using the parameters obtained above.

More details of each step are described in the following sections.

3.1 Preprocessing

One of the key processes in WSNs is the deployment of the system. Each node is initialized with an empty node link list hereafter. Note that one anchor node link list contains an anchor node ID, positioning information, hop numbers and the distances to neighboring nodes. The nodes can connect only to each other rather than detecting the distance. Then, in relation to assigning the value 1 to all edges, the distance can be calculated from the hop ranges. Aiming to reduce the communication overhead, especially for large WSNs, a threshold is preset as the hop count for each anchor node to expand outward. If and only if the hop range from one node to the anchor node is larger than the threshold, the expanding will stop.

Subsequently, each anchor node can broadcast a “Hello” packet to its neighboring node. The content of the packet is in line with the anchor node ID, coordinate \( x_{i} \) and the hop range \( p_{i} \) with the initial value preset as 0.

For every nonanchor node, as long as a detection packet is received, an increment of value 1 is given to the hop range to compare with the threshold. If and only if the current hop is larger than the threshold, the packet will be discarded. Otherwise, the hop is kept to update the node link list for further transmitting. The node will not stop collecting the detection packet until the hop count equals the threshold collected from the link list. This task is addressed through the following pseudo code:

figure e

3.2 Parameter Determination

On the foundation of the preprocessing, one anchor node can receive the data package with the updated information from another anchor node. In this way, the content within the link list can be transmitted during communication. The pseudocode of anchor node communication for the information updating algorithm is shown in algorithm 2.

figure f

After acquiring the aforementioned information, the link list of the anchor node is updated, especially for the hop count. Then, in relation to the WSN, a straightforward way to compute the estimation matrix and the distance matrix is available. As long as all the anchor nodes update their key information, three nodes, which are the closest to each other in distance, are selected to construct a new matrix of approximate value. At this stage, the variables for node localization are established.

The process of parameter determination can be described as algorithm 3.

figure g

The linear transforming function is based on the estimation matrix \( P \). By using the SVD, we shall thus obtain the linear transformation \( T \) mapping the neighboring sensor nodes. The matrices can then be delivered to the nonanchor nodes.

3.3 Localization

In the direction of a nonanchor node \( S \), its approximation vector \( Ps \) can be established via the link list of anchor nodes. Further, the function of linear transformation is passed on by its neighboring anchors. The target distance matrix is therefore achieved through Eq. (9):

$$ LS = TPs $$
(9)

The position of every nonanchor can be determined calculated using the trilateration principle. However, considering the energy consumption and the hardware working accuracy, the three circles cannot intersect at one point all the time. Therefore, we employ GA to find the optimized point, which can effectively minimize the difference between the measuring distance and the estimation outcome. This optimized point represents the position of the node.

The flowchart describing the optimization of the point position in this research is shown in Fig. 2. We take the geometric parameters of the three circles as the input of GA, while the ideal intersection is the output.

Fig. 2
figure 2

Flowchart of GA optimization

For current research, the initial population of individuals’ genes is generated randomly so that the selection of genes with high fitness can address a best gene in the minimum number of genetic evolutions [29, 30]. The size of the initial population is set at 40 individuals. The fitness function is used to select individuals with the highest fitness. Reproduction is then utilized to produce increased numbers of offspring with higher fitness. The mutation ratio is given as converges on 0.2% considering that the convergence speed slows down as the search space expands. After 150 generations, the iterative procedures stop satisfying the criteria. The variation in the target value became negligible. Finally, the result approaches a constant value.

Consequently, the nonanchor sensor node can be localized by the following process.

figure h

4 Experiments

This section shows the implemented approach for sensor node position identification in a WSN. This study integrates the localization algorithms into an embedded virtual platform, where the state of each node can be set and measured for system development.

4.1 Experimental Setup

Experiments are conducted on the proposed sensor node localization method to evaluate the working performance in WSNs. The algorithms are compiled and run on the simulation software Network Simulator, which can be applied to the WSN environment. The localization accuracy and the energy consumption are taken to verify DMA technical efficacy in comparison with traditional approaches, DV-Hop and MDS-map.

Sixty moving sensor nodes are deployed randomly in a \( 400 \times 400 \) space. The topology of the network in the simulation is shown in Fig. 3. The points represent the sensor nodes, and the lines between them represent their relationship. With all the functions enabled, the network can to identify the position of all the sensor nodes.

Fig. 3
figure 3

Topology of sensor node distribution

4.2 Analysis of Results

In the conducted simulations, the density of anchor nodes in the network varies with manual adjustment of parameters. It should be noted that the localization accuracy changes with differing numbers of anchor nodes. We set the number of anchor nodes from 4 to 20 for the working performance comparison. The localization error is recorded to demonstrate the positioning accuracy during the result analysis. The outcomes of the three approaches introduced above are illustrated in Fig. 4.

Fig. 4
figure 4

Relation of localization error and number of anchor nodes

According to Fig. 4, the positioning errors decrease as the number of anchor nodes increases. The presence of more reference nodes in the WSN leads to a more accurate representation of the network. The proposed DMA algorithm typically reaches an even higher localization accuracy than the other two algorithms. The localization error can be explained by the noise within the network and the transmitting error resulting from variable collection environments. An accuracy rate of 100% is not possible [31].

Energy consumption is also a significant index for sensor node localization algorithm analysis. In WSNs, growth in the number of anchor nodes will inevitably result in power consumption. For the localization algorithm, the energy is allocated for the data sending, receiving and updating. For the purpose of reducing the system power demands, we compare the energy consumption of the three algorithms (Fig. 5).

Fig. 5
figure 5

Relation of energy consumption and number of anchor nodes

The proposed algorithm DMA uses less power mainly because it employs neighboring nodes by transmitting local positioning information. Since the anchor nodes reject the nodes that are beyond their hop range automatically, the algorithm is more efficient in energy consumption. Moreover, DMA benefits network expansion by using the information of neighboring nodes. In summary, the qualitative results of the simulation provide evidence that DMA can be adapted for complex WSNs with reliable working performance that and it is possible to conserve relatively more power.

5 Concluding Remarks

The DMA concentrates on identifying the position of the sensor nodes in the WSNs. On the basis of high-accuracy localization, the estimation matrix, distance matrix and the optimized linear transformation are effective for node position description. GA is employed during the computation to provide a more reliable outcome through identification of optimal node position. In addition, this algorithm also tends to be beneficial to system scalability. The simulation of three localization algorithms was set up in the laboratory. The results reveal that the proposed approach outperforms other widespread methods in terms of localization accuracy and energy consumption, which offers an opportunity to fulfill the demand for high-accuracy sensor node localization within the development of WSNs.

Due to the significance of this research, future work will focus on more complex situations that require real-time localization of freely moving nodes. The proposed algorithm may have difficulty in identifying the node location without a preset trajectory. Therefore, we tend to improve the current method by integrating path planning and predicting strategies.