Chinaunix首页 | 论坛 | 博客
  • 博客访问: 67492
  • 博文数量: 46
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2017-04-22 16:11
文章分类
文章存档

2017年(46)

我的朋友

分类: 系统运维

2017-05-16 14:57:06

原文地址:NS技巧--怎么样广播数据 作者:yexin218

根据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);

}

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