Research Article

Energy-Efficient Adaptive Geosource Multicast Routing for Wireless Sensor Networks

Algorithm 5

Packet forwarding at each node.
Input: serialized path, node
(1) if  FirstBit(path 0 ) == 1 then
(2)  // the first byte in path is a delimiter
(3)  if  ID(node) {IDs pointed by the delimiter} then
(4)   pos1 = indexInPath(node) + 1
(5)   pos2 = indexInPath(next node pointed by delimiter after me) − 1
(6)   path = {path pos1 , …, path pos2
(7)   Forward(path)
(8)  end if
(9) else
(10)  if  FirstTwoBits(path 0 ) == 01 then
(11)   // the first byte in path is x coordinate
(12)   // path , path are X and y coordinates
(13)   of a branch or a destination
(14)   if  path 2 Null then
(15)    path = {path 2 , …, path length(path) − 1
(16)   end if
(17)   Forward(path)
(18)  else if  FirstTwoBits(path 0 ) == 00 then
(19)   // the first byte in path is an ID
(20)   path = {path 1 , …, path length(path) − 1
(21)   Forward(path)
(22)  end if
(23) end if