[ns] routing agent

Fernando Correia fernandocorreia at oninet.pt
Sun Feb 18 03:35:16 PST 2007


I already did something like that. I create a new agent to generate 
traffic, but to put it to work with AODV, what I did was to change some 
lines in recv() from AODV class in order for AODV to process this kind 
of agent.
It is also necessary to change *size* field from common header, so you 
can add some info formation to your agent, for AODV to update this field.

Above is the code that I use in AODV, and works fine for me.

Fernando

/*
  Packet Reception Routines
*/

void
AODV::recv(Packet *p, Handler*) {
  struct hdr_cmn *ch = HDR_CMN(p);
  struct hdr_ip *ih = HDR_IP(p);
  struct hdr_cbr* cbrh= HDR_CBR(p);

 assert(initialized());
 //assert(p->incoming == 0);
 // XXXXX NOTE: use of incoming flag has been depracated; In order to 
track direction of pkt flow, direction_ in hdr_cmn is used instead. see 
packet.h for details.

  if(ch->ptype() == PT_AODV) {
    ih->ttl_ -= 1;
    recvAODV(p);
    return;
  }
 
 
 /*
  *  Must be a packet I'm originating...
  */
if((ih->saddr() == index) && (ch->num_forwards() == 0)) {
         // verify traffic for my CBR agent
    if(ch->ptype() == PT_TXCBR){
      ih->daddr() = cbrh->daddr;
      cbrh->saddr = getNodeAddr();
      ch->size() += (IP_HDR_LEN + cbrh->len);
    }
    else
      // Add the IP Header
      ch->size() += IP_HDR_LEN;

    if ((u_int32_t)ih->daddr() != IP_BROADCAST){
      ih->dport() = RT_PORT;
      ih->ttl_ = NETWORK_DIAMETER-1;
    }
}
 /*
  *  I received a packet that I sent.  Probably
  *  a routing loop.
  */
else if(ih->saddr() == index) {
   drop(p, DROP_RTR_ROUTE_LOOP);
   return;
 }
 /*
  *  Packet I'm forwarding...
  */
 else {
 /*
  *  Check the TTL.  If it is zero, then discard.
  */
   if(--ih->ttl_ == 0) {
     drop(p, DROP_RTR_TTL);
     return;
   }
 }
// Added by Parag Dadhania && John Novatnack to handle broadcasting
 if ( (u_int32_t)ih->daddr() != IP_BROADCAST)
   rt_resolve(p);
 else
   forward((aodv_rt_entry*) 0, p, NO_DELAY);
}

nsuser12 wrote:
> i have created a new agent,and i want to send packets from this agent using
> aodv routing agent.
> please help me how i can access this feature from inside c++.
>   



More information about the Ns-users mailing list