## 3 RLS Design
### Localization Phase
When the sink reaches three localization messages and inserts the \(r\) value to them, the position of the node will be pertain to Equation (7) and intersects three circles according to later to achieve the actual node coordination. Hence, we could map the nodes from 3D to 2D with those determined circles. The RLS operation is outlined in Algorithm 1. ```
1:ifsensor senses an eventthen
2:broadcast (localizationMSG) // including node-ID, \(T_{S}\), depth
3:endif
4:for each beacon receive (localizationMSG) do
5:localizationMSG.insert (\(T_{R}\), B(x, y))
6:send LocalizationMSG toward sink
7:endfor
8:forsink receive (localizationMSG) do
9:dist = (\(T_{R}\) - \(T_{S}\)) * v
10:\(r\) = sqrt (dist*2 - depth*2)
11:localizationMSG.insert(r)
12:Sink.table.addrecord (LocalizationMSG)
13:\(m\) = \(m\) + 1
14:Ifm\(\geq\) 3 then
15:Select 3 records which (\(r\) < others)
16:\(P_{S}\) = Trilaterate( (\(x_{1}\),\(y_{1}\),\(r\)), (\(x_{2}\),\(y_{2}\),\(r_{2}\)), (\(x_{3}\),\(y_{3}\),\(r_{3}\)) )
17:endif
18:endfor
```  
**Algorithm 1**RLS operation. From Algorithm 1, it is seen that RLS is an event-driven method (line 1). In a sensor network, sensor nodes sample several properties from their surroundings, according to their deployment purpose. Temperature, pressure, salinity and acceleration are typical sensors for underwater sensor networks [2] where it is practical to use the proposed RLS algorithm. In RLS, the task of ordinary nodes is rather simple. They only broadcast a localization request message whenever they detect an event or determine the measured value (line 2). The detector sensor does not require waiting to receive location information from beacon nodes. As for beacon nodes, the localization task is also energy-efficient and fast. They only receive the localization messages broadcast by sensors and insert their time and location in it (line 5). Then it is forwarded to the sink immediately (line 6). The transmitting phase of the RLS method finishes here (line 7). The proposed message exchange mechanism can save energy by significantly reducing the number of sending packets. It does not involve intensive messages while only send an event which is desired value for network goal. At later time, if the position of node would be changed by water currents, the measured value is sent and location information is calculated in sink. The localization phase will be launched by a localization message reaching a sink from a beacon (line 8). The distance between detector sensor and receiver beacon is calculated in the sink by using TOA (line 9). Then, the radius of circular base in Figure 2 will be estimated and the sink inserts this value in the localization message (lines 10, 11). Now, this updates message is recorded in a table in the sink to be used in estimating the location of the node (line 12). After collecting at least three messages from different beacons, trilateration is applied and the location of the occurred event is determined (line 16). Beacon signals with the lowest r value in the localization table are preferred to estimate more accurate locations (line 15), because these beacons are closer to the sensor compared to other beacons.