2015年3月5日 星期四

NS3安裝

一. NS3安装预先设置Ubuntu环境如下(Prerequisites for Ubuntu12.04)



  • C++和python安装,必装
 sudo apt-get install gcc g++ python
 sudo apt-get install gcc g++ python python-dev
  • NS3代码维护使用的源码版本控制管理系统
 sudo apt-get install mercurial
  • 运行python绑定ns-3-dev需要bazaar这个组件
 sudo apt-get install bzr
  • 调试工具
 sudo apt-get install gdb valgrind 
  • 支持更多精确WIFI模块的GNU Scientific Library (GSL) 
 sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl
  • 仿真必需的词法分析器和语法分析生成器,必装
 sudo apt-get install flex bison libfl-dev
  • 一些Network Simulation Cradle (nsc) stacks需要gcc-4.4
 sudo apt-get install g++-4.4 gcc-4.4
  • 读取pcap的packet traces,即包嗅探器
sudo apt-get install tcpdump
  • 支持统计特性的数据库软件
sudo apt-get install sqlite sqlite3 libsqlite3-dev
  • xml的配置存储软件(requires libxml2 >= version 2.7)
sudo apt-get install libxml2 libxml2-dev
  • 基于GTK的配置系统
 sudo apt-get install libgtk2.0-0 libgtk2.0-dev
  • 在虚拟机and ns-3上测试
 sudo apt-get install vtun lxc
  • 支持utils/check-style.py 代码风格检查程序
sudo apt-get install uncrustify
  • 文档生成器,从源代码中生成说明文档
 sudo apt-get install doxygen graphviz imagemagick
 sudo apt-get 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-get 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-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev
  • 支持openflow 模块(requires some boost libraries)
sudo apt-get install libboost-signals-dev libboost-filesystem-dev
  • 支持基于 MPI的分布式仿真
sudo apt-get install openmpi*

------------------------------------------------------------
二、NS3下载

 
  到NS3網站下載NS3壓縮檔,並解壓縮到家目錄底下



------------------------------------------------------------
  三、编译NS3
进入ns-allinone-3.17目录,在终端shell中执行
./build.py --enable-examples --enable-tests

一轮长时间的等待,
最终执行完后看到 ".Waf: Leaving directory `/path/to/workspace/ns-allinone-3.17/ns-3.17/build'
'build' finished successfully (6m25.032s)

Modules built:
antenna                    aodv                       applications
bridge                     buildings                  config-store
core                       csma                       csma-layout
dsdv                       dsr                        emu
energy                     fd-net-device              flow-monitor
internet                   lte                        mesh
mobility                   mpi                        netanim (no Python)
network                    nix-vector-routing         olsr
point-to-point             point-to-point-layout      propagation
spectrum                   stats                      tap-bridge
test (no Python)           tools                      topology-read
uan                        virtual-net-device         wifi
wimax                     visualizer

Modules not built (see ns-3 tutorial for explanation):
brite                      click                      openflow
Leaving directory `./ns-3.17`."


使用waf构建(Building with Waf)
进入ns-3.17文件目录:


 ./waf clean
./waf -d optimized --enable-examples --enable-tests configure

