#C++和python安装,必装
sudo apt install gcc g++ python
sudo apt install gcc g++ python python-dev
#NS3代码维护使用的源码版本控制管理系统
sudo apt install mercurial
#运行python绑定ns-3-dev需要bazaar这个组件
sudo apt install bzr
#调试工具
sudo apt install gdb valgrind
#支持更多精确WIFI模块的GNU Scientific Library (GSL)
sudo apt install gsl-bin libgsl0-dev libgsl0ldbl
#仿真必需的词法分析器和语法分析生成器,必装
sudo apt install flex bison libfl-dev
#一些Network Simulation Cradle (nsc) stacks需要gcc-3.4
sudo apt install g++-3.4 gcc-3.4
#读取pcap的packet traces,即包嗅探器
sudo apt install tcpdump
#支持统计特性的数据库软件
sudo apt install sqlite sqlite3 libsqlite3-dev
#xml的配置存储软件(requires libxml2 >= version 2.7)
sudo apt install libxml2 libxml2-dev
#基于GTK的配置系统
sudo apt install libgtk2.0-0 libgtk2.0-dev
#在虚拟机and ns-3上测试
sudo apt install vtun lxc
#支持utils/check-style.py 代码风格检查程序
sudo apt install uncrustify
#文档生成器,从源代码中生成说明文档(很大,我没有装)
sudo apt install doxygen graphviz imagemagick
sudo apt install texlive texlive-extra-utils texlive-latex-extra
#The ns-3 manual and tutorial are written in reStructuredText for Sphinx (doc/tutorial, doc/manual, doc/models), and figures typically in dia:
sudo apt install python-sphinx dia
#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”.
#Gustavo’s ns-3-pyviz的可视化软件(可不装)
sudo apt install python-pygraphviz python-kiwi python- - pygoocanvas libgoocanvas-dev
#支持openflow 模块(requires some boost libraries)
sudo apt install libboost-signals-dev libboost-filesystem-dev
#支持基于 MPI的分布式仿真
sudo apt-get install openmpi*
mkdir NS3 # 我创建的NS3目录的完整路径是/usr/local/src/NS3,可自行创建在其他目录下。
cd NS3
wget https://www.nsnam.org/releases/ns-allinone-3.35.tar.bz2
tar xvf ns-allinone-3.35.tar.bz2
cd ns-allinone-3.35/
./build.py
# 看到'build' finished successfully..... 就表示安装成功
cd ns-3.35/ # 注意不是ns-allinone-3.35/
# (清除先前配置编译)
./waf clean # 或 ./waf distclean 清除整个build目录(可执行也可不执行)
# (重新配置ns3,优化编译包括例子和测试,默认情况下例子和测试是不编译的,系统会重新配置,编译系统会检查ns3依赖的软件包是否安装成功)
./waf –d optimized –enable-examples –enable-tests configure
# 或
./waf configure --enable-examples --enable-tests #开启例子及帮助
# 进行编译
./waf build
./test.py
./test.py -c core # PASS就证明安装成功
./waf --run hello-simulator
例 : 修改至 gcc-7 版本
gcc
版本ls /usr/bin/gcc* -l
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt install -y gcc-7 gcc-7-multilib g++-7 g++-7-multilib
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --config gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
sudo update-alternatives --config g++
sudo update-alternatives --remove gcc /usr/bin/gcc-5
gcc -v