Follow the procedure I indicated in that other thread, as many times as necessary, each time getting one step closer to the destination.
There are two different ways you can proceed:
- At the source node, you work out the complete path to the destination node. When you transmit the data, prefix it with the remaining path. The node you hand over to will be responsible for contacting the next hop and transmitting the data to it with its own address stripped from the path list. Or:
- At the source node, figure out a node that is "closer" to the destination. There might be enough information to predict a likely complete path, but there might not be, and even if there is enough information, it could be that a node in the predicted path will become unavailable while the data is being relayed. Transmit the data to the predicted next step along the way, prefixed by an indication of the final destination, but not all of the predicted steps in the route. At the receiving node, again predict the best route and forward the packet onwards, hopefully getting closer and closer to the destination each time.
The first option, predicting the complete path and having each node required to follow it, runs the risk that a node will become unavailable, leaving it undefined how the packet should continue. The second option, continually predicting the path along the way, runs the risk that based on the path information as known to the receiving node, the packet will be sent to a node that has already handled it in the trip (possibly right back to the node that just send it here), potentially resulting in an infinite loop for the packet.
Both of these are classic routing problems in networking, and there is no solution that guarantees delivery or shortest delivery. There have been a number of routing protocols invented to work with these problems, with trade-offs necessarily taken. You need to investigate routing protocols and decide which one you are going to use.