Ubuntu上安装NS

Wesley13
• 阅读 805

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
点赞
收藏
评论区
推荐文章
blmius blmius
2年前
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
Easter79 Easter79
2年前
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
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Wesley13 Wesley13
2年前
Java获得今日零时零分零秒的时间(Date型)
publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这