Algorithm 1. Neighborhood Discovery (ND) |
|
Run at any wireless node (e.g., u) |
|
Input: Nmax
|
|
Output: The identifiers and approximate maximum transmission ranges of all neighbors |
1. |
Initialize the variables (e.g., Lu,nei = Φ; du,max = 0; N = 0) |
2. |
Use a CSMA/CA scheme to contend for the channel |
3. |
if succeed in accessing the channel then
|
4. |
Send [IDu, eu, pu,max, du,max, Lu,nei] at the maximum transmission power pu,max
|
5. |
Set the timer tΔ as Δ
|
6. |
Initialize FLAG1
and FLAG2 as false respectively |
7. |
while the timer tΔ does not expire do
|
8. |
if receive [IDv, ev, pv,max, dv,max, Lv,nei] from any node v that is not in Lu,nei
then
|
9. |
Record the receiving power prv,u and employ the Formula (4) to compute dv,u
|
10. |
Add (IDv, dv,u) to Lu,nei
|
11. |
if
du,max < dv,u
then
du,max = dv,u
|
12. |
FLAG1 = true
|
13. |
else
if receive [IDv, ev, pv,max, dv,max, Lv,nei] and node u is not in Lv,nei
then
|
14. |
FLAG2 = true
|
15. |
end if
|
16. |
end while
|
17. |
if (FLAG2 == true) then
N++ |
18. |
if (N < Nmax) and (FLAG1 == true or FLAG2 == true) then go to step 2 |
19. |
else go to step 2 |
20. |
end if |