(1) /* forager received from MAC layer */ |
(2) for each ( received from MAC layer) { |
(3) if ( arrived at ) |
(4) send to packingFloor; |
(5) else { |
(6) collect optimization parameter from the node; |
(7) //delay, lifetime, or energy consumption |
(8) sendPacketToNextHop (); |
(9) } |
(10) } |
(11) |
(12) /* scout received from MAC layer */ |
(13) for each ( received from MAC layer) { |
(14) if ( is on return path toward ) { |
(15) if ( is at ) |
(16) send to packingFloor; |
(17) else { |
(18) sendPacketToNextHop (); |
(19) } |
(20) } |
(21) else if ( is on forward path toward ) { |
(22) var = danceFloor · getForager(); |
(23) if ( != NULL) { |
(24) insert in payload of ; |
(25) insert in payload of other foragers in danceFloor; |
(26) complete the route by concatenating + ; |
(27) change to a backward scout; |
(28) reverse the source route in the header; |
(29) sendPacketToNextHop (); |
(30) } |
(31) else { |
(32) if (TTL expired ∣∣ exists in seenScoutList) |
(33) if ( list collected from is empty) |
(34) kill ; |
(35) else { |
(36) insert in payload of foragers from danceFloor; |
(37) change to a backward scout; |
(38) reverse the source route in the header; |
(39) sendPacketToNextHop (); |
(40) } |
(41) else { |
(42) insert in payload of foragers from danceFloor; |
(43) insert address in the source route header; |
(44) insert and source of into seenScoutList; |
(45) decrease TTL; |
(46) broadcast to all neighbors of ; |
(47) } |
(48) } |
(49) } |
(50) } |
(51) |
(52) /* forager received from packing floor */ |
(53) for each ( received from Packing floor) { |
(54) collect optimization parameter from the node; |
(55) sendPacketToNextHop (); |
(56) } |
(57) |
(58) /* scout received from packing floor */ |
(59) for each ( received from Packing floor) { |
(60) insert address in the source route header; |
(61) insert and source of into seenScoutList; |
(62) decrease TTL; |
(63) broadcast to all neighbors of ; |
(64) } |
(65) |
(66) void sendPacketToNextHop () |
(67) { |
(68) find in the source route header; |
(69) send to MAC Interface of ; |
(70) } |