Ubuntu下安装网络仿真器NS3 3.22
1、 NS3 下载
进入NS3官网,https://www.nsnam.org。下载NS3软件包ns-allinone-3.22.tar.bz2。然后,将软件包进行解压。
2、 依赖软件包安装
由于依赖软件包比较多,我们利用shell脚本编程安装。将所有安装命令写入脚本文件,并在后面附加自动确认参数(-y),然后编译和执行脚本文件。
如下:
1)、在vi中编辑如下文件
#!/bin/sh
sudo apt-get install gcc g++ python -y
sudo apt-get install gcc g++ python python-dev -y
sudo apt-get install mercurial -y
sudo apt-get install bzr -y
sudo apt-get install gdb valgrind -y
sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl -y
sudo apt-get install flex bison libfl-dev -y
sudo apt-get install g++-3.4 gcc-3.4 -y
sudo apt-get install tcpdump -y
sudo apt-get install aqlite aqlite3 libsqlite3-dev -y
sudo apt-get install libxml2 libxml2-dev -y
sudo apt-get install libgtk2.0-0 libgtk2.0-dev -y
sudo apt-get install vtun lxc -y
sudo apt-get install uncrustify -y
sudo apt-get install doxygen grphviz imagemagick -y
sudo apt-get install texlive texlive-extra-untils texlive-latex-extra -y
sudo apt-get install python-sphinx dia -y
sudo apt-get install python-pygraphviz python-kiwi python-pygoocanvaslibgoocanvas-dev -y
sudo apt-get install libboost-signals-dev libboost-filesystem-dev -y
sudo apt-get install openmpi* -y
:wq mysetup #(注释)保存为以mysetup为名字的文件
2)、终端中编译: chmod+x mysetup
3)、运行安装,终端中输入:./mysetup
3、 编译安装NS3
在终端中,进入NS3解压包。
运行:
sudo ./build.py –enable-example –enable-tests
成功结果:
Waf: Leaving directory`/home/peng/ns-allinone-3.22/ns-3.22/build‘
‘build‘ finished successfully (4m48.801s)
Modules built:
antenna aodv applications
bridge buildings config-store
core csma csma-layout
dsdv dsr energy
fd-net-device flow-monitor internet
lr-wpan lte mesh
mobility mpi netanim (no Python)
network nix-vector-routing olsr
point-to-point point-to-point-layout propagation
sixlowpan spectrum stats
tap-bridge test (no Python) topology-read
uan virtual-net-device visualizer
wave wifi wimax
Modules not built (see ns-3 tutorial forexplanation):
brite click openflow
4、 测试是否安装成功
在终端中,进入NS3解压包的ns-3.22文件夹中。
1)测试发行版是否编译正确
运行:
./test.py –c core
结果:
PASS: TestSuite lte-frequency-reuse
195 of 198 tests passed (195 passed, 3skipped, 0 failed, 0 crashed, 0 valgrind errors)
List of SKIPped tests: ns3-tcp-cwnd
ns3-tcp-interoperability
nsc-tcp-loss
2)运行脚本测试
运行:
sudo ./waf --run scratch-simulator
结果
Waf: Entering directory`/home/peng/ns-allinone-3.22/ns-3.22/build‘
Waf: Leaving directory`/home/peng/ns-allinone-3.22/ns-3.22/build‘
‘build‘ finished successfully (3.263s)
Scratch Simulator
恭喜你,NS3软件安装成功!