## 3 DI-distributed Localization (DIL) Algorithm
### Distance Measurement  
The received signal strength indicator (RSSI) is one type of distance estimation technology to obtain the distance between the transmitter and receiver [19, 20]. This measurement technology is a standard feature found in most wireless devices and is attractive as they do not need any additional hardware support. When the transmitter sends packet to the receiver, receiver gets the RSSI value as the inverse square of the distance. In most of the localization algorithms, the propagation of signal is considered as an over idealization case, e.g., free space model. However, because of the noise and obstacle, the fading and shadowing effects must be considered in node localization. Experimental results [21] show that many well-designed protocols in WSNs fail in a realistic wireless environment. Typically, the mean RSSI decays between the transmitter and receiver (T-R) can be predicted by some radio propagation model. Because of multi-path fading and shadowing, the received signal strength in wireless channel cannot be obtained appropriately and location estimation error is inevitable. However, log-normal shadowing model can better describe the relationship between the RSSI value and distance. Hence, the log normal shadowing model is a most commonly used propagation model that considers the shadowing effect,  
Figure 1: Example of node deployment strategy in the localization system. whether in outdoor or indoor environment. This model indicates that decrease in average received signal strength with distance is logarithmical. In general, the average path loss for an arbitrary T-R separation can be expressed as given in Equation (1),  
\[P_{r}(d)=P_{t}(d_{0})-10 nlog(\frac{d}{d_{0}})+X_{\sigma} \tag{1}\]  
where \(n\) is the path loss exponent, which depends on the specific propagation environment, \(d\) is the distance between T-R, \(P_{r}(d)\) represents the received signal strength indicator (RSSI), and \(P_{t}(d_{0})\) represents the transmission power at reference distance \((d_{0})\). The term \(X_{\sigma}\) is a random variable, which accounts for the random variation of the shadowing effect and is supposed to be Gaussian distribution with zero mean random variable (in dB) with standard deviation \(\sigma\) (also in dB). Based on Equation (1), we can obtain the distance \(d\) from Equation (2). \[d=d_{0}*10^{-(\frac{P_{t}(d_{0})-P_{r}(d)-X_{\sigma}}{10n})} \tag{2}\]  
Coordinate Computation  
After measuring the distance between the beacon and normal nodes based on the RSSI value, coordinate of each normal node can be calculated. According to our assumptions, a normal node must have received location information from at least one beacon node and angle information from only one anchor node to calculate its own location. To satisfy the conditions of the assumption, a normal node must wait for a predefined timeout \(T_{n}\) units to receive RSSI value from at least one and at most three beacon nodes. During the waiting time, if a normal node does not receive any RSSI value from at least one beacon node, it has to again wait for the \(T_{n}\) units and the process continues till a normal node receives RSSI value from any beacon nodes within its communication range. Upon receiving RSSI value from the beacon nodes and angle information from the anchor node, a normal node starts calculating the possible coordinates of its own location. Let \((x,y)\) be the coordinate of the normal node, \((x_{1},y_{1})\) be the location of a beacon node \(B_{1}\), and \((x_{a},y_{a})\) be the location of an anchor node. Distance between the beacon and normal node is \(d_{1}\), which is calculated as described later. Let the angle between the anchor node's \(x\)-axis and the line joining the normal and anchor node be \(\theta\). Based on these information, we can obtain two equations. We consider  
Figure 2: Location computation of a normal node with help of one beacon node. the linear equation that passes through the anchor and normal node, as shown in Figure 2 and given in Equation (3).