使用长庚大学的NS2的WIMAX模块做仿真,结果trace文件的mac地址总是很奇怪,而且nam的动画显示仿真过程中有问题。
一步步的查啊查,最后发现问题在cmutrace类(trace/cmu-trace.cc)中。一下分析全部是针对老版本的trace格式,请自行修改变通。
hdr_mac802_11(mac/mac-802_11.h)与hdr_mac(mac/mac.h)使用的是同一块内存空间,而我所使用的802.16的头部,是在hdr_mac的基础上再加了一个hdr_mac802_16,也就是说,如果要取mac地址相关信息,应该是从hdr_mac中间取。
阅读全部内容…
Tags:
yhustc On
ns2仿真 @ 2010-07-23 16:08:31 |
没有评论
一直用debian的VPS运行NS2的,因为我都是看trace。
今天修改了一个支持WIMAX的NS 2.33,想用nam看看动画,所以装了一个cygwin,准备编译NS2。
cygwin的安装镜像可以使用这个,速度很快 http://www.cygwin.cn/pub/
安装所需的一些包:XFree86/xorg, autoconf, make, patch, perl, gcc, gcc-g++, gawk, gnuplot, tar, gzip
然后就开始install了,结果cygcheck -c gcc的时候显示没有安装gcc。仔细查了一下,发现安装的时候选软件包,有gcc,但是体积更大的,是那个gcc-core。看了一下gcc的说明,只是一个update helper,估计实际用还是用gcc-core。
阅读全部内容…
Tags:
yhustc On
ns2仿真 @ 2010-07-16 13:31:58 |
1条评论
做一个跨层优化的仿真,在应用层Application里面要访问OLSR的路由表项,结合底层路由信息做P2P的传输策略优化。OLSR使用的是UM-OLSR。
根据UM-OLSR的说明,如果要对单个节点上的agent进行设置,可以使用如下代码
TCL代码
- set ra [$mobilenode agent 255]
- $ra set use_mac_ true
- $ra set tc_ival_ 6
这说明,ra取到的是对应agent的引用,可以直接操作这个路由agent了。
阅读全部内容…
Tags:
yhustc On
ns2仿真 @ 2010-07-07 17:28:23 |
9条评论
我在这里提供了一个修改的NS2的多接口代码,有朋友反应在运行多接口示例的代码时报错,错误发生在调用change-numifs函数的时候。之前我回复说无法复现这个问题,估计是因为我的代码确实没问题。今天师弟叫我帮忙看看,我发现报的错跟那两位朋友是一样的。然后我去ns-2.33/tcl/lib/ns-lib.tcl里面调试,发现他的这个文件里面根本没有change-numifs函数,这个函数应该是在2277行。后来师弟发现解压没搞正确,没有覆盖掉原来的ns-lib.tcl,所以没有增加修改后的那部分代码。遇到这个错误的朋友可以打开这个文件确认一下是不是修改过的版本。
Tags:
yhustc On
ns2仿真 @ 2010-03-21 16:50:06 |
5条评论
I have provided NS2 files which add multiple interface support in NS-2.33 in this page. Comments show that there are runtime error when executing the multi-interface sample. I came across this problem today, the reason is that modified files have not been unpacked correctly.
So, if you meet this runtime error, please check whether there is a change-numifs funtion in ns-2.33/tcl/lib/ns-lib.tcl at line 2277
Tags:
yhustc On
ns2仿真 @ 2010-03-21 16:32:47 |
4条评论
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:
yhustc On
ns2仿真 @ 2009-10-31 20:27:09 |
10条评论
关于如何在NS2的基础上添加多接口支持,大家可以google一下,有相关的网页说明。其中比较有名的是Ramon版本(http://personales.unican.es/aguerocr/)。他有一个PDF文件,详细说明了需要修改哪些文件。但是关是这个工作也是挺烦人的。我花了一下午时间来修改所有需要修改的文件。结果死活运行不起来。花了一整个晚上来找错误,把生成节点到AODV收发请求与应答,到Channel的sendUp,全调试了个遍。死活没搞定,今天再详细看一遍,发现是在ns-mobilenode.tcl里有一句需要删除的语句,在Ramon的文档里没有说明这一点,在代码里也没有用黑体标出来
,把这里改好,终于可以看到多接口收发的效果了。
阅读全部内容…
Tags: NS2, Ramon, 多接口
yhustc On
ns2仿真 @ 2009-10-31 20:10:20 |
没有评论
if else 跟C里面一样,只不过if条件的括号变成了大括号。至于双引号的,暂时不管它吧。捡熟悉的记。
#求绝对值
if{ $x>=0 } {
puts "abs(x)=$x"
} else {
puts "abs(x)=[expr -$x]"
}
switch就比C的复杂多啦。可以用三种模式判断(因为tcl里面所有的值都是字符串,所以用多种类型匹配可以从分发挥字符串的优势)。-exact:精巧匹配 -glob:使用通配符匹配 -regexp:正则表达式匹配。关键的一点,在value前加--是一个好习惯。至于为啥看书上的解释吧。然后一个区别就是每种分支情况都不需要用case关键字。直接写分支。用花括号括起来。
阅读全部内容…
Tags:
yhustc On
ns2仿真 @ 2008-04-13 11:16:00 |
2条评论
赋值用set,而不是等号,第一次使用变量时,tcl会自动创建变量。对于数组的赋值也是直接使用set语句。不过比较奇怪的是,tcl的数组居然不用[]把索引框起来,用的是(),这个要牢记。数组的索引可以使用字符串(事实上,tcl中数字也是字符串-___-!!)
set a 3; set a 100;#创建a变量初值为3,将a的值赋值成100
set arr(1) 1;#把arr数组索引为1的变量赋值为1
变量引用跟PHP一样,用$引用变量。
阅读全部内容…
Tags:
yhustc On
ns2仿真 @ 2008-04-13 10:25:00 |
没有评论
终究还是逃不过这一劫啊。搞网络的,大家都用NS2做仿真,似乎NS2就是一块招牌,表示我的仿真数据是可靠的。
大三就买了书,到现在翻了不超过20页。-______-!!
现在要一鼓作气的把NS2学会,虽然可能完成复杂的仿真还需要假以时日,但是最基本的怎么用要先学会吧。
工欲善其事,必先利其器。找了几个TCL的IDE,发现都不咋地,最后选择用Komodo Edit,可以完成关键字的自动补全,但是居然没有自动补全的快捷键,只能用鼠标点菜单,¥#@¥¥……%,然后似乎没有变量的自动提示,那叫一个域名啊。不知道是不是我没有配置好的原因。
又找了个图形化生成TCL的工具,nsBench,貌似挺不错的样子,不过好像是个大众化的软件,估计我的仿真还得自己写TCL。
第一篇就这么多,下面开始学习TCL
Tags:
yhustc On
ns2仿真 @ 2008-04-13 09:54:00 |
没有评论
最新评论