1. Introduction
Localization is the process of acquiring the position information of an entity in a coordinate system. Knowledge of the position of network nodes is invaluable for numerous applications, such as routing, autonomous airvehicles, network security, environment surveillance for military purposes, and so on. The network is modeled as an undirected graph, where vertices represent a set of nodes and edges are links between two nodes within communication range. Nodes which are aware of their coordinates or position are known as anchor nodes. The aim is to compute the position of other nodes within the network with the help of these anchor nodes. We attempt to achieve this goal by using the position information of anchor nodes and the relative distance between their onehop neighbors. Since, in some adhoc networks (e.g., IoT), the devices have limited resources, it is computationally expensive to equip each node with a localization sensor such as GPS. Thus, we attempt to localize nodes where only a subset are equipped with localization sensors.
Using the distance between onehop neighbors to localize nodes is known as rangebased localization, where the distance between nodes is computed either through Received Signal Strength Indicator (RSSI), Time Of Arrival (TOA), or Time Difference Of Arrival (TDOA). TOA and TDOA require external hardware to synchronize a transmitter and a receiver, while RSSI does not need additional hardware as the distance is derived from a signal attenuation model which relates signal strength to the distance. However, using RSSI is subject to error due to environmental factors (indoors or outdoors), multipath fading, and noise [
1]. In [
2], RSSI was found to vary consistently, with a distance up to 50 m.
Considering the resource limitation of the network nodes, we propose a lightweight solution based on a series of triangulations. If a nonanchor node lies within the vicinity of three nodes whose positions are known, it can efficiently estimate its own position via triangulation, because the distances to these nodes are known. The node then shares its position with other nodes, to further propagate the location estimation process. However, in some less connected regions of the network, this condition will not hold, prohibiting the location discovery for existing solutions (such as [
3,
4]). Our contribution involves the use of triangulation to estimate the coordinates of nonanchor nodes within the vicinity of exactly two anchor nodes. The triangulation yields two possible positions for nonanchor nodes. We introduce a mechanism which attempts to eliminate one of the positions, to localize nonanchor nodes in less connected regions of the network. This approach improves significantly the localization of unknown positions of network nodes.
2. Related Work
Localization of network nodes is crucial for plethora of applications; for instance, improvement of routing techniques [
5,
6,
7]. A straightforward method to address the localization problem is to equip all nodes with a location sensor (such as a GPS), and share the location information. There are two main paradigms to share position information: Rendezvousbased and floodingbased. In rendezvousbased methods, some nodes are elected to store node position information and respond to inquiries when position information is requested. The disadvantage of such a method is that it centralizes the information in only a few nodes, and thus there is a risk of information loss if such nodes break down [
8]. Floodingbased methods overcome this disadvantage by broadcasting node position information to the network. The cost involved in such an approach is excessive message exchange, contributing to network overhead. In SemiFlooding based Location Service (SFLS) [
8], the location information is forwarded with higher frequency to close neighbors (in terms of the number of hops) and lower frequency to further nodes, in order to decrease bandwidth consumption while maintaining adequate knowledge of neighbors’ positions.
In the case where not all nodes are equipped with a GPS, localizing nonanchor nodes require additional information to relate nodes to each other. According to the classification specified in [
9], node relations can be connectivitybased, which simply indicates whether a node is in connection with anchor nodes or not. This is used in [
10], where a node’s position is assumed to be the average of the known positions of the other nodes. Another type of internode relation is the distance between onehop neighbors, which is widely used to estimate the positions of nonanchor nodes [
3,
4]. Relative distance information is an added benefit, which helps to improve the accuracy of the location. In addition, some solutions use the AngleofArrival to relate nodes, or a combination of the mentioned measurement types [
11].
The localization problem can also be seen as an optimization problem, which can be solved using numerical techniques such as SemiDefinite Programming (SDP) [
12] or linear programming [
13]. To avoid the inaccuracies of signal propagation models when using RSSI for distance measurements, some studies [
14,
15,
16] have used intervalanalysis. In intervalbased analysis, instead of computing direct distances from RSSI, a set of inequalities is formulated to indicate that a node is on a ring between 2 radii, based on its relative position to other nodes. Then, the defined areas for nodes can be further restrained using the Waltz algorithm [
17].
Some approaches divide the problem into subproblems, as in [
2], where (1) base stations classify ordinary nodes into clusters based on their proximity to anchor nodes, and (2) within each cluster, a node seen by three anchor nodes is located using a simple geometrical computation. In [
1], the region where the network is deployed is divided into rectangular grids as a first step, then within each small grid the location is refined. However, in the previously mentioned approaches, the number of GPS nodes needs to be high in order to satisfy the necessary constraints. In [
9,
18,
19], the probability distribution is integrated in the location process, rather than attributing a single position for each node. Such a method allows the uncertainty of measurements to be taken into account—be it the GPS position or the relative distance between nodes [
9].
Generally speaking, if the distance of a nonanchor node to three anchor nodes is known the node can be located with simple geometric computations, except in rare cases where the nodes are collinear or when some nodes overlap. This might imply a conclusion that at least three GPS nodes in the network are needed for location. However, in [
9], the proposed solution attempts to localize the network with a single anchor node. Each node starts with a uniform probability distribution over the deployment region and, as the roaming anchor node passes by, the ordinary nodes tweak the distribution to localize the nodes. In this context, the authors experiment their solution where the anchor nodes use a random model to traverse the network, and have a reasonable claim that traversing the network can be optimized to improve the location process. In [
9,
18], negative information about the absence of a node in the proximity of the anchor nodes is used in the location process. This kind of information is used as a basis for our algorithm.
An approach which is seemingly far from the abovementioned methods, yet interesting to address the node location problem, are Graph Layout Algorithms such as FDP [
20] and neato [
21]. Even though the objective of these algorithms is generally to create an easyontheeye graph, some variations make it possible to fix the positions of some nodes (the anchor nodes) and to set a suitable edge length (i.e., the distance between nodes). We have tested these algorithms using graphviz [
22], and the estimated node positions are satisfactory.
Other methods, which use a set of distance equations and optimization techniques, usually require high computation power, which is impractical for these networks. In this case, the computation is done remotely in a centralized fashion. The graph structure might not yield a unique solution. Even if the graph has a unique solution, finding this solution has been proved to be NPhard [
23].
The presented work is an extension of our previous work on localization [
24]. We address the problem from the graph point of view, aimed at pinpointing the location of as many nodes as possible. In our approach, we first consider perfect distance measurements and compare it to an existing method [
4], and show that our method is able to localize more nodes in a randomly generated network by exploiting the case where a nonanchor node is within vicinity of only two localized nodes. Next, we introduce Gaussian noise to distance measurements to simulate the effect of real world errors in distance measurements. Gaussian noise is widely accepted in simulating distance errors, and is experimentally validated in [
25].
Table 1 summarizes different approaches to solve the localization problem.
In
Section 3, the system model is presented and the principal localization steps of the algorithm are introduced. In
Section 4, we explain the distributed implementation of the algorithm, which shows how each node acquires awareness of its location and the location of other nodes. Next, the algorithm is compared with the GPSfree [
4] method, which is widely referenced in the literature and has some similarities with our method, allowing clear comparison and explanation of results. Next, the behavior of our method is studied, with distance measurement errors, in the NS3 [
26] network simulator in
Section 5.
Section 6 contains the conclusion and discusses possible future work.
4. Distributed Implementation of the Algorithm
In this section, we present the algorithm implemented on each node in the network. The first part of the algorithm is sharing positions (if found) through the network, in a bandwidth efficient manner. The second part is the previously described localization method. We use a semiflooding method (SFLS) [
8] to share known positions, as it takes the advantages of both flooding and rendezvous based methods, while mitigating their drawbacks. In this method, each node broadcasts its own position (if found) with an identifier, such as a timestamp or sequence number. A node that receives another node’s position with a higher sequence number or timestamp rebroadcasts once every two receivables. In other words, when a node receives a position for the first time, it rebroadcasts. The next time it receives the new position of the same node, it does not rebroadcast and keeps alternating the rebroadcast decision for the following received positions. This method is bandwidthfriendly and compatible with our localization algorithm, because nodes need more frequent information about their closer neighbors. Assuming the broadcast interval is
t seconds, onehop neighbors receive the position information every
t seconds, twohop neighbors receive position information every
$2\phantom{\rule{3.33333pt}{0ex}}t$ seconds, threehop neighbors receive position info every
$4\phantom{\rule{3.33333pt}{0ex}}t$ seconds, and so on. In [
8], it has been shown mathematically that the mean number of broadcasts
$\overline{{m}_{i}}$ performed to update the position information of node
i grows approximately linearly with the number of nodes in the network, where nodes are uniformly distributed. This ensures scalability with respect to bandwidth consumption. The broadcasting of positions, receiving them, and initiating the selflocalization algorithm is illustrated in Algorithm 1.
Algorithm 1 SFLS Position sharing 
 1:
