Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6628389
  • 博文数量: 227
  • 博客积分: 10047
  • 博客等级: 上将
  • 技术积分: 6678
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-11 10:33
个人简介

网上的蜘蛛

文章分类

全部博文(227)

文章存档

2010年(19)

2009年(29)

2008年(179)

分类: 系统运维

2008-07-25 16:10:33

根据AODV中recv()函数的代码,我们可以知道,只需要将IP包头的目的地址设为广播地址即可,ih->daddr() != IP_BROADCAST

void

AODV::recv(Packet *p, Handler*) {

//访问通用以及IP包头

struct hdr_cmn *ch = HDR_CMN(p);

struct hdr_ip *ih = HDR_IP(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)) {

 /*

  * Add the IP Header

  */

   ch->size() += IP_HDR_LEN;

   // Added by Parag Dadhania && John Novatnack to handle broadcasting

   if ( (u_int32_t)ih->daddr() != IP_BROADCAST)

     ih->ttl_ = NETWORK_DIAMETER;

}

 /*

  * 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);

}

阅读(2817) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~