[问题] NS2的wireless广播

楼主: CxMacchi (Carael Macchiato)   2010-02-21 16:49:26
小弟是ns2新手 恰巧最近开始接触VANET相关的研究
想在ns2上先练习实作简单的广播功能 以期未来可以做区域广播的动作
却发现ns2在wireless部份似乎没有提供广播的功能
于是参考过网络上一些资料后发现这个解法
http://mailman.isi.edu/pipermail/ns-users/2000-June/009635.html
但在文章修改过ll.cc过后的部份却不太能理解
下面这一段是应该另外新增一个Agent或者是加在哪边呢?
又或者是否有已开发完毕的模组有提供广播功能?
先谢谢各位大哥了 @@
// Create a new packet
Packet* pkt = allocpkt();
// Access the common header for the new packet:
hdr_cmn* cmnhdr = (hdr_cmn*)pkt->access(off_cmn_);
// Access the IP header for the new packet:
hdr_ip* iphdr = (hdr_ip*)pkt->access(off_ip_);
// set all the necessary things for the common header
cmnhdr->next_hop_ = IP_BROADCAST; // broadcast
// now the ip header stuff
iphdr->saddr() = myAddress;
iphdr->sport() = myPort;
iphdr->daddr() = IP_BROADCAST;
iphdr->dport() = desiredDestinationPort;
// I do this just to be sure that it isn't forwarded
// beyond the neighbors
iphdr->ttl() = 1;
// this is taken from dsragent::sendOutBCastPkt
Scheduler::instance().schedule(ll, pkt, 0.0);
// return TCL_OK, so the calling function knows that the
// command has been processed
return (TCL_OK);
作者: abilitylife   2010-02-24 03:44:00
这应该是给Routing Agent用的其实也不一定,反正上层的Agent只要new一个这样的往下送自然就会Broadcast出去Packet
楼主: CxMacchi (Carael Macchiato)   2010-02-24 14:02:00
谢谢楼上,有一点想法了 先试看看 :)自己回..发现在2.34里有内建的module 当初眼残没看到...

Links booklink

Contact Us: admin [ a t ] ucptt.com