Ubuntu上安装NS-3实践

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自带单元测试功能,有了上述实程序之后,进行验证:


[email protected]:~/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

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

时间: 2024-10-13 11:43:48

Ubuntu上安装NS-3实践的相关文章

64位ubuntu上安装 hadoop-2.4.0

完全参考:http://blog.csdn.net/cruise_h/article/details/18709969 这上面的安装教程 伪分布配置: http://my.oschina.net/mynote/blog/93735 64位ubuntu上安装 hadoop-2.4.0,布布扣,bubuko.com

[异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议

一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题(vmware坑了,virtual-box简单安装,在virtual-box中安装精简版win7)> link:http://www.cnblogs.com/zjutlitao/p/5061917.html 遇到的在ubuntu上装虚拟机坑之后,接下来又遇到了一个新的问题—— 如何在在ubuntu上安装

在ubuntu上安装maven

下载maven http://maven.apache.org/download.cgi 解压 用压缩管理器打开,解压至home目录下 配置环境变量 sudo gedit /etc/profile 添加 export M2_HOME=<span style="color:#ff0000;">/home/weibo/apache-maven-3.0.5(视自己的情况而定)</span> export M2=$M2_HOME/bin export PATH=$M2:

Ubuntu上安装QQ

作者:邹祁峰 邮箱:[email protected] 博客:http://blog.csdn.net/qifengzou 日期:2014.06.12 转载请注明来自"祁峰"的CSDN博客 自从腾讯QQ发布Linux QQ后,其他第三方均纷纷退出Linux版本QQ的开发和维护,而后腾讯QQ也停止了Linux QQ的开发和维护,致使目前Ubuntu上只能使用网页QQ. 而直接登陆网页QQ又使用户不能及时方便的获知对方的回复,目前可使用PIDGIN登陆QQ,能很好的解决网页QQ的这个缺点.

如何在ubuntu上安装flash_player

一.如何在ubuntu上安装Flash Player 相信很多玩ubuntu的都会遇到这样一个问题,当你在网上看视频时,屏幕总会弹出你没用安装 Flash Player,然后就有一个选项叫你下载Flash Player. 遇到这种情况时,我们先下载下来,选择linux tar.gz版本,下载,然后解压到当前目录. 接着点开解压后的文件,你会看到libflashplayer.so文件,打开终端,输入以下命令就行了. sudo cp libflashplayer.so /usr/lib/mozill

在64位ubuntu上安装alienbrain客户端

一.首先从Alienbrain_EN_10.5.zip安装包(网上可搜索下载)里提取出linux版安装文件:Installations/Clients/Linux/NoVM/install.bin并chmod+x使之可执行 二.如果直接运行,可能会出现大把问题,逐步解决如下: 1.首先是报libc.so.6找不到:strings: '/lib/libc.so.6': No such file.这里只要做个链接:/lib/libc.so.6 -> /lib/x86_64-linux-gnu/lib

Ubuntu上安装MongoDB(译)

add by zhj:直接从第四步开始就可以了,而且安装好MongoDB后会自动启动的,不必自己去执行启动命令 原文:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ 一. 概述 通过这个教程,我们可以用.deb包在LTS Ubuntu上安装MongoDB社区版.虽然Ubuntu自己也有MongoDB包,但是官方的MongoDB社区版通常要更新一些. 注:平台支持 MongoDB只为64位 LTS Ubuntu

通过ppa在ubuntu上安装atom编辑器

在终端中执行以下命令即可,很方便. sudo add-apt-repository ppa:webupd8team/atom sudo apt-get update sudo apt-get install atom 支持Ubuntu 14.10, 14.04, 13.10 和 12.04 通过ppa在ubuntu上安装atom编辑器,布布扣,bubuko.com

ubuntu上安装nodejs

目录: 1. nodejs的下载 2. 解压和安装 3. 安装过程中出现过的问题 4. 总结 1. nodejs的下载 我刚开始没有linux系统,于是安装了nodejs的windows版本进行学习.这两天把ubuntu鼓捣好了,也就想着在ubuntu上装上nodejs. nodejs的官网(http://nodejs.org/)点击install进行下载,而且下载的就是当前的最新版本:不过在windows默认下载的是.msi文件,在linux下默认下载的是.tar.gz!ubuntu下载默认的

Ubuntu上安装oracle java 7

1.通过PPA 这种安装方式特点: 1.安装的java含jdk.jre和浏览器插件 2.自动识别64bit或者32bit 3.自动升级为最新版本 4.支持 Ubuntu 13.10, 13.04, 12.10, 12.04 and 10.04 或  Linux Mint 1.1在终端中执行安装命令: sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-