2

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.

pr0py_s
  • 171
  • 9

1 Answers1

3

To send datagrams using route table entries, you need to use router agent, which inturn uses link and phy agents to send your datagram to the destination.Further routing of packets to the destination will be taken care by router agent itself.Hence I don't think you need to determine nextHop here for the to field in DatagramReq.

Your DatagramReq can be as-

router.send new DatagramReq(recipient: msg.sender, to: msg.from, protocol: Protocol.DATA)

Assuming router is the AgentID defined, and value of msg.from is your destination, and there is a valid route in the route table.

Further, nextHop or getNextHop() returns the address of neighbor node.