## 3 DI-distributed Localization (DIL) Algorithm
### Localization Error Determination  
It is to be noted that we propose the distributed localization algorithm taking three different types of nodes. We use location information of at least one or at most three beacon nodes to calculate the location of normal nodes. The anchor nodes do not provide location information neither to beacon nor to normal nodes. In our algorithm, they can provide only angle information to the normal nodes. Since we consider at most three beacon nodes to calculate location of the normal nodes, it could be possible that a normal node may calculate three different locations from the RSSI values received from three different beacon nodes. Hence, we use here the probability distribution function (PDF) to determine the probability of wrong identification of a transmission from the beacon node \(A\) as if it is originating either from the location of beacon node \(B\) or \(C\). Besides, we also give the analytical methods to determine the probability of wrong identification from the beacon nodes \(B\) and \(C\) with respect to the beacon node \(A\). Figure 3: Location determination of normal node: **(a)** with help of two beacon nodes, **(b)** with help of three beacon nodes. It is obvious that only one pair of coordinate is used as the location of the normal node, if only one beacon node is used to calculate the location of the normal node. However, the presence of more beacon nodes can enhance the accuracy of the localization. Hence, we propose our system with two or three beacon nodes for error analysis as follows. Consider three beacon nodes \(A\), \(B\) and \(C\) located at different positions but within the communication range of a normal node. Let \(S_{A}\), \(S_{B}\) and \(S_{C}\) be the received signal strength (RSSI) by a normal node from those beacon nodes \(A\), \(B\) and \(C\), respectively. \(f_{A}\), \(f_{B}\) and \(f_{C}\) are the probability density functions (PDF) of the received signal strength \(S_{A}\), \(S_{B}\) and \(S_{C}\), respectively, which are received by a normal node. Taking \(S_{A}\) as the RSSI value received by the normal node from beacon node \(A\) and using this value in \(f_{A}\) and \(f_{B}\), we can calculate \(f_{A}(S_{A})\) and \(f_{B}(S_{A})\), respectively. In this process, if \(f_{A}(S_{A})<f_{B}(S_{A})\), the normal node wrongly decides that the transmission has originated from \(B\) instead of \(A\). As shown in Figure 4, as an example, \(f_{B}(S_{A})\) is determined from the RSSI value received from node \(A\) and the shaded area represents the probability of wrong identification, which can be expressed analytically as follows,  
\[P_{A\to B}=P(f_{A}(S_{A})<f_{B}(S_{A})) \tag{8}\] \begin{table}
\begin{tabular}{|l|} \hline
**Initialize:** \\ Waiting time \(T_{n}\) for each normal node; \\ All fields of coordinate table =\{\(\phi\)\(\}\); \\ Start: Node deployment strategy; \\
**Do** \\ \{ \\
**For each Anchor node:** \\ Check: Neighbors of each normal nodes; \\ Measure: Angle information for \\ each neighbor of normal nodes; \\ Transmit: Angle information to each normal nodes; \\
**For each Beacon node:** \\ Broadcast the beacon packets; \\
**For each Normal node:** \\ Setup: Waiting time \(T_{n}\); \\
**Do** \\ \{ \\
**Listen** to the network; \\
**If** (any beacon packet is received) \\
**Translate:** RSSI into Distance; \\
**Start location computation;** \\ Update the coordinate table; \\
**End If** \\ \} **While** (\(T_{n}\) is not expired); \\ Calculate: Final result from all entries of the table; \\ Output: Normal node’s location; \\
**End** \\ \hline \end{tabular}
\end{table} 
Table 2: Distributed Localization (DIL) Algorithm. \[P_{A\to C}=P(f_{A}(S_{A})<f_{C}(S_{A})) \tag{9}\]  
where \(P_{A\to B}\) is the probability of wrongly identifying a transmission arriving from beacon node \(A\) as if it originates from beacon node \(B\). Similarly, \(P_{A\to C}\) is the probability of wrongly identifying a transmission arriving from beacon node \(A\) as if it originates from beacon node \(C\).