心若在梦就在
854727449
全部博文(46)
2017年(46)
仙女6666
lting
Elaine20
三分酿成
wojiuzhu
wufengwu
lesliejy
分类: 系统运维
2017-05-16 14:57:06
原文地址:NS技巧--怎么样广播数据 作者:yexin218
根据AODV中recv()函数的代码,我们可以知道,只需要将IP包头的目的地址设为广播地址即可,ih->daddr() != IP_BROADCASTvoidAODV::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);}
上一篇:NS技巧--怎样从trace文件中获得从节点a发送到b的数据报经历的路径
下一篇:NS技巧--改变节点在nam中显示的颜色
登录 注册