NS2各个版本的安装其实都大同小异,但每个升级版本并不向下兼容,所以会考虑到实际需要而安装多个NS2版本,将在后续文章中说明本人安装多个NS2版本的关键点,本文主要就在WinXP SP2下安装NS2.33的主要过程和相关疑问解答罗列出来,具体可参见文章最后列出的参考网址,如有疑问,欢迎联系本人。
Step1
在http://www.cygwin.com/
在http://www.isi.edu/nsnam/dist/上下载ns-allinone-2.33.tar.gz
修改环境变量。将
export NS_HOME=/home/jerry.wu/ns-allinone-2.33
export PATH=$NS_HOME/tcl8.4.18/unix:$NS_HOME/tk8.4.18/unix:$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.18/unix:$NS_HOME/tk8.4.18/unix:$NS_HOME/otcl-1.13:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.4.18/library
拷贝到c:/cwgwin/home/ Administrator
检验ns和nam命令。输入startxwin.sh命令,在出现的视图窗口下进入jerry.wu\ns-allinone- 2.33\ns-2.33\tcl\ex\wpan
至此,Cygwin+ns-allinone-2.33
Problems & Solutions
S: 可能是没有安装X-Startup-Scripts,重新运行setup.exe,然后选择安装就行了
S: 如果是找不到 examples2.tcl 那就是你打 cd /home/hct/ns-allinone-2.28/ns-2.28/ns-tutorial/examples 的时候出了错 ,如果是找不到ns,那就是环境变量没设置好
S: 看看你的 /home/hct/ns-allinone-2.28/nam-1.11 目录下有没有 nam.exe 文件,有的话就是你的环境变量设置错了,注意要把 nam-1.11 这个目录加到PATH中
如果没有nam.exe,那就是编译nam时出错了。运行 gcc -dumpversion 看看你的gcc版本,如果是3.4.x,那就好办了。找到 nam-1.11/agent.h ,把它的第73行中的NULL改成0,然后回到nam-1.11目录,运行 ./configure 然后运行 make,等运行完毕,再试试 ns example2.tcl 就应该没问题了
如果gcc版本不是3.4.x,那就不知道是什么问题了,不过可以肯定是编译出了错,所以换个nam版本试试吧
S: 未安装libXt-devel,用cygwin的setup升级安装这个组件
S: 未安装libXmu-devel,用cygwein的setup升级安装这个组件
S: 修改makefile.in和makefile.vc,搜错/user/bin/install -c -m -o bin -g bin,并将其改为/user/bin/install -c -m -o [your user name]
S: 这个是由于nam调用的tk组件和xproto-7.0.13不兼容导致的(xproto-7.0.13 新添加了 GenericEvent)。
到这里下载补丁http://bugs.gentoo.org/show_bug.cgi?id=225999
具体的指令如下:
[badar@linux tk8.4.18]$ ls
bitmaps compat library macosx tk-8.4.18-tkBind.patch win
ChangeLog doc license.terms README tk-8.4-lastevent.patch xlib
changes generic mac tests unix
[badar@linux tk8.4.18]$ patch -p1 < ./tk-8.4-lastevent.patch
can’t find file to patch at input line 3
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|— generic/tk.h.orig 2008-02-06 16:31:40.000000000 +0100
|+++ generic/tk.h 2008-07-24 08:21:46.000000000 +0200
————————–
File to patch: generic/tk.h
patching file generic/tk.h
[badar@linux tk8.4.18]$ cd ..
[badar@linux ns-allinone-2.33]$ ./install
References:
http://x.cygwin.com/docs/ug/setup-cygwin-x-installing.html
http://140.116.72.80/~smallko/ns2/setup.htm
http://forums.fedoraforum.org/showthread.php?t=206795
http://bbs.cnttr.com/viewthread.php?tid=190413&page=1&authorid=319430
http://blog.sina.com.cn/s/blog_4a5f138701000bbv.html
http://perti.blog.sohu.com/47330681.html
http://user.qzone.qq.com/187375679/blog/1234963865