此文为转载,原文出处没有查询。。。有待添加
2009年05月11日
NS2中调试Multi-channel and Multi-interface 基于NS2的多信道多接口的底层环境已经调试出来了,我们调试出了"Hyacinth"以及"Ramon A.C & Jesus P.C"的Multi-Channel & Multi-Interface两种方案。这两种方法也是MIMONS2比较适用的两种。
前期我们找到的相关资料如下:
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实现方法: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"的方案优势在于信道分配的清晰明了,仿真环境tcl文件中会很清晰的添加信道,tag,数据流no.。但另一方面,该方案也有很多劣势:只能支持静态路由协议manual协议;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文件,拓扑为0—>1—>2,0如果要经过1路由给给2就要在0上加去2的route tag,以及1去2的tag,相同的tag.其实也就是和实际的routing table上的标识一样. 然后做好tag后,增加nexthop. 0去2要走1通过nic2,1去2要走2通过nic2. nic可改。
网上还有以下内容也许对你会有帮助:
# Add routing tag 这个function要有4个input 分别为 Newentry, add-route-tag, entry.dsy, entry.tag
以第一个entry来看 $node(0) add-route-tag 1 999 对照一下不难发现就是增加一条route table是从node0 传到 node1 并且tag 设为 999
#Add next hop 这个function要有6个input 分别为 fixedrtableent, add-next-hop, dst, tag, next hop, nic
其中 nic 代表是使用的频道数 对照一下第一个entry $node(0) add-next-hop 1 999 1 2
也不难理解就是一条 node0透过hop(node1), 传给node1, tag为999, 使用第二频道就在我当我都了解他在干麼时,我想试著增加一个node做Multi-hop时却一直无法成功传递最后成功的设定的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
然后设定封包 routing为node0先传给node4再转传给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里面要先设一条route是从 0 -> 1 并将tag设为999必需还要有一条是 4->1 的routing且 tag 必需一样
在add next hop里 也是一样
要先设定一条 0->1 的路径
$node(0) add-next-hop 1 999 4 4
node0 欲传给 dst为1 , tag 为999, next-hop node4为转传点, 并且使用channel 4收送 第二条entry
$node(4) add-next-hop 1 999 1 5
node4 的dst为node1, tag是999, next-hop 因为没有下一个节点了,於是便设为成接收点为1, 使用channel 5 来传送
"Hyacinth"方案的拓展:
由于传统的"Hyacinth"方案只支持静态manual路由协议,但依然可以对其进行拓展。
Hyacinth的扩展不仅能在tcl里指定manual路由,它的multi-interface还可以被ns2其他路由在内部调用,比如在aodv里调用. 如下:
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的方法我在各个论坛中查资料的时候,发现调成功的人并不多甚至没有。我师兄和Ramon同志发了很多邮件讨论过,最终Ramon进行了在Adding Multiple Interface Support in NS-2:(http://personales.unican.es/aguerocr/files/ucMulti IfacesSupport.pdf)基础上的修改,最终调成功了。我们用的ns版本为ns-2.33,不过据Ramon说,ns的后几个版本都是支持的。
Ramon的方案拓展性很好,很实用。不想说太多了,说以下做的仿真结果吧,cbr-200s仿真。
吞吐量:
单信道:recv:16328 throughput:347
多信道(设置为2信道):recv:32834 throughput:698
协议开销:
单信道:cbrbytes:8686496, routebytes:556, routecosts:6.400739722898623334426217429905e-5
多信道(设置为2信道):cbrbytes:17467688, routebytes:710, routecosts:4.0646478228830283664329246091412e-5
延迟:
恩,不多说了。总体就是这样,和几位师兄一起做的很愉快。现在我正在想办法把DSDV添加进来。
参考:
1 http://greenw.blogspot.com/2006/06/extend-ns2-to-s upport-multi-channle.html
2 http://www.wretch.cc/blog/mystylevisu/21319840