| Algorithm 4. Cluster Member Association and FCH Selection (CMA-FCHS) | |
| Run at any non-CH node (e.g., w) Input: the hello messages of all neighbors Output: the membership request message |
|
| 1. | for each entry (IDu, du,w) in Lw,nei do |
| 2. | if the state variable su is “decided MCH” then initialize the flag variable fu as “unrequested” |
| 3. | end for |
| 4. | dmin = maximum number; IDmch = maximum number |
| 5. | for each entry (IDu, du,w) in Lw,nei do |
| 6. | if (fu == “unrequested”) and ((du,w < dmin) or (du,w == dmin && IDu < IDmch)) then {dmin = du,w; IDmch = IDu} |
| 7. | end for |
| 8. | Send the “membership request message” to the neighboring MCH with IDmch |
| 9. | if receive the “membership list message” from the neighboring MCH with IDmch (e.g., y) then |
| 10. | if find that its ID (i.e., w’s ID) is not in the “membership list message” then |
| 11. | if not more than the given maximum number of resending attempts then |
| 12. | fy = “requested” |
| 13. | Go to step 4 |
| 14. | end if |
| 15. | end if |
| 16. | end if |
| Run at a MCH node (e.g., u) which has a SCH node (e.g., v) Input: the hello messages of all neighbors Output: the membership list message |
|
| 17. | if receive the first “membership request message” from any non-CH node (e.g., w) then |
| 18. | Compute node w’s FCH eligibility metric FMw,v,u according to the Formula (9) |
| 19. | FMmax = FMw,v,u; IDfch = IDw |
| 20. | Add IDw to the membership list message |
| 21. | Set the timer tφ as φ |
| 22. | while the timer tφ does not expire do |
| 23. | if receive the “membership request message” from any non-CH node (e.g., x) then |
| 24. | if the number of cluster members is less than the threshold then |
| 25. | Add IDx to the membership list message |
| 26. | Compute node x’s FCH eligibility metric FMx,v,u according to the Formula (9) |
| 27. | if (FMmax < FMx,v,u) or (FMmax == FMx,v,u && IDx < IDfch) then {FMmax = FMx,v,u; IDfch = IDx} |
| 28. | end if |
| 29. | end if |
| 30. | end while |
| 31. | Declare the node with IDfch as the FCH through adding it to the membership list message |
| 32. | Design a TDMA schedule and add it to the membership list message |
| 33. | Broadcast the “membership list message” to its neighbors within the cluster radius |
| 34. | else if a new non-CH wants to join a given MCH and the number of cluster members is less than the threshold then |
| 35. | Update the TDMA schedule to include this node’s ID and add it to the “membership list message” |
| 36. | Broadcast the updated “membership list message” to its neighbors within the cluster radius |
| 37. | end if |