码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu上安装NS-3实践

时间:2020-01-15 23:17:54      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:自带   BMI   ice   efault   sign   nim   thread   完成   openflow   

ns3官网https://www.nsnam.org/wiki/Installation#Installation

安装:

Ubuntu/Debian/Mint

The following list of packages should be accurate for Ubuntu 19.04 release; other releases or other Debian-based systems may slightly vary. Ubuntu 16.04 LTS release is probably the oldest release that is known to work as of recent ns-3 releases.

Note: As of ns-3.30 release (August 2019), ns-3 uses Python 3 by default, but earlier releases depend on Python 2 packages, and at least a Python 2 interpreter is recommended. If working with an earlier release, one may in general substitute ‘python‘ for ‘python3‘ in the below (e.g. install ‘python-dev‘ instead of ‘python3-dev‘).

  • minimal requirements for C++ users (release): This is the minimal set of packages needed to run ns-3 from a released tarball.
 apt-get install gcc g++ python python3
  • minimal requirements for Python users (release 3.30 and ns-3-dev): This is the minimal set of packages needed to work with Python bindings from a released tarball.
 apt-get install gcc g++ python python3 python3-dev
  • minimal requirements for Python (development): For use of ns-3-allinone repository (cloned from Git), additional packages are needed to fetch and successfully install pybindgen and netanim.
 apt-get install python3-setuptools git mercurial
  • Netanim animator: qt5 development tools are needed for Netanim animator; qt4 will also work but we have migrated to qt5.
 apt-get install qt5-default mercurial
  • Support for ns-3-pyviz visualizer
    • For ns-3.28 and earlier releases, PyViz is based on GTK+ 2, GooCanvas, and GraphViz:
 apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev ipython
    • For Ubuntu 18.04, python-pygoocanvas is no longer provided. The ns-3.29 release and later upgrades the support to GTK+ version 3, and requires these packages:
 apt-get install gir1.2-goocanvas-2.0 python-gi python-gi-cairo python-pygraphviz python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython ipython3  
  • Support for MPI-based distributed emulation
apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
  • Support for bake build tool:
 apt-get install autoconf cvs bzr unrar
  • Debugging:
 apt-get install gdb valgrind 
  • Support for utils/check-style.py code style check program
apt-get install uncrustify
  • Doxygen and related inline documentation:
 apt-get install doxygen graphviz imagemagick
 apt-get install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils texlive-lang-portuguese dvipng latexmk
  • 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):
 apt-get install python3-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".

  • GNU Scientific Library (GSL) support for more accurate 802.11b WiFi error models (not needed for OFDM):
 apt-get install gsl-bin libgsl-dev libgsl23 libgslcblas0

If the above doesn‘t work (doesn‘t detect GSL on the system), consult: https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/. But don‘t worry if you are not using 802.11b models.

  • To read pcap packet traces
apt-get install tcpdump
  • Database support for statistics framework
apt-get install sqlite sqlite3 libsqlite3-dev
  • Xml-based version of the config store (requires libxml2 >= version 2.7)
apt-get install libxml2 libxml2-dev
  • Support for generating modified python bindings
 apt-get install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev

and you will want to install castxml and pygccxml as per the instructions for python bindings (or through the bake build tool as described in the tutorial). The ‘castxml‘ package provided by Ubuntu 18.04 and earlier is not recommended; a source build (coordinated via bake) is recommended.

Note: Ubuntu versions (through 19.04) and systems based on it (e.g. Linux Mint 18) default to an old version of clang and llvm (3.8), when simply ‘libclang-dev‘ and ‘llvm-dev‘ are specified. The packaging on these 3.8 versions is broken. Users of Ubuntu will want to explicitly install a newer version by specifying ‘libclang-6.0-dev‘ and ‘llvm-6.0-dev‘. Other versions newer than 6.0 may work (not tested).

  • A GTK-based configuration system
 apt-get install libgtk2.0-0 libgtk2.0-dev
  • To experiment with virtual machines and ns-3
 apt-get install vtun lxc uml-utilities
  • Support for openflow module (requires some boost libraries)
apt-get install libboost-signals-dev libboost-filesystem-dev

NS-3的编译借助build.py脚本工具。


./build.py

但是会碰到如下错误:


[1459/1770] cxx: src/lte/model/lte-ffr-sap.cc -> build/src/lte/model/lte-ffr-sap.cc.1.o
[1460/1770] cxx: src/lte/model/lte-fr-no-op-algorithm.cc -> build/src/lte/model/lte-fr-no-op-algorithm.cc.1.o
[1461/1770] cxx: src/lte/model/lte-ffr-soft-algorithm.cc -> build/src/lte/model/lte-ffr-soft-algorithm.cc.1.o
[1462/1770] cxx: src/lte/model/lte-ue-power-control.cc -> build/src/lte/model/lte-ue-power-control.cc.1.o
[1463/1770] cxx: build/src/lte/bindings/ns3module.cc -> build/src/lte/bindings/ns3module.cc.7.o
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build‘
Build failed
 -> task in ‘ns3module_lte‘ failed (exit status 4): 
    {task 159048492: cxx ns3module.cc -> ns3module.cc.7.o}