$ownSeqNum$ = 0 (Sequence number starts at 0 for all nodes)  2:
$retransmitDecision$ (stores retransmission decision for all nodes, initialized to true for all nodes)  3:
N (list of received node positions) and ${N}_{1}$ (1hop neighbors with known positions)  4:
$I{d}_{1}$: list of IDs of all onehop neighbors and $distanceTo$ stores distances to 1hop neighbors  5:
procedurebroadcast_own_position  6:
if $nodeType$ == $anchor$ then  7:
$ownSeqNum++$  8:
$pos$ = $anchor\_pos$  9:
else if position is estimated then  10:
$pos$ = $estimatedPos$  11:
end if  12:
packet = [$ownID$, $pos$, $ownSeq$, $ownID$]  13:
broadcast packet  14:
end procedure  15:
procedurereceive($sendID,pos,seqNum,I{D}_{1hop}$)  16:
$prevSeqNum=seqNum\left[sendID\right]$  17:
if $seqNum>prevSeqNum$ then  18:
$seqNum\left[sendID\right]=seqNum$  19:
$N\left[sendID\right]=pos$  20:
update $distanceTo\left[I{D}_{1hop}\right]$  21:
if $sendID$ == $I{D}_{1hop}$ then  22:
${N}_{1}\left[sendID\right]=pos$  23:
end if  24:
if $nodeType!=anchor$ and $seqNum>ownSeqNum$ and ${N}_{1}.size>=2$ then  25:
$selfLocalize\left(\right)$  26:
end if  27:
end if  28:
$rebroadcast(sendID,pos,seqNum,ownID)$  29:
end procedure  30:
procedurerebroadcast($sendID,pos,seqNum,ownID$)  31:
if $retransmitDecision\left[sendID\right]$ == $true$ then  32:
packet = [$sendID,pos,seqNum,ownID$]  33:
broadcast packet  34:
$retransmitDescision\left[sendID\right]$ = $false$  35:
else  36:
$retransmitDescision\left[sendID\right]$ = $true$  37:
end if  38:
end procedure

