NS2 for Eclipse
Eclipse is an open source development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. A large and vibrant ecosystem of major technology vendors, innovative start-ups, universities, research institutions and individuals extend, complement and support the Eclipse platform.
Set up NS2 for Eclipse under Linux:
- Download Eclipse SDK
- Download Eclipse C++ Development Tooling
- Extract Eclipse SDK to a folder, i.e. /home/username/eclipse
- Extract Eclipse CDT to the same folder
- Download NS2
- Extract NS2 to a folder, i.e. /home/username/ns-allinone-2.29
- Edit Makefile if necessary (see note below for details)
- Build NS2
- Start Eclipse
- Choose your ns2 folder as your workspace folder, default:/home/username/ns-allinone-2.29
- Create new C++ Project
- Select File->New->Project...
- Select C++->Standard C++ Make Project
- Click Next
- Enter ns-2.29 as your project name
- Click Finish
- Create a Launch Configuration
- Select Run->Debug...
- Select C/C++ Local Application
- Click "New Launch Configuration"
- Under Project, click Browse and select "ns-2.29"
- Under C/C++ Application, click Search Project and select "ns"
- Click Apply
- Click Close
Note: The debugger needs debug information to be generated by the compiler. To make the compiler generate these informations, you have to edit the NS2 makefile. Edit ".../ns-allinone-2.29/ns-2.29/Makefile" or edit ".../ns-allinone-2.29/ns-2.29/Makefile.in" and run "./configure" after that. Add those lines anywhere:CCOPT = -g # Hinzufügen der "-g"-Option
DEFINE = -DNDEBUG # Löschen des NoDebug-Flags
DEFINE = -DDEBUG # Hinzufügen des Debug-Flags
Additional Note: Eclipse creates project and workspace files in the NS2 folder.These should be excluded from CVS checkins and patch creations. Add those files to your cvsignore, respectively delete them from your patchfile after creating it.
Set up NS2 for Eclipse under Windows
You need cygwin to run NS2 under Windows.
- Download Cygwin
- Install Cygwin
- Run setup.exe
- Choose a root directory, i.e. c:/cygwin
- Make sure, unix/binary text file type is selected
- Click Next
- Choose a package directory, this is where your downloaded files will be put in
- Select an internet connection and a download mirror
- Make sure you install the following packages:
xorg-x11-bin, xorg-x11-bin-dlls, xorg-x11-devel, xorg-x11-libs-data, xorg-x11-etc, gcc, gcc-g++, gawk, tar, gzip, make, patch, perl, w32api
- Start cygwin.bat to create a user
- Download Eclipse SDK
- Download Eclipse C++ Development Tooling
- Extract Eclipse SDK to a folder, i.e. c:/eclipse
- Extract Eclipse CDT to the same folder
- Download NS2
- Extract NS2 to a cygwin folder, i.e. c:/cygwin/home/username/ns-allinone-2.29
- Edit Makefile if necessary (see note below for details)
- Build NS2
- Start Cygwin.bat to get into cygwin shell
- cd to your NS2-directory, default: /home/username/ns-allinone-2.29
- Type "./install"
- Type "./validate" if you want to validate your build
- These steps may take a while
- Start Eclipse
- Choose your ns2 folder as your workspace folder, default:c:/cygwin/home/username/ns-allinone-2.29
- Create new C++ Project
- Select File->New->Project...
- Select C++->Standard C++ Make Project
- Click Next
- Enter ns-2.29 as your project name
- Click Finish
- Change the Binary Parser
- Select Project->Properties
- Select C/C++ Make Project
- In the Binary Parser Tab, select Cygwin PE Parser and PE Windows Parser
- Click OK
- Create a Launch Configuration
- Select Run->Debug...
- Select C/C++ Local Application
- Click "New Launch Configuration"
- Under Project, click Browse and select "ns-2.29"
- Under C/C++ Application, click Search Project and select "ns.exe"
- Click Apply
- Click Close
Note: The debugger needs debug information to be generated by the compiler. To make the compiler generate these informations, you have to edit the NS2 makefile. Edit ".../ns-allinone-2.29/ns-2.29/Makefile" or edit ".../ns-allinone-2.29/ns-2.29/Makefile.in" and run "./configure" after that. Add those lines anywhere:CCOPT = -g # Hinzufügen der "-g"-Option
DEFINE = -DNDEBUG # Löschen des NoDebug-Flags
DEFINE = -DDEBUG # Hinzufügen des Debug-Flags
Additional Note: Eclipse creates project and workspace files in the NS2 folder.These should be excluded from CVS checkins and patch creations. Add those files to your cvsignore, respectively delete them from your patchfile after creating it.
From: http://wcms1.rz.tu-ilmenau.de/fakia/NS2-for-Eclipse.6025.0.html
有些朋友好像对Eclipse CDT开发很感兴趣,我就把我用Eclipse搭建NS2开发平台的过程说一下吧,经验和大家共享。
一、我的开发环境:Mware 6.5 + Fedora Core 8 + NS 2.31+Eclipse CDT+DLTK
Eclipse CDT用的是 Europa 版本的。这个版本直接装好了Eclipse 的CDT插件。也可以用Fedora内自带的Eclipse在单独装上CDT插件就行了,DLTK是一个TCL和Ruby的插件,实际上我只用它的高亮显示Tcl关键字的功能,不装也可以。我的NS安装路径为~/ns-allinone-2.31/ns-2.31/
二、过程摘要:
1.装好VMware和linux
2.装好NS2。配置好环境变量。
a) 运行在ns2目录下运行 ./configure –enable-debug
3.安装好Eclipse CDT
4.安装DLTK插件(可选)
5.新建C++ makefile工程 workspace指定到 ~/ns-allinone-2.31/ns-2.31
6.设置
a) 把ns目录下所有文件夹添加为source文件夹
b) 设定Run配置:添加ns可执行文件和变量(tcl脚本的位置)
7.运行 在console中可以看到结果
如果你已经知道怎么做了,那就开始吧。如果不清楚那就接着看下面的详细步骤
三、详细步骤:
1-4 网上有大量资料可以参考,我简单的说几点:
a) VMware 6.5不要装FC7。因为vmware-tools和FC7的内核似乎不兼容,需要将FC7内核升级到2.6.23以上。所以还是装FC8。或者用VMware5.5也行。
b) ./configure –enable-debug在make文件中加入-g属性 然后重新编译一下ns
c) Eclipse需要安装JAVA虚拟机。简单的方式是安装linux时完全安装一下,FC8中已经把开发环境都配置好了
现在假设你已经安装好了所有需要的软件,NS可以正常运行,那么把NS导入到Eclipse中就可以了。具体步骤如下:
a) 新建C++ makefile工程:在Project Explorer中右键,新建C++工程;
b) 设置工程属性:注意位置是ns的安装目录,类型是makefile project,tool chain选linux GCC;
c) 完成
d) 在工程名上右键,选properties;
e) 在C/C++ General -> paths and symbols中选则source location;添加NS目录下所有文件夹为source;这是为了可以从大纲视图看代码;
f) 设置Run:双击C/C++ Local Application, 新建一个Run配置;C/C++ Application中选择目录下的ns可执行文件。enable-debug后这个文件变大为10几M了。
g) 设置Arguments;把你所要仿真的tcl脚本添加进去。相当于在终端中输入ns yourTcl.tcl
h) 运行。如果没有设定变量,相当于直接运行ns。Console中提示符变为%; 我们可以测试一下输入
puts “Hello NS2”
输出Hello NS2
安装结束。Enjoy it!
四、Eclipse的作用(欢迎大家讨论)
1.Debug
Eclipse调试C++也是调用GDB,相当于一个可视化的GDB调试环境;使用时设定断点,点debug按钮即可。
2.查找代码
Eclipse在项目中查找代码的作用我认为非常管用,你可以查一个关键字或者类名,看它在那定义的。只需要在变量名上ctrl+左键单击,就自动打开定义文件。感觉很爽 ^_^ 看代码会省很多事。
3.CVS
写代码的时候还是用用这些代码管理软件比较好。省得改错了代码时想回都回不去,欲哭无泪啊。
4 ……希望大家在使用中自己多多发现
我也是一个NS2和Eclipse的新手,希望大家多多发现Eclipse在NS2编程上的技巧,相互交流,有了发现也告诉我一声啊。^_^
From: http://jimey.com/2009/03/06/%E4%BD%BF%E7%94%A8eclipse-cdt-%E5%BC%80%E5%8F%91ns2.html
NS2在Win系统中三种调试方法
NS2是开源的,因此其基本的编译和调试工具为GCC和GDB,不管你是将它安装在window、linux 中。在window系统中,GCC和GDB比较的承载平台为Cygwin。因此在window中使用NS2一般建议大家先安装Cygwin,注意你必须安装GCC和GDB。在此前提下,你可以选择的调试方式有三种。
1、直接使用GDB,在Cygwin现在版本中,它包含的GDB包有两种分别是 2006XXX和2004XXX,它们都是基于命令行的方式。据说早期的GDB中有图形调试方式,它们是2001XXX或2002XXX,大家如果有兴趣可以在网络上找找。对现在已经熟悉了window操作方式的人来讲,命令行的方式的确有些不方便。见GDB图片
2、DDD,它是可以图形操作方式,底层是GDB。它提供了一个GDB的命令窗口,和源码查看窗口。另外你可以直接在源码中设置断点,调试跟踪时,可以直观的查看变量、参数等。比起命令行的操作方式方面多了,但调试时,响应速度比较慢。还有源码查看窗口代码没有着色,没有层次感。见DDD图片
3、Eclipse+CDT,它构建了一个比较好的IDE平台,明显优于前面的两种方法。反应速度快,查看代码方便,类的结构清晰。这种方法应该是目前比较好的NS2编译与调试方案。在搭建Eclipse+CDT平台时应该注意几点:
消去部分编译影响速度的选项,如:code assisant, code indexer一般不需要,binary parser设置为PE Windows Parser。
建立NS2项目时,选择stand make C++ project, 不要勾选use default location而是选择NS2的安装路径。
如果需要调试,你必须在GCC的选项中添加-g。你可以通过修改Makefile完成,也可以通过在cygwin命令行中运行configure with-enable-debug完成。
调试时,你可能遇到无法找到源文件的情况,这是由于cygwin在作怪。cygwin中的路径标识与windows存在一定的差异,因此你必须做一定的映像,例如/cygdrive/c <----> C:/; /cygdrive/d <----> D:/等等。映射的设置方法为perferences -> C/C++ -> Debug -> command Source LookUP Path,添加Path Mapping。注意cygwin的安装路径也是很重要的,一般也必须添加到映射中,例如cygwin的根目录 “/<-->C:/cygwin”。
From: http://blog.chinaunix.net/u2/82448/showart.php?id=1888082