Research Article

Fuzzy Weight Cluster-Based Routing Algorithm for Wireless Sensor Networks

Algorithm 2

The pseudocode implementation of the setup phase.
broadcast(ID, );
calculate(Deg); //Obtain the neighbor number
calculate(RSSIave); //Obtain the average RSSI of my neighbors
//normalization procedure of Deg
;
if (CFWA_1)
elseif (CFWA_2)
elseif (CFWA_3)
;
if (!receive(c1uster head) &&   == )//now is the current time, not receive//any advertisement
 broadcast(cluster head); //declare itself as cluster head
 headFlag = 1; //cluster head mark is set
if ( == )//if has received some message
   = receivedCHList; //load in the list
  if (length(receivedCHList) != 0)
  
   currentCH = selectCH(); //select cluster head
     join(currentCH); //send join information
  
  else
  
      sleep( );
  
if (HeadFlag == 1)//cluster head
 creatTDMA( ); //generate TDMA schedule
 if (currentCH == Sink) {broadcast(TDMA);}
 if (receive(TDMA)) {broadcast(TDMA);}
else
  receive(TDMA);