Ubuntu上安装NS

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

但是会碰到如下错误:

1[1459/1770] cxx: src/lte/model/lte-ffr-sap.cc -> build/src/lte/model/lte-ffr-sap.cc.1.o 2[1460/1770] cxx: src/lte/model/lte-fr-no-op-algorithm.cc -> build/src/lte/model/lte-fr-no-op-algorithm.cc.1.o 3[1461/1770] cxx: src/lte/model/lte-ffr-soft-algorithm.cc -> build/src/lte/model/lte-ffr-soft-algorithm.cc.1.o 4[1462/1770] cxx: src/lte/model/lte-ue-power-control.cc -> build/src/lte/model/lte-ue-power-control.cc.1.o 5[1463/1770] cxx: build/src/lte/bindings/ns3module.cc -> build/src/lte/bindings/ns3module.cc.7.o 6g++: internal compiler error: Killed (program cc1plus) 7Please submit a full bug report, 8with preprocessed source if appropriate. 9See for instructions. 10Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build' 11Build failed 12 -> task in 'ns3module_lte' failed (exit status 4): 13 {task 159048492: cxx ns3module.cc -> ns3module.cc.7.o} 14['/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'] 15Traceback (most recent call last): 16 File "./build.py", line 170, in 17 sys.exit(main(sys.argv)) 18 File "./build.py", line 161, in main 19 build_ns3(config, build_examples, build_tests, args, build_options) 20 File "./build.py", line 81, in build_ns3 21 run_command([sys.executable, "waf", "build"] + build_options) 22 File "/home/fyang/project/workspace/repos/ns-3-allinone/util.py", line 24, in run_command 23 raise CommandError("Command %r exited with code %i" % (argv, retval)) 24util.CommandError: Command ['/usr/bin/python', 'waf', 'build'] exited with code 1

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

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

编译完成后删除:

1sudo swapoff /swapfile 2sudo rm /swapfile

如果成功,则显示:

1Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build' 2'build' finished successfully (7m31.696s) 3Modules built: 4antenna aodv applications 5bridge buildings config-store 6core csma csma-layout 7dsdv dsr energy 8fd-net-device flow-monitor internet 9lr-wpan lte mesh 10mobility mpi netanim (no Python) 11network nix-vector-routing olsr 12point-to-point point-to-point-layout propagation 13sixlowpan spectrum stats 14tap-bridge test (no Python) topology-read 15uan virtual-net-device visualizer 16wave wifi wimax 17 18Modules not built (see ns-3 tutorial for explanation): 19brite click openflow 20 21Leaving directory `./ns-3-dev

3 测试

3.1 添加实例程序

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

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

3.2 单元测试

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

1fyang@fyang-virtual-machine:~/project/workspace/repos/ns-3-allinone/ns-3-dev$ ./test.py 2Waf: Entering directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build' 3Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build' 4'build' finished successfully (0.210s) 5 6Modules built: 7core 8 9Modules not built (see ns-3 tutorial for explanation): 10brite click openflow 11 12PASS: TestSuite attributes 13PASS: TestSuite callback 14PASS: TestSuite command-line 15PASS: TestSuite config 16PASS: TestSuite global-value 17PASS: TestSuite int64x64 18PASS: TestSuite object-name-service 19PASS: TestSuite object 20PASS: TestSuite ptr 21PASS: TestSuite event-garbage-collector 22PASS: TestSuite sample 23PASS: TestSuite simulator 24PASS: TestSuite time 25PASS: TestSuite timer 26PASS: TestSuite traced-callback 27PASS: TestSuite type-traits 28PASS: TestSuite watchdog 29PASS: TestSuite hash 30PASS: TestSuite type-id 31PASS: TestSuite threaded-simulator 32PASS: TestSuite random-number-generators 33PASS: TestSuite random-variable-stream-generators 34PASS: Example examples/tutorial/hello-simulator 35PASS: Example examples/tutorial/fourth 36PASS: Example src/core/examples/main-callback 37PASS: Example src/core/examples/sample-simulator 38PASS: Example src/core/examples/main-ptr 39PASS: Example src/core/examples/sample-random-variable 40PASS: Example src/core/examples/sample-simulator.py

3.3 运行测试

运行模拟器:

1./waf --run hello-simulator 2 3 4结果: 5 6 7Waf: Entering directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build' 8Waf: Leaving directory `/home/fyang/project/workspace/repos/ns-3-allinone/ns-3-dev/build' 9'build' finished successfully (0.202s) 10Hello Simulator

4 参考文献

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

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

swap空间的增减方法

(1)增大swap空间去激活swap交换区:swapoff v /dev/vg00/lvswap扩展交换lv:lvextend L 10G /dev/vg00/lvswap重新生成swap交换区:mkswap /dev/vg00/lvswap激活新生成的交换区:swapon v /dev/vg00/lvswap