Skip to main content
. 2019 Nov 21;19(23):5102. doi: 10.3390/s19235102
Algorithm 1 The Process of MD-MAC.
  • Input: node Ni, the previous neighbor Nj, the following neighbor Nk, time stamp K

  • Output: Initialization

  •  Each node initializes its time stamp       //add the time stamp

  • For t=1 to T

  • While t 2       //the first two period, collecting neighbors information

  •   Each node transmit with its neighbors and build its

  •   neighbor table

  • endwhile

  • If t>2 then       //start to adjust

  •   For i=1 to N

  •    If ϕi=0 then

  •     Ni send fire packet broadcast       //reach the firing point

  •    else                                           //adjust phase according to different cases

  •     If in case 1 & ϕj = 0 then

  •      Ni adjusts its phase to (1α)ϕi+αϕmid

  •     endIf

  •     If in case 2 & ϕoh=0 & Ki=Kth then

  •      (oh means one-hop neighbor and tw means

  •      two-hop neighbor)

  •      Ni adjusts its phase to (1α)ϕi+αϕmid

  •     endIf

  •     If in case 3 & ϕnearest=0 & Ki+1=Kj=Kk

  •     then

  •      Ni adjusts its phase to (1α)ϕi+αϕmid

  •     endIf

  •     endIf

  •   endFor

  • endIf

  •  Each node has occupied a period of the frame       //success to occupy time slots

  •  // Conflict detection process

  • If the collision occurs between nodes Ni and NJ in the one-hop    then       //punching

  •    Ni and Nj calculate the punching frame based on Mi and Mj

  •   In next period

  •    Ni and Nj keep listening in the frame they select

  • else

  •    the collision occurs between nodes Ni and NJ in the two-hop       //neighbor detection

  •    Nk is the junction node of Ni and Nj

  •    Nk send collision-warning packet to Ni and Ni backs off

  • endIf

  • endFor