(*Run the following at each node *)
Get the information of current remaining energy EA.
Set timer;
  if     then
 status = CH;
 Broadcast containing (CHID, CHEA, HC, SEA) to neighbors.
if  Receive a   then
  If     then
   status = NORMAL;
  end if
end if
 Receive from neighbors.
if   does not contains .NID  then
  Add .NID to ;
   timer fires;
  Broadcast to its members.
end if
  else
 status = NORMAL;
 Receive a message.
if     then
  status = CH;
(22) end if
(23) if  message == from CH(s)  then
  Add .CHID to ;
   = .SID;
   timer fires;
  Send to its parent node.
  if     then
   HC=HC+1;
   Broadcast to neighbors.
  end if
else
  if  message ==   then
   Send the to its parent node.
  else
   if  message == from CH(s)  then
    Update its .
   end if
  end if
end if
if  its has more than one CHID  then
  Status = Boundary;
  Add .CHID to ;
  Send its and to its parent node.
else
  Receive and from Boundary nodes.
end if
  end if
Algorithm 1: The -OCHE algorithm.