10: According to the source field of the routing packet, find the corresponding record in the routing result and update it. If not found, record the source, suc, nexthop, pathlength value of the routing packet
11: ifoptimalsourcethen
12: suboptimal_nexthop ← optimal nexthop;
13: suboptimal_success ← optimal success;
14: suboptimal_hop ← optimal_hop
15: suboptimal_threshold←optimal_threshold
16: end if
17: optimal_nexthoop←source
18: optimal_success←suc
19: optimal_hop←path_length+1
20:
21: optimal_threshold⟵1
22: whiledo
23:
24: optimal_threshold⟵optimal_threshold+1
25: end while
26: generate routing packets according to Algorithm 3 and inform neighbor nodes