[TOC]
参考文档
- 官方安装wiki文档:
https://www.nsnam.org/wiki/Installation
- 参考博客:
http://blog.csdn.net/dyzok88/article/details/50816624
环境
我系统的环境
ubuntu 16.10
建议ubuntu 16.04版本以上吧- NS版本ns-3.26
安装依赖
注意:如果提示权限不够,在前面加上
sudo
。minimal requirements for C++ (release): This is the minimal set of packages needed to run ns-3 from a released tarball.
|
|
- minimal requirements for Python (release): This is the minimal set of packages needed to work with Python bindings from a released tarball.
|
|
- minimal requirements for Python (development): For use of ns-3-allinone repository (cloned from Mercurial), additional packages are needed to fetch and successfully install pybindgen:
|
|
- Python API scanning support: cmake libc6-dev libc6-dev-i386 g++-multilib To rescan Python bindings requires gccxml and pygccxml, which are installed by bake. However, for Ubuntu 16.04, gccxml will not build without a patch and a build flag described here: https://www.nsnam.org/bugzilla/show_bug.cgi?id=2451
- qt4 development tools are needed for Netanim animator (Note: qt version qt4, not qt5, is required)
|
|
- Support for generating modified python bindings
|
|
and you will want to install gccxml and pygccxml as per the instructions for python bindings (or through the bake build tool as described in the tutorial).
Debugging:
|
|
- GNU Scientific Library (GSL) support for more accurate WiFi error models
|
|
- The Network Simulation Cradle (nsc) requires the flex lexical analyzer and bison parser generator:
|
|
- To read pcap packet traces
|
|
- Database support for statistics framework
|
|
- Xml-based version of the config store (requires libxml2 >= version 2.7)
|
|
- A GTK-based configuration system
|
|
- To experiment with virtual machines and ns-3
|
|
- Support for utils/check-style.py code style check program
|
|
- Doxygen and related inline documentation:
|
|
- The ns-3 manual and tutorial are written in reStructuredText for Sphinx (doc/tutorial, doc/manual, doc/models), and figures typically in dia (also needs the texlive packages above):
|
|
Note: Sphinx version >= 1.12 required for ns-3.15. To check your version, type “sphinx-build”. To fetch this package alone, outside of the Ubuntu package system, try “sudo easy_install -U Sphinx”.
- Support for Gustavo Carneiro’s ns-3-pyviz visualizer
|
|
- Support for openflow module (requires some boost libraries)
|
|
- Support for MPI-based distributed emulation
|
|
安装NS-3
- 下载NS-3安装包:官网首页下载
- 建立文件夹
NS3
(可自己定义)
- 将下载的安装包解压到
NS3
目录中
- 编译
1)使用build.py编译
|
|
编译成功:
2)使用waf编译
一旦工程已经编译过,就不能再使用build.py脚本
使用waf重新配置和编译ns-3系统
sudo ./waf clean
清除先前配置编译- ./waf -d optimized –enable-examples–enable-tests configure 重新配置ns-3,优化编译例子和测试(默认测试和例子是不编译的)
optimized参数,优化模式下默认是禁止ns-3特殊的日志系统(logging),这样导致运行的的结果不能再控制台上显示。因此,建议更改为./waf -d debug --enable-examples --enable-tests configure
./waf
正式编译3) 运行测试
使用test.py测试,从`ns`目录中进入到`ns-3.26`目录下找到test.py文件,运行:
|
|
运行成功:
编程工具安装VIM
我比较喜欢vim编辑器,感觉比较原生,你也可以使用eclips,大部分是截取i前辈的文档,但是他们的x有些下载地址进不去,就自己修改了点。
首先说明一下几个配置文件的作用:
- vim 文件夹,这个文件夹放置 vim 的配置文件,包括 vim 的插件和 doc
文件,ubuntu 下面名字以 . 开始说明默认是隐藏的,如果想看可以进入文件夹
所在的目录按 CTRL+H,显示隐藏文件,或者在终端下面输入 ls -a 命令。.vim
是自己创建的,放在主文件夹下面。
创建过程:首先打开终端,一般默认是主文件夹,也可以输入 cd ~命令进
入主文件夹,然后,输入 mkdir .vim 创建文件夹。输入 cd .vim 进入文件夹,创
建 plugin, doc, tags 文件夹, plugin 放置的是 vim 的一些插件,文件名后缀是.vim,
doc 是插件的帮助文档,tags 放 ctags 生成的 tag 文件(tags 这个可选,可以放在
任何位置,只要在.vimrc 文件中设置正确即可)。 - vimrc 文件,这个文件里面存储 vim 的配置信息,也是自己创建的,和.vim
在同一级目录下。
创建过程:打开终端,输入:cd ~,然后输入 vim .vimrc 命令,会出现一
个.vimrc 文件的 vim 编辑界面。按 i 键进入编辑模式,在文件里面添加如下命令:
filetype plugin indent on
set helplang=cn
set encoding=utf-8
syntax enable
syntax on
然后按 esc 键,输入:wq 命令,保存退出!
下面是主要配置环节
- ctags安装1sudo apt-get install ctags
太繁琐了,不想写了,留着以后有时间再弄吧。暂时用eclipse吧。
编程工具安装之eclipse
安装eclipse
|
|
eclipse与ns-3对接
1.新建ns3空工程
FILE->new->c++project
2.将原来的ns3文件夹下的ns-3.26
文件夹下的内容全复制到eclipse的工作目录下
并且在改目录下使用下面的命令配置项目:
|
|
3.设置eclipse中的ns3编译器为waf
在eclipse中的`project exploer
中的项目文件上右键,选择properties
选项,进行如下设置
这时右键点击build project
进行编译
4.设置eclipse执行工具使用外部工具
选择run->External Tools->Externel tools Configuration
然后出现:
5.仿真结果