Research Article

Data Dissemination Protocol for Mobile Sink in Wireless Sensor Networks

Algorithm 2

Tree construction and relay node selection.
Data structure for any sensor node :
: children set of node , initialized to .
: parent of node , initialized to .
: set of relay nodes in the network.
: set to true once the sensor node selects its parent, initialized to false.
: set to true once the sensor node sends T_MSG packet, initialized to false.
: the set of neighbors of node , which are willing to be the relay node, initialized to .
Node receives following packets from node :
T_MSG: T_MSG,
If ( ) then
   ;
   ;           ⊳ node declares itself as a relay node
  Drop the packet;
else if ( and ) then
   ;
   ;
  if ( ) then
   ;
   (T_MSG, );             ⊳ Broadcast T_MSG packet
  else
  Drop the packet;
  end if
else
  Drop the packet;
end if
   ⊳ Timeout occurs to the node when the time duration expires for the tree construction
phase and become .
if ( ) then
  if ( ) then
   (T_ERR, );                 ⊳ Broadcast T_ERR packet
  end if
end if
T_ERR: T_ERR,
If     then
   ;
   (T_MSG, );               ⊳ Broadcast T_MSG packet
else
  Drop the packet;
end if