I've set up my routing algorithm from node itself. After this I want to send datagrams from physical layer in that route itself.
For example if my routes are 1 to 2 and 2 to 3 and I want to send a datagram from 1 to 3 I want my datagram to go through 2.
For this routing table for 1 will be as follows:
Routing table for 1
- to: 3 nextHop: 2
- to: 2 nextHop: 2
- to: 1 nextHop: 1
So I want my process msg function to be as follows:
void processMessage(Message msg) {
if (msg instanceof DatagramNtf && msg.protocol == PING_PROTOCOL && msg.to != nodeInfo.addr)
def dG = new DatagramReq(to: routes.nextHop(msg.to), destination: msg.to)
send new DatagramReq(recipient: msg.sender, to: msg.from, protocol: Protocol.DATA)
}
also what routes.nextHop does is takes in the addr of the destination node and from the routing table gets the next hop.
I want to know to how to get the nextHop from routing table.