最终看到:Checking for program g++ : ok /usr/bin/g++
Checking for program cpp : ok /usr/bin/cpp
Checking for program ar : ok /usr/bin/ar
Checking for program ranlib : ok /usr/bin/ranlib
Checking for g++ : ok
Checking for program pkg-config : ok /usr/bin/pkg-config
Checking for -Wno-error=deprecated-declarations support : yes
Checking for -Wl,--soname=foo support : yes
Checking for header stdlib.h : ok
Checking for header signal.h : ok
Checking for header pthread.h : ok
Checking for high precision time implementation : 128-bit integer
Checking for header stdint.h : ok
Checking for header inttypes.h : ok
Checking for header sys/inttypes.h : not found
Checking for library rt : ok
Checking for header netpacket/packet.h : ok
Checking for pkg-config flags for GSL : ok
Checking for header linux/if_tun.h : ok
Checking for pkg-config flags for GTK_CONFIG_STORE : ok
Checking for pkg-config flags for LIBXML2 : ok
Checking for library sqlite3 : ok
Checking for NSC location : ok ../nsc (guessed)
Checking for library dl : ok
Checking for NSC supported architecture x86_64 : ok
Checking for program python : ok /usr/bin/python
Checking for Python version >= 2.3 : ok 2.5.2
Checking for library python2.5 : ok
Checking for program python2.5-config : ok /usr/bin/python2.5-config
Checking for header Python.h : ok
Checking for -fvisibility=hidden support : yes
Checking for pybindgen location : ok ../pybindgen (guessed)
Checking for Python module pybindgen : ok
Checking for pybindgen version : ok 0.10.0.640
Checking for Python module pygccxml : ok
Checking for pygccxml version : ok 0.9.5
Checking for program gccxml : ok /usr/local/bin/gccxml
Checking for gccxml version : ok 0.9.0
Checking for program sudo : ok /usr/bin/sudo
Checking for program hg : ok /usr/bin/hg
Checking for program valgrind : ok /usr/bin/valgrind
---- Summary of optional NS-3 features:
Python Bindings :                          enabled
Python API Scanning Support :   not enabled (Missing 'pygccxml' Python module)
BRITE Integration :                        not enabled (BRITE not enabled (see option --with-brite))
NS-3 Click Integration :                 not enabled (nsclick not enabled (see option --with-nsclick))
GtkConfigStore :                             enabled
XmlIo :                                               enabled
Threading Primitives :                    enabled
Real Time Simulator :                    enabled
Emulated Net Device :                   enabled
File descriptor NetDevice :            enabled
Tap FdNetDevice :                           enabled
Emulation FdNetDevice :               enabled
PlanetLab FdNetDevice :              not enabled (PlanetLab operating system not detected (see option --force-planetlab))
Network Simulation Cradle :         not enabled (NSC not found (see option --with-nsc))
MPI Support :                                    not enabled (option --enable-mpi not selected)
NS-3 OpenFlow Integration :        not enabled (OpenFlow not enabled (see option --with-openflow))
SQlite stats data output :                enabled
Tap Bridge :                                       enabled
PyViz visualizer :                                enabled
Use sudo to set suid bit :                enabled
Build tests :                                        enabled
Build examples :                                enabled
GNU Scientific Library (GSL) :         enabled
'configure' finished successfully (4.768s)


PS:此次出现很多“Not enable“ 暂时还不清楚怎么使其”enable“



./waf clean
./waf -d debug --enable-examples --enable-tests configure

最终看到"...finished successfully (s)"
./waf 

又将是一轮长时间的等待

Enable something
./waf configure -d debug --enable-sudo --enable-examples --enable-tests

Help
./waf --help



四、测试NS3

./test.py -c core

出现Waf: Leaving directory `/home/rogerking/ns-allinone-3.17/ns-3.17/build'
'build' finished successfully (6m1.803s)

Modules built:
antenna                      aodv                              applications
bridge                         buildings                      config-store
core                             csma                             csma-layout
dsdv                            dsr                                  emu
energy                         fd-net-device                flow-monitor
internet                        lte                                   mesh
mobility                       mpi                                 netanim (no Python)
network                       nix-vector-routing         olsr
point-to-point             point-to-point-layout     propagation
spectrum                   stats                                tap-bridge
test (no Python)        tools                                topology-read
uan                              virtual-net-device         visualizer
wifi                               wimax

Modules not built (see ns-3 tutorial for explanation):
brite                           click                                openflow


PASS: TestSuite attributes
PASS: TestSuite callback
PASS: TestSuite command-line
PASS: TestSuite config
PASS: TestSuite global-value
PASS: TestSuite int64x64
PASS: TestSuite object-name-service
PASS: TestSuite object
PASS: TestSuite ptr
PASS: TestSuite basic-random-number
PASS: TestSuite sample
PASS: TestSuite simulator
PASS: TestSuite time
PASS: TestSuite timer
PASS: TestSuite traced-callback
PASS: TestSuite type-traits
PASS: TestSuite watchdog
PASS: TestSuite threaded-simulator
PASS: TestSuite random-number-generators


...

PASS: TestSuite static-routing
PASS: TestSuite mobility
PASS: TestSuite ns3-wifi-interference
PASS: TestSuite ns3-wifi-msdu-aggregator
SKIP: TestSuite ns3-tcp-cwnd
SKIP: TestSuite ns3-tcp-interoperability
PASS: TestSuite ns3-tcp-loss
PASS: TestSuite ns3-tcp-no-delay
PASS: TestSuite ns3-tcp-socket
PASS: TestSuite ns3-tcp-state
SKIP: TestSuite nsc-tcp-loss
153 of 156 tests passed (153 passed, 3 skipped, 0 failed, 0 crashed, 0 valgrind errors)
说明安装成功,这个信息非常重要

./waf --run hello-simulator

出现"Hello Simulator"信息,恭喜你现在正式成为ns3的用户(若没有出现"Hello Simulator",请确定waf构建是否使用-d debug)

來源 : http://blog.csdn.net/roger__king/article/details/9209501

沒有留言:

張貼留言