title: Adding route into routing table using agent
body: <p>We planned to do final year project in the area of 
  underwater routing protocol (multi-hop communication) using UnetStack. In planned routing protocol, every node has to select its next hop out of many available neighbours. Before going in depth about selection of next hop algorithm, i would like to see how i can configure selected next hop in routing table using UnetStack.For that purpose i installed 5 nodes. Node 1 and 5 are destination and source nodes respectively. Neighbors of node 5 are node 3 and 4.Out of neighbors 3 and 4 , i would like to select node 3 as next hop of node 5 to reach destination.
  I am not able to add node 3 as next hop at node 5. It will be helpful, if you providing some input regarding this. </p>
  
  <p>I writen simuation script as follows:</p>
  
  <pre><code>channel.soundSpeed = 1500.mps           // c
  channel.communicationRange = 100.m     // Rc
  
  // run the simulation infinately
  simulate  {
   // Destination node
  node '1', remote: 1101, address: 1, location: [ 0.m, 0.m, 0.m], shell: true, stack: { container -&gt;
  container.add 'routing', new org.arl.unet.net.Router();
  container.add 'rdp', new org.arl.unet.net.RouteDiscoveryProtocol();  
  } 
  
  node '2', remote: 1102, address: 2, location: [ 0.m, 0.m, -75.m], shell: 5102, stack: { container -&gt;
  container.add 'new_routing_agent', new new_routing_agent();
  container.add 'routing', new org.arl.unet.net.Router();  
  container.add 'rdp', new org.arl.unet.net.RouteDiscoveryProtocol();
  }    
  
   // neighbor node for node 5, and will be a next node for node 5 during routing
  node '3', remote: 1103, address: 3, location: [0.m, 0.m, -90.m], shell: 5103, stack: { container -&gt;
  container.add 'new_routing_agent', new new_routing_agent();
  container.add 'routing', new org.arl.unet.net.Router();  container.add 'rdp', new org.arl.unet.net.RouteDiscoveryProtocol();   
  }
  
  //Neighbor node for node 5 ,but not a next node for node 5
   node '4', remote: 1104, address: 4, location: [0.m, 0.m, -150.m], shell: 5104, stack: {container -&gt;
  container.add 'new_routing_agent', new new_routing_agent();
  container.add 'routing', new org.arl.unet.net.Router();
  container.add 'rdp', new org.arl.unet.net.RouteDiscoveryProtocol();    
  }
  
  // Source node
  node '5', remote: 1105, address: 5, location: [0.m, 0.m, -160.m], shell: 5105, stack: {container -&gt;
  container.add 'new_routing_agent', new new_routing_agent();
  container.add 'routing', new org.arl.unet.net.Router();
  container.add 'rdp', new org.arl.unet.net.RouteDiscoveryProtocol();    
    }
  }
  </code></pre>
  
  <p>Agent: new_routing_agent as follows:</p>
  
  <pre><code>class new_routing_agent extends UnetAgent {
      def router;
      int addr;  
          // STARTUP  
     void startup() 
      {
  
          def phy = agentForService Services.PHYSICAL;
          subscribe topic(phy);
  
          router = agentForService Services.ROUTING;
          subscribe topic(router);
  
          def nodeInfo = agentForService Services.NODE_INFO;
          addr = nodeInfo.address; // obtain the address of the node
  
          def rdp = agentForService org.arl.unet.Services.ROUTE_MAINTENANCE
          def rsp = rdp &lt;&lt; new RouteDiscoveryReq(1)      // discover routes to node 1
  
      }
  
      void processMessage(Message msg) {  
      if (msg instanceof RouteDiscoveryNtf )  
      { 
          if (addr == 5)
          addroute 1, 3 ;
  
          else if (addr == 4)
          addroute 1, 2;
  
          else 
            addroute 1,1;     
      }  //End of if   
  } //End of processMessage
  } // End of class
  </code></pre>