Three procedures are described in Algorithm 1:
 (a)
Broadcast own position: Startup method is called every t seconds for anchor nodes at the beginning of the simulation. For nonanchor nodes, it is called, once their positions are estimated, to start broadcasting their positions with the interval t. Note that the sequence number (which indicates the freshness of position information) is incremented only by anchor nodes. This is because the position information originates from the anchor nodes, while the localization of all the other nodes is more or less inherited from them. Thus, when a nonanchor node is localized, it updates its sequence number to be equal to that of the nodes used to localize it.
 (b)
Receive: Called every time a packet is received. The inputs to the procedure are the ID of the original creator of the packet $sendID$, the position of sending node $pos$, the associated sequence number $seqNum$, and the ID of the onehop neighbor that relayed the packet $I{D}_{1hop}$. When new information arrives, this method checks if the gathered information is sufficient to attempt to estimate a node’s position. If so, it calls the $selfLocalize$ method, which is described in Algorithm 2.
 (c)
Rebroadcast: Called by the receive method, after the received position is processed, to decide whether to forward the received packet according to the SFLS rule.
The second part of the algorithm is the localization part, which was explained in the previous section. Thus, each time updated position information is received, an attempt is made to localize a node by calling $selfLocalize\left(\right)$ in the $receive$ method. The localization procedure is further detailed in Algorithm 2.
Algorithm 2 Position Certainty Propagation: $selfLocalize\left(\right)$ 
 1:
