Research Article

A Network Coding-Based Braided Multipath Routing Protocol for Wireless Sensor Networks

Algorithm 4

HMPN topology formation.
(1) Sink broadcast probe message
(2) Upon sink receives message from node u
(3) if messagetype == ack then
(4)  if sum of received ack messages == neighbor number then
(5)   broadcast level update message in order to give the turn to first level
(6)  end if
(7) else if messagetype == lupack
(8)  if sum of received lupack and lupnack messages == neighbor number then
(9)   broadcast level update message in order to give the turn to next level
(10)  end if
(11) else if messagetype == lupnack then
(12)  if sum of received lupack and lupnack messages == neighbor number then
(13)  if all received messages are lupnack messages then
(14)   Terminate
(15)  else
(16)   broadcast level update message in order to give the turn to next level
(17)  end if
(18)  end if
(19) end if
(20) end Upon
(21) Upon node u receives message from node
(22) if messagetype == probe then
(23)  if message.level < v.level then
(24)   Insert node into parentlist and send ack message to node
(25)  end if
(26) else if messagetype == lupack then
(27)  if sum of received lupack and lupnack messages == neighbor number then
(28)  broadcast lupack to parents
(29)  end if
(30) else if messagetype == lupnack then
(31)  if sum of received lupack and lupnack messages == neighbors’ number then
(32)   if node u has not received any lupack message then
(33)    call Algorithm 2and broadcast lupnack to parents//∗Network coding
(34)   else
(35)    broadcast lupack to parents
(36)   end if
(37)  end if
(38) else if messagetype == lup then
(39)  if node is one of the parents of node u then
(40)   if node u has no neighbor then broadcast lupnack message to parents
(41)   else if level of node u == received level value in lup message then
(42)    broadcast probe by the level value in message = level of node + 1
(43)   else if level of node u < received value in lup message then
(44)    broadcast received lup message for forwarding to children nodes
(45)   end if
(46)  end if
(47) else if messagetype == ack then
(48)  if ackNum == Neighbor number then
(49)   broadcast lupack message to parents
(50)  end if
(51) end if
(52) end Upon