Algorithm 2. MCH Selection (MCHS) |
|
Run at any wireless node (e.g., u) |
|
Input: Nmax
|
|
Output: The identifiers and approximate maximum transmission ranges of all neighbors |
1. |
Initialize the state variable su as “undecided” |
2. |
for each entry (IDv, dv,u) in Lu,nei
do initialize the state variable sv as “undecided” |
3. |
Compute node u’s Ru,intra according to the formulas (5) and (6) |
4. |
Compute node u’s MCH eligibility metric MMu according to the Formula (7) |
5. |
Initialize FLAG1 as true
|
6. |
for each entry (IDv, dv,u) in Lu,nei
do
|
7. |
if (sv == “undecided”) and (dv,u ≤ Ru,intra) then
|
8. |
Compute node v’s MCH eligibility metric MMv according to the Formula (7) |
9. |
if (MMu < MMv) or (MMu == MMv && IDu > IDv) then
FLAG1 = false
|
10. |
end if
|
11. |
end for |
12. |
if (FLAG1 == true) then
|
13. |
Determine itself (i.e., node u) as the MCH and change the value of su as “decided MCH” |
14. |
Broadcast the updated su to its neighbors to which the distance is not more than Ru,intra from it |
15. |
else |
16. |
Set the timer tτ as τ
|
17. |
Initialize FLAG2 as true
|
18. |
while the timer tτ does not expire do
|
19. |
if receive a state variable (e.g., sv) from any node (e.g., v) then
|
20. |
if the received sv is “decided MCH” then
|
21. |
Change the value of su as “decided non-MCH” |
22. |
Broadcast the updated su to the neighbors to which the distance is not more than Ru,intra from u
|
23. |
FLAG2 = false
|
24. |
else update the initial value of sv kept in u as “decided non-MCH” |
25. |
end if
|
26. |
end if
|
27. |
end while
|
28. |
if (FLAG2 == true) then go to step 5 |
29. |
end if |