Skip to main content
. 2016 Sep 25;16(10):1576. doi: 10.3390/s16101576
Algorithm 3. SCH Selection (SCHS)
Run at any MCH node (e.g., u)
Input: the hello messages of all neighbors
Output: SCH confirmation message
1. for each entry (IDv, dv,u) in Lu,nei do initialize the label variable lv as “uninvited
2. SMmax = 0; IDsch = maximum number
3. for each entry (IDv, dv,u) in Lu,nei do
4.   if (dv,u ≤ Ru,intra) and (lv == “uninvited”) then
5.    Compute node v’s SCH eligibility metric SMv,u according to the Formula (8)
6.    if (SMmax < SMv,u) or (SMmax == SMv,u && IDv < IDsch) then {SMmax = SMv,u; IDsch = IDv}
7. end if
8. end for
9. Send the “SCH invitation message” to the neighbor IDsch
10. if eavesdrop the “SCH acceptance message” from the invited node (i.e., IDsch) that does not accept its (i.e., u’s) invitation then
11.   Change the value of the invited node’s label variable as “invited
12.  Go to step 2
13. end if
14. if receive the “SCH acceptance message” from the invited node (i.e., IDsch) that accepts its (i.e., u’s) invitation then
15.   Broadcast the “SCH confirmation message” at its maximum transmission power
16. end if
Run at any non-MCH node (e.g., v)
Input: the hello messages of all neighbors
Output: SCH acceptance message
17. if receive the first “SCH invitation message” from any MCH (e.g., w) then
18.   dmin = dv,w; IDmch = IDw
19.   Set the timer tζ as ζ
20.   while the timer tζ does not expire do
21.    if receive the “SCH invitation message” from any MCH (e.g., u) then
22.     if (dv,u < dmin) then {dmin = dv,u; IDmch = IDu}
23. end if
24.   end while
25.  Send the “SCH acceptance message” to the neighbor IDmch
26.   Set the timer tθ as θ
27.   Initialize FLAG as true
28.   while the timer tθ does not expire do
29.    if receive the “SCH confirmation message” from a MCH that selects itself (e.g., v) as SCH then FLAG = false
30.   end while
31.   if (FLAG == true) then move to the next step (determining cluster members and selecting FCHs)
32. end if