[转]NS2添加多接口
此文為轉(zhuǎn)載,原文出處沒有查詢。。。有待添加
?
?
2009年05月11日
NS2中調(diào)試Multi-channel and Multi-interface 基于NS2的多信道多接口的底層環(huán)境已經(jīng)調(diào)試出來了,我們調(diào)試出了"Hyacinth"以及"Ramon A.C & Jesus P.C"的Multi-Channel & Multi-Interface兩種方案。這兩種方法也是MIMONS2比較適用的兩種。
前期我們找到的相關(guān)資料如下:
1.TENS:這是基于NS2.1b9的,http://www.cse.iitk.ac.in/users/braman/tens/
2.“Hyacinth”的Multi-Channel & Multi-Interface 方法 for ns2.29:http://www.cse.msu.edu/~wangbo1/ns2/nshowto8.html基于NS2.29
3. NOAH & Hyacinth : Multi-Channel & Multi-Interface Extension in NS2:http://dobbymmlab.blogspot.com/2008/07/multi-chann el-multi-interface-extension.html
4.這篇文章介紹了一個Multi-interface實現(xiàn)方法:Adding Multiple Interface Support in NS-2″(http://personales.unican.es/aguerocr)
5.“MW-Node” path for ns2 to support multiple interfaces & multiple channels:http://www.q2s.ntnu.no/~paquerea/ns.php
6.Aguero.C.R’s “Adding Multiple Interface Support in NS-2″:http://personales.unican.es/aguerocr/
7.NS-MIRACLE: Multi-InteRfAce Cross-Layer Extension library for the NS2:http://www.dei.unipd.it/wdyn/?IDsezione=3965
一些連接:
1.An IEEE 802.11-based Multi-channel Wireless Mesh Network:http://www.ecsl.cs.sunysb.edu/multichannel/
2.Extend ns2 to support multi-channle multi-interface for wireless network:http://my.opera.com/greenw/blog/show.dml/27506
3.Multi-channel Multi-interface Simulation in NS2 (2.29):http://www.cse.msu.edu/~wangbo1/ns2/nshowto8.html
柯老師也提供了這個修改的下載: http://140.116.72.80/~smallko/ns2/ns-allinone-2.29 multichan.rar
4.A new one for hyacinth for NS-2.29:http://my.opera.com/HenryFD/blog/show.dml/270422
5.Multichannel MAC Protocols for Wireless Networks:http://www.wings.cs.sunysb.edu/%7Eritesh/multichan nel-mac.html
6.Adding Multiple Interface Support in NS-2:http://personales.unican.es/aguerocr/files/ucMulti IfacesSupport.pdf
7.802.11 Multi-Channel, Multi-Flow and Multi-Hop in NS-2:http://www.wretch.cc/blog/mystylevisu/21319840
下面我就分別說一下。
一、"Hyacinth"的Multi-Channel & Multi-Interface方法for ns-2.29
這個方案詳情見http://www.cse.msu.edu/~wangbo1/ns2/nshowto8.html,我使用的版本是ns-2.29.3,因此建議大家也用這個版本。此外這個方案在臺灣柯老師的主頁上也有源碼下載http://140.116.72.80/~smallko/ns2/ns-allinone-2.29 multichan.rar
"Hyacinth"的方案優(yōu)勢在于信道分配的清晰明了,仿真環(huán)境tcl文件中會很清晰的添加信道,tag,數(shù)據(jù)流no.。但另一方面,該方案也有很多劣勢:只能支持靜態(tài)路由協(xié)議manual協(xié)議;tcl編寫時需要手工添加路由表(十分痛苦);拓展性不高等。
手工添加路由表很繁瑣。我舉例說明:
# Add routing tag
$node(0) add-route-tag 2 02
$node(1) add-route-tag 2 02
# Add next hop
$node(0) add-next-hop 2 02 1 2
$node(1) add-next-hop 2 02 2 2
如上述tcl文件,拓?fù)錇?—>1—>2,0如果要經(jīng)過1路由給給2就要在0上加去2的route tag,以及1去2的tag,相同的tag.其實也就是和實際的routing table上的標(biāo)識一樣. 然后做好tag后,增加nexthop. 0去2要走1通過nic2,1去2要走2通過nic2. nic可改。
網(wǎng)上還有以下內(nèi)容也許對你會有幫助:
# Add routing tag 這個function要有4個input 分別為 Newentry, add-route-tag, entry.dsy, entry.tag
以第一個entry來看 $node(0) add-route-tag 1 999 對照一下不難發(fā)現(xiàn)就是增加一條route table是從node0 傳到 node1 并且tag 設(shè)為 999
#Add next hop 這個function要有6個input 分別為 fixedrtableent, add-next-hop, dst, tag, next hop, nic
其中 nic 代表是使用的頻道數(shù) 對照一下第一個entry $node(0) add-next-hop 1 999 1 2
也不難理解就是一條 node0透過hop(node1), 傳給node1, tag為999, 使用第二頻道就在我當(dāng)我都了解他在干麼時,我想試著增加一個node做Multi-hop時卻一直無法成功傳遞最后成功的設(shè)定的route table如下
# add route tag #new entry , add-route-tag , entry.dst , entry.tag
$node(0) add-route-tag 1 999
$node(4) add-route-tag 1 999
$node(2) add-route-tag 3 8
# Add next hop #fixedrtableent newentry , add-next-hop , entry.dst , entry.tag , entry.hop , entry.nic
$node(0) add-next-hop 1 999 4 4
$node(4) add-next-hop 1 999 1 5
$node(2) add-next-hop 3 8 3 3
我新增了一個 node4在原先4個node的正中間 topology 像這樣
Node 1 Node3
Node4
Node0 Node2
然后設(shè)定封包 routing為node0先傳給node4再轉(zhuǎn)傳給node1 如下
# add route tag
$node(0) add-route-tag 1 999 ;#new entry , add-route-tag , entry.dst , entry.tag
$node(4) add-route-tag 1 999
# Add next hop
$node(0) add-next-hop 1 999 4 4 ;#fixedrtableent newentry , add-next-hop , entry.dst , entry.tag , entry.hop , entry.nic
$node(4) add-next-hop 1 999 1 5
在add route tag里面要先設(shè)一條route是從 0 -> 1 并將tag設(shè)為999必需還要有一條是 4->1 的routing且 tag 必需一樣
在add next hop里 也是一樣
要先設(shè)定一條 0->1 的路徑
$node(0) add-next-hop 1 999 4 4
node0 欲傳給 dst為1 , tag 為999, next-hop node4為轉(zhuǎn)傳點, 并且使用channel 4收送 第二條entry
$node(4) add-next-hop 1 999 1 5
node4 的dst為node1, tag是999, next-hop 因為沒有下一個節(jié)點了,於是便設(shè)為成接收點為1, 使用channel 5 來傳送
"Hyacinth"方案的拓展:
由于傳統(tǒng)的"Hyacinth"方案只支持靜態(tài)manual路由協(xié)議,但依然可以對其進行拓展。
Hyacinth的擴展不僅能在tcl里指定manual路由,它的multi-interface還可以被ns2其他路由在內(nèi)部調(diào)用,比如在aodv里調(diào)用. 如下:
Then in routing protocol or whereever the packet will be sent to different NIC, define coresponding downtarget for each interface to send out packet like (in header file):
NsObject *downtarget1;NsObject *downtarget2;NsObject *downtarget3;NsObject *downtarget4;NsObject *downtarget5;
Then get the corresponding objects from Tcl from command(int argc, const char*const* argv), for example in AODV:
aodv/aodv.cc:
int AODV::command(int argc, const char*const* argv) {if(argc == 2) {Tcl& tcl = Tcl::instance();...else if(argc == 3) {...// multi-channel supportelse if (strcasecmp (argv[1], "down-target-1") == 0) {downtarget1 = (NsObject *) TclObject::lookup(argv[2]);return TCLOK;}else if (strcasecmp (argv[1], "down-target-2") == 0) {downtarget2 = (NsObject *) TclObject::lookup(argv[2]);return TCLOK;}else if (strcasecmp (argv[1], "down-target-3") == 0) {downtarget3 = (NsObject *) TclObject::lookup(argv[2]);return TCLOK;}else if (strcasecmp (argv[1], "down-target-4") == 0) {downtarget4 = (NsObject *) TclObject::lookup(argv[2]);return TCLOK;}else if (strcasecmp (argv[1], "down-target-5") == 0) {downtarget5 = (NsObject *) TclObject::lookup(argv[2]);return TCLOK;}...
When send out the packet to different interface, just call one of them:
downtarget1->recv(p, (Handler *)0);downtarget2->recv(p, (Handler *)0);downtarget3->recv(p, (Handler *)0);downtarget4->recv(p, (Handler *)0);downtarget5->recv(p, (Handler *)0);
Then, everything is ok. It seems simple…
最后我把幾張仿真圖貼出來:
二、"Ramon A.C & Jesus P.C"的Multi-Channel & Multi-Interface方法
Romon的方法我在各個論壇中查資料的時候,發(fā)現(xiàn)調(diào)成功的人并不多甚至沒有。我?guī)熜趾蚏amon同志發(fā)了很多郵件討論過,最終Ramon進行了在Adding Multiple Interface Support in NS-2:(http://personales.unican.es/aguerocr/files/ucMulti IfacesSupport.pdf)基礎(chǔ)上的修改,最終調(diào)成功了。我們用的ns版本為ns-2.33,不過據(jù)Ramon說,ns的后幾個版本都是支持的。
Ramon的方案拓展性很好,很實用。不想說太多了,說以下做的仿真結(jié)果吧,cbr-200s仿真。
吞吐量:
單信道:recv:16328 throughput:347
多信道(設(shè)置為2信道):recv:32834 throughput:698
協(xié)議開銷:
單信道:cbrbytes:8686496, routebytes:556, routecosts:6.400739722898623334426217429905e-5
多信道(設(shè)置為2信道):cbrbytes:17467688, routebytes:710, routecosts:4.0646478228830283664329246091412e-5
延遲:
恩,不多說了。總體就是這樣,和幾位師兄一起做的很愉快。現(xiàn)在我正在想辦法把DSDV添加進來。
參考:
1 http://greenw.blogspot.com/2006/06/extend-ns2-to-s upport-multi-channle.html
2 http://www.wretch.cc/blog/mystylevisu/21319840
總結(jié)
以上是生活随笔為你收集整理的[转]NS2添加多接口的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: undefined reference
- 下一篇: [转贴]计算机学术期刊排名