Research Article

CPEH: A Clustering Protocol for the Energy Harvesting Wireless Sensor Networks

Pseudocode 1

Pseudocode of the cluster construction process in CPEH.
Cluster Construction Process for sensor
1: At the beginning of the Round
2: Ifthen
3:  Broadcast a State_Message within
4: End if
5: On receiving the State_Message from its neighbor
6:  add to its neighbor set
7:  calculate its local energy state and local node density
8:  infer its chance and size base on the fuzzy logic system
9: Broadcast a Competition_Message ()
10: While the cluster head election time has not expired, do
11:  ifthen
12:  broadcast a Winner_Message () and then EXIT
13:  end if
14:  on receiving a Winner _Message from sensor
15:  ifthen
16:   broadcast a Quit _Message () and then EXIT
17:  end if
18:  on receiving a Quit_Message from sensor
19:  ifthen
20:   remove sensor from
21:   end if
22: end while
23: Ifthen
24:  On receiving the Join_Message from sensor
25:  if the current cluster size less than
26:   Accept the sensor , sending back the Accept_Message
27:  else Sending back the Reject_Message
28:  end if
29: Else
30:  Sending the Join_Message to the nearest CH
31:  On receiving the Accept_Message, finish
32:  On receiving the Reject_Message, delete the CH and repeat 30
33:  if all the neighbor CHs refuse to accept sensor
34:   
35:  end if
36: End if