[問題] 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