Skip to main content
. 2016 Jun 7;16(6):835. doi: 10.3390/s16060835
Algorithm 1 PEAFC-CL
Upon Timer
BS: broadcast “Beacon” frame in network
foreach sensor node Ni do
  Reset Ci_request to 0
  Upon receiving a beacon frame from BS
  Compute Li_loss
  send “Probe_request” frame (contain: Ei_curr, Cirequest, Li_loss)
end
Upon receiving a Probe request frame from Ni
BS compute: Nactive, Mi_curr, Mr_aver, Mr_max, Er_max, Er_aver
If Tinitialize < current time < Tinitialize+TCH-election then
  BS broadcast “START_MSG” (contain: Nactive, Mi_curr, Mr_aver, Mr_max, Er_max, Er_aver)
  foreach sensor node Ni do
   Wi_r ← Random (0, Wr)
    If Wi_r < Ti(t) then
     Be cluster head ← TRUE
     NiGCH
    else
     Be cluster head ← FALSE
     NiG¯CM
    end
  end
else if Tinitialize+TCH-election < current time < TCF then
  foreach CH node do
   Broadcast “CLUSTER_HEAD_MSG” message
   Upon receivingh a “REQ_JOIN(intended_ID,CMj)” message
   if CH_ID=intended_ID then
    Record information contained in “REQ_JOIN
    Add CMj to CH Member node list
   else
    Discard “REQ_JOIN
   end
  end
  foreach CM node do
   Upon receivingh a “CLUSTER_HEAD_MSG” message
   Compute: LiCHn, Liall
   If LiCHn+LCHnBS<LiCHm+LCHmBS and LiCHn+LCHnBS<LiBS then
    intended_IDCHn_ID
    Broadcast “REQ_JOIN(intended_ID,CMj)” message
   end if
  end
end