ubuntu16.04下安装配置NS3
NS3安装
最开始按照同学的blog进行安装:
安装依赖库
- 更新apt
1 | sudo apt-get update |
- 安装相关依赖
1 | sudo apt-get install gcc g++ python python-dev #C++和python |
在安装依赖的时候遇到一两个错误,根据提示进行了包的替换,有的则直接略过了,等到以后需要的时候再装。
安装NS3
- 安装NS3包括创建目录、进入目录、下载压缩包、解压
1 | wget http://www.nsnam.org/release/ns-allinone-3.28.tar.bz2tar xjf ns-allinone-3.28.tar.bz2 |
编译NS3
进入ns-allinone-3.28目录:
1
./build.py
进入ns-3.28目录:
1
./waf distclean #清除整个build目录./waf configure --build-profile=debug --enable-examples --enable-tests #打开debug并开启例子及帮助./waf build
测试并运行相关程序
1 | ./test.py -c core #测试./waf --run hello-simulator #运行hello-simulator程序 |
NS3配置
下载Eclipse
第一次在eclipse中配置Mercurial的时候提示出错:(具体见此)
1 | Cannot complete the install because one or more required items could not be found. Software currently installed: MercurialEclipse 2.5.2.201806082050 (mercurialeclipse.feature.group 2.5.2.201806082050) Missing requirement: MercurialEclipse 2.5.2.201806082050 (com.vectrace.MercurialEclipse 2.5.2.201806082050) requires 'bundle org.eclipse.jface.text 3.11.0' but it could not be found Cannot satisfy dependency: From: MercurialEclipse 2.5.2.201806082050 (mercurialeclipse.feature.group 2.5.2.201806082050) To: com.vectrace.MercurialEclipse [2.5.2.201806082050] |
原来是eclipse的版本问题,Mercurial在Eclipse Neon (4.6) 才第一次发布。
所以重新安装了Eclipse的最新版本,安装教程参考此文。
导入项目
将NS3项目复制到eclipse的workspace,同时在eclipse中新建项目File--New--C/C++Projec, 项目名称与NS3项目名称相同。


用waf编译NS3项目
(不知道这一步是不是必要的)
在该项目中找到waf文件所在文件夹目录,在该目录中打开终端,依次敲以下命令。
1 | ./waf configure |
注:若显示无权限 则在以下界面打开终端,输入 sudo chmod 777 ns-XX —R
Eclipse 中 设置NS3 编译器为 waf
在 Project Explorer 中的 NS3 上单击右键,选择 properties,配置如图所示

配置Eclipse 执行程序使用外部工具
Run->External Tools->External tools Configuration,配置如下

配置Debug
置Debug时 C/C++Application处的文件路径要精确到需要Debug的c++文件名

然后选择Environment 进行配置
