| Procedure main_algorithm(){ |
| //check the route from the node to sink k. |
| If (node. hop==∞) or (the lifetime is over){ |
| //broadcast the RREQ packet and wait for RREP |
| Packet |
| Initialize the RREQ packet |
| routing_algorithm(packet); |
| } |
| // After the routing is built up |
| Initialize the pheromone. |
| // When sending data |
| path_algorithm(); |
| if (the data is transmitted successfully) { //receive |
| the ACK packet |
| k = packet.sink; //the ACK packet |
| update_pheromone_algorithm (, , , 0, ); |
| } |
| else |
| update_pheromone_algorithm (0, 0, , , ); |
| Wait for the next data transmission; |
|
}
|