$mostRecentOneHop$ = list of 1hop neighbors with the highest sequence number  2:
$maxSeqNumFound$ = seqNum of any of the nodes in the $mostRecentOneHop$  3:
if$mostRecentOneHop$ has 3 or more nodes then  4:
$estimatedPos$ = $intersection\left(mostRecentOneHop\right)$  5:
$ownSeqNum$ = $maxSeqNumFound$  6:
else if$mostRecentOneHop$ has 2 nodes then  7:
[pos1, pos2] = $intersection\left(mostRecentOneHop\right)$  8:
$P1Neighs$ = n for each n ∈ N where $distance(n,pos1)$ <= $CommRange$  9:
$\overline{P1Neighs}$ = $NP1Neighs$  10:
$P2Neighs$ = n for each n ∈ N where $distance(n,pos2)$ <= $CommRange$  11:
$\overline{P2Neighs}$ = $NP2Neighs$  12:
$pos1IsCompatible$ ⇔ for each n ∈ $P1Neighs$, n ∈ $I{d}_{1}$ and for each m ∈ $\overline{P1Neighs}$, $m\notin I{d}_{1}$  13:
$pos2IsCompatible$ ⇔ for each n ∈ $P2Neighs$, n ∈ $I{d}_{1}$ and for each m ∈ $\overline{P2Neighs}$, $m\notin I{d}_{1}$  14:
if $pos1IsCompatible$ and not $pos2IsCompatible$ then  15:
$estimatedPos$ = $pos1$  16:
$ownSeqNum$ = $maxSeqNumFound$  17:
else if $pos2IsCompatible$ and not $pos1IsCompatible$ then  18:
$estimatedPos$ = $pos2$  19:
$ownSeqNum$ = $maxSeqNumFound$  20:
end if  21:
end if

Let ${N}_{1}$ be the list of detected neighbors with known positions within communication range of the node. When ${N}_{1}$ includes two or three nodes, the position of the node can be estimated using the intersection method. If ${N}_{1}$ includes two nodes, the intersection method returns the two possible positions, one of which is to be eliminated (if possible). Let N be the list containing position information of all the received positions of network nodes. The first line gets the 1hop neighbors whose positions are known and have the highest sequence number available. This ensures that the positions used to localize the node are from the same time step, and thus ensures the information is coherent. Then, if the number of 1hop node positions is three or more, the $intersection$ method returns one position that is stored in $estimatedPos$ and the sequence number is updated to be equal to the sequence number of nodes used in localization. If there were two 1hop nodes with known positions, the $intersection$ method returns two possible positions, which are then tested in an attempt to eliminate one of them using the procedure explained above. Once $estimatedPos$ is updated, it will be used together with the sequence number in the next $broadcast\_own\_position$ call.
6. Conclusions
The work presented in this article proposed a location service solution that is lightweight, bandwidth friendly, and cost and energy efficient. Cost and energy consumption is conserved by requiring a minimum of three GPSequipped nodes. The computations used to localize nodes are not complicated, and do not require many cycles (as in the case of optimization). Sharing positions with other nodes in the network is done using a semiflooding method, to conserve network bandwidth. The solution requires that the anchor nodes are in the vicinity of at least one nonanchor node, in order to be able to start. This starting condition constraint might appear to hinder the generality of the algorithm, but this can be mitigated by electing some virtual anchor nodes that satisfy the condition. These virtual anchor nodes are given assumed positions, so that they form a triangle from the known distance between them. For instance, let us assume noncollinear nodes
$i,\phantom{\rule{3.33333pt}{0ex}}j,\phantom{\rule{3.33333pt}{0ex}}k$ see each other, and at least a fourth node
l. Node
i is positioned at the origin, node
j is on the horizontal axis at a distance equal to
$dist(i,\phantom{\rule{3.33333pt}{0ex}}j)$ and node
k is added to have a positive
yvalue using triangluation. The algorithm then treats them as anchor nodes and computes the position of the rest of the nodes, as previously explained. When at least three real anchor node positions have been computed, all the nodes can then be transferred to the global coordinate system, using the computed and actual positions of anchor nodes [
4].
The solution was compared to another method [
4], and it was shown that our solution achieves a higher percentage of localized nodes. In a network with an average degree ≈10, around
$90\%$ of the nodes are localized. Furthermore, we tested our algorithm using NS3, while introducing distance measurement errors, and the average error is shown to be stable for a 50node network. Also, the average localization error increases linearly with the standard deviation of the Gaussian measurement noise. The position sharing technique used conserves bandwidth by reducing position update frequency to further nodes. For future work, the error propagation effect towards the edge of the network needs to be mitigated. Additionally, the impact of node mobility on the accuracy of localization is also to be considered.