[‘/usr/bin/g++‘, ‘-O0‘, ‘-ggdb‘, ‘-g3‘, ‘-Wall‘, ‘-Werror‘, ‘-Wno-error=deprecated-declarations‘, ‘-fstrict-alid‘, ‘-fno-strict-aliasing‘, ‘-fwrapv‘, ‘-fstack-protector‘, ‘-fno-strict-aliasing‘, ‘-fvisibility=hidden‘, ‘-Wn, ‘-I..‘, ‘-Isrc/lte/bindings‘, ‘-I../src/lte/bindings‘, ‘-I/usr/include/python2.7‘, ‘-I/usr/include/gtk-2.0‘, -I/usr/include/atk-1.0‘, ‘-I/usr/include/cairo‘, ‘-I/usr/include/gdk-pixbuf-2.0‘, ‘-I/usr/include/pango-1.0‘, ‘glib-2.0‘, ‘-I/usr/lib/i386-linux-gnu/glib-2.0/include‘, ‘-I/usr/include/pixman-1‘, ‘-I/usr/include/freetype2‘,bxml2‘, ‘-DNS3_ASSERT_ENABLE‘, ‘-DNS3_LOG_ENABLE‘, ‘-DHAVE_SYS_IOCTL_H=1‘, ‘-DHAVE_IF_NETS_H=1‘, ‘-DHAVE_NET_ETTE3=1‘, ‘-DHAVE_IF_TUN_H=1‘, ‘-DHAVE_GSL=1‘, ‘-DNS_DEPRECATED=‘, ‘-DNS3_DEPRECATED_H‘, ‘-DNDEBUG‘, ‘src/lte/binings/ns3module.cc.7.o‘]
Traceback (most recent call last):
  File "./build.py", line 170, in 
    sys.exit(main(sys.argv))
  File "./build.py", line 161, in main
    build_ns3(config, build_examples, build_tests, args, build_options)
  File "./build.py", line 81, in build_ns3
    run_command([sys.executable, "waf", "build"] + build_options)
  File "/home/fyang/project/workspace/repos/ns-3-allinone/util.py", line 24, in run_command
    raise CommandError("Command %r exited with code %i" % (argv, retval))
util.CommandError: Command [‘/usr/bin/python‘, ‘waf‘, ‘build‘] exited with code 1

似乎是g++编译器自身的问题,解决办法是利用swap:


sudo dd if=/dev/zero of=/swapfile bs=64M count=16
sudo mkswap /swapfile
sudo swapon /swapfile

编译完成后删除:


sudo swapoff /swapfile
sudo rm /swapfile

如果成功,则显示:


Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build‘
‘build‘ finished successfully (7m31.696s)
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 for explanation):
brite                     click                     openflow                 

Leaving directory `./ns-3-dev

3 测试

3.1 添加实例程序

Waf工具用于脚本运行,并保证共享库在运行时处在正确位置。 通过修改Waf程序配置,添加实例程序:


$ ./waf clean
$ ./waf configure --enable-examples --enable-tests --enable-modules=core
$ ./waf build

3.2 单元测试

NS-3自带单元测试功能,有了上述实程序之后,进行验证:


fyang@fyang-virtual-machine:~/project/workspace/repos/ns-3-allinone/ns-3-dev$ ./test.py 
Waf: Entering directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build‘
Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build‘
‘build‘ finished successfully (0.210s)

Modules built:
core                     

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 event-garbage-collector
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 hash
PASS: TestSuite type-id
PASS: TestSuite threaded-simulator
PASS: TestSuite random-number-generators
PASS: TestSuite random-variable-stream-generators
PASS: Example examples/tutorial/hello-simulator
PASS: Example examples/tutorial/fourth
PASS: Example src/core/examples/main-callback
PASS: Example src/core/examples/sample-simulator
PASS: Example src/core/examples/main-ptr
PASS: Example src/core/examples/sample-random-variable
PASS: Example src/core/examples/sample-simulator.py

3.3 运行测试

运行模拟器:


./waf --run hello-simulator
结果:
  
Waf: Entering directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build‘
Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build‘
‘build‘ finished successfully (0.202s)
Hello Simulator

4 参考文献

  1. explain-like-im-5-kerberos
  2. g++ error
  3. 使能测试程序1
  4. 使能测试程序2
    getting-started
 

Ubuntu上安装NS-3实践

标签:自带   BMI   ice   efault   sign   nim   thread   完成   openflow   

原文地址:https://www.cnblogs.com/zywnnblog/p/12198983.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!