Add multiple interface support in NS-2.33

Introduction:

Codes in this archive add multiple interface support in NS-2.33. I accomplished this work, thanks to Ramon's notes (http://personales.unican.es/aguerocr/). There are many places need to be modified, and there is one line need to be deleted form the legacy tcl code not be pointed out in Ramon's notes, I spent a lot of time to get it worked successfully. Therefor, I decided to share these codes with others who have the same requirement for NS

How to use:

Copy dirs in ns-2.33 to your own ns-2.33, then "make clean", "make"
Use "ns multi/single-interface.tcl" in example dir to run the simulation

Notice:

1. Single-interface scenario could be demonstrated correctly by nam, while multi-interface's nam file has some errors. However, the trace file of the multi-interface scenario shows that the multi-interface module works correctly. From the trace file we could find out that node 1 received data from mac address 0, and then forwarded to node 2. Node 2 received tcp packets from source MAC address 2, while in single-interface scenario the source MAC address would be 1.
Node 0                        Node 1                     Node 2
channel 0            channel 0    channel 2     channel 2
MAC 0                    MAC 1        MAC 2         MAC 3

2. For the single-interface scenario, code generated by NSG2 or NSBench works well. However, for the multi-interface scenario, there would be some constraints for the variabe names in the scenario script.
    1. set ns_ [new Simulator] ;# The simulator instance's variabe name must be ns_
    2. set tracefd [open multi-interface.tr w] ;# The trace file handle's variabe name must be tracefd

Download: Add multiple interface support in NS-2.33

Tags: NS2,Ramon

为NS2添加多接口支持的代码,Ramon版本

关于如何在NS2的基础上添加多接口支持,大家可以google一下,有相关的网页说明。其中比较有名的是Ramon版本(http://personales.unican.es/aguerocr/)。他有一个PDF文件,详细说明了需要修改哪些文件。但是关是这个工作也是挺烦人的。我花了一下午时间来修改所有需要修改的文件。结果死活运行不起来。花了一整个晚上来找错误,把生成节点到AODV收发请求与应答,到Channel的sendUp,全调试了个遍。死活没搞定,今天再详细看一遍,发现是在ns-mobilenode.tcl里有一句需要删除的语句,在Ramon的文档里没有说明这一点,在代码里也没有用黑体标出来,把这里改好,终于可以看到多接口收发的效果了。

之前我是想找现成的代码下载的,有人改好运行成功了但就是不共享。只能自己按着Ramon的PDF上一处处的修改,深知这种痛苦,改得不好就跟我上面样出错。因此决定把我改好的代码共享出来,代码修改是基于NS 2.33的。

下载压缩包把ns-2.33下面的文件夹复制到自己的ns目录然后重编译NS就行了。example目录下的是多接口和单接口的两个例子。下面说明几点需要注意的地方

1、单接口例子出来的nam文件是可以正常演示的,多接口的没法用动画演示。但是看trace文件可以发现多接口是正常工作的。因为数据转发的MAC地址是变化的。节点2收到数据的源MAC来自于节点1的第二个接口

Node 0                           Node 1                              Node 2
channel 0             channel 0    channel 2               channel 2
mac 0                       mac 1           mac 2                  mac 3

2、单接口例子里的变量名是可以随便取的,我这个例子是直接用NSG2生成的代码,AODV可以正常工作。多接口的例子里,在场景文件里有两个变量的命名受到约束,如果不这么命名会报TCL脚本错误

             1. set ns_ [new Simulator] ;# 仿真器变量的名字必须是 ns_
             2. set tracefd [open multi-interface.tr w] ;# trace文件句柄对应的变量必须是 tracefd

其他还有什么问题的话可以在这里发表评论,大家一起探讨一下

Tags: NS2,Ramon,多接口