作者CxMacchi (Carael Macchiato)
看板Network_Sim
標題[問題] NS2的wireless廣播
時間Sun Feb 21 16:49:26 2010
小弟是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);
--
《Sometimes Love Just Ain't Enough》 Yan-zi
"But there's a danger in loving somebody too much.
And its sad when you know it's your heart you can't trust.
There's a reason why people don't stay where they are.
Baby sometimes love just ain't enough."
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.216.89
※ 編輯: CxMacchi 來自: 140.116.216.89 (02/21 16:49)
※ 編輯: CxMacchi 來自: 140.116.216.89 (02/21 16:50)
推 abilitylife:這應該是給Routing Agent用的 02/24 03:44
→ abilitylife:其實也不一定,反正上層的Agent只要new一個這樣的 02/24 03:46
→ abilitylife:往下送自然就會Broadcast出去 02/24 03:46
→ abilitylife: Packet 02/24 03:46
→ CxMacchi:謝謝樓上,有一點想法了 先試看看 :) 02/24 14:02
→ CxMacchi:自己回..發現在2.34裡有內建的module 當初眼殘沒看到... 08/29 22:47