| Algorithm 1. RLS operation. |
| 1: if sensor senses an event then |
| 2: broadcast (localizationMSG) // including node-ID, TS, depth |
| 3: end if |
| 4: for each beacon receive (localizationMSG) do |
| 5: localizationMSG.insert (TR, B(x, y)) |
| 6: send LocalizationMSG toward sink |
| 7: end for |
| 8: for sink receive (localizationMSG) do |
| 9: dist = (TR - TS) * v |
| 10: r = sqrt (distˆ2 - depthˆ2) |
| 11: localizationMSG.insert(r) |
| 12: Sink.table.addrecord (LocalizationMSG) |
| 13: m = m + 1 |
| 14: If m ≥ 3 then |
| 15: Select 3 records which (r < others) |
| 16: PS = Trilaterate((x1,y1,r1), (x2,y2,r2), (x3,y3,r3)) |
| 17: end if |
| 18: end for |