(1)
(2)if then
(3) Prepare RREP for each RREQ packet received
(4)
(5)end if
(6)if then
(7) Compute as in equation (9)
(8)if then
(9)  
(10)end if
(11) to the downstream node along the path
(12)end if
(13)if then
(14) Receive first RREP and start a timer
(15)while do
(16)  Hold the RREQ packet in the table
(17)end while
(18) Choose the route with minimum
(19)
(20)end if
Algorithm 2: Route reply algorithm.