我写的内容多是重复NS3官方文档里面的内容,如果看不懂我写的东西或我的内容与官方文档有冲突,以官方文档为准。建议大家多看看文档(程序员的必备技能)。

下载NS3

有多种下载NS3方式,最简单的是直接从官网下载NS3。从官网找到下载地址,下载安装包ns-allinone-3.25.tar.bz2,解压缩得到文件夹ns-allinone-3.25。不知道是什么原因,官网有时候连接不上,我给一个百度网盘的地址http://pan.baidu.com/s/1bplwXsV

安装前准备

安装NS3需要许多软件的支持,比如Python。网址https://www.nsnam.org/wiki/Installation介绍了不同系统需要安装什么软件支持,有提供下载安装方式。其实它就是NS3的详细的安装教程,你可以直接阅读教程而不需要看我的这篇文章。

编译

安装NS3也有多种方式。(下面的操作许多都要管理员权限,先su获取管理员权限吧)

使用build.py编译

最简单的是build.py。进入文件夹ns-allinone-3.25

cd ns-allinone-3.25
ls

可以看到:
bake constants.py ns-3.25 README
build.py netanim-3.107 pybindgen-0.17.0.post49+ng0e4e3bc util.py
建议看看README。
执行

./build.py --enable-examples --enable-tests

看到下面的内容说明你已经编译好了
Build commands will be stored in build/compile_commands.json
‘build’ finished successfully (12.537s)

Modules built:
antenna aodv applications
bridge buildings config-store
core csma csma-layout
dsdv dsr energy
fd-net-device flow-monitor internet
internet-apps 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 traffic-control uan
virtual-net-device wave wifi
wimax

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

编译过程你可能会发现有红色字体出现,如(红色字体在这里用加粗字体表示)
—- Summary of optional NS-3 features:
Build profile : debug
Build directory :
Python Bindings : not enabled (Python library or headers missing)
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
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 : not enabled (Python Bindings are needed but not enabled)
Use sudo to set suid bit : not enabled (option –enable-sudo not selected)
Build tests : enabled
Build examples : enabled
GNU Scientific Library (GSL) : enabled
Gcrypt library : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.)
‘configure’ finished successfully (5.419s)

不用担心,这只是显示NS3的一些功能或特性没有启动(个人认为),不会影响NS3的安装。

使用Waf编译

文档推荐使用Waf编译NS3。
首先进入文件夹ns-3.25

cd ns-allinone-3.25/ns-3.25
ls

也可以看到有一个README文件,里面也有安装教程,可以看看。
继续编译

./waf clean
./waf --build-profile=debug --enable-examples --enable-tests configure

这一步是配置NS3,“–build-profile=debug”是让NS3以debug模式运行,可以在运行时查看日志信息,方便调试。最后出现
‘configure’ finished successfully (2.493s)
说明配置成功。接着编译

./waf

最后看到
Build commands will be stored in build/compile_commands.json
‘build’ finished successfully (7m41.748s)

Modules built:
antenna aodv applications
bridge buildings config-store
core csma csma-layout
dsdv dsr energy
fd-net-device flow-monitor internet
internet-apps 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 traffic-control uan
virtual-net-device wave wifi
wimax

Modules not built (see ns-3 tutorial for explanation):
brite click openflow
visualizer
说明编译成功。

安装

这一步不是必须的。缺少这一步,只能在ns-3.25文件夹中使用NS3,不能在ns-3.25文件夹以外的文件夹中使用NS3。我就没有执行这一步。

./waf install

执行之后,会把NS3的安装到其他的位置,文档是这么说的:
By default, the prefix for installation is /usr/local, so ./waf install will install programs into
/usr/local/bin, libraries into /usr/local/lib, and headers into /usr/local/include.

测试

测试看看是否成功地安装好NS3:

./test.py -c core

最后输出
219 of 222 tests passed (219 passed, 3 skipped, 0 failed, 0 crashed, 0 valgrind errors)
List of SKIPped tests:
ns3-tcp-cwnd
ns3-tcp-interoperability
nsc-tcp-loss
0 failed, 0 crashed, 0 valgrind errors,虽然有skipped,应该不影响使用。
好了,你已经安装成功了!

运行脚本

执行第一个程序(又是Hello world)

./waf --run hello-simulator

直接执行命令,如果出现
Hello Simulator
恭喜你,你可以使用NS3了!
如果没有出现,可能是配置NS3时,不是使用debug模式,而是”optimized”

./waf --build-profile=optimized --enable-examples --enable-tests configure

那么控制台就不会输出Hello Simulator

Linux安装NS3相关推荐

  1. 详细介绍 安装ns3步骤

    安装ns3步骤: 准备工作-- 1.[Linux] ubuntu系统安装完成 2.熟悉Linux常用命令 开始安装-- 确保ubuntu已经完成换源---阿里云或清华,个人推荐阿里云 3.安装组件和依 ...

  2. Ubuntu 18.04 安装ns-3.30

    本文主要参考ns-3官网安装教程,结合其他博主的文章,整理如下. 首先,我使用的是基于VirtualBox的linux虚拟机,安装的Ubuntu版本为18.04.在安装ns-3过程中出现编译卡顿的情况 ...

  3. 初学者安装ns3详细步骤

    安装ns3步骤: 准备工作-- 1.[Linux] ubuntu系统安装完成 2.熟悉Linux常用命令 开始安装-- 3.安装组件和依赖库 1.快捷键Ctrl+Alt+T 打开终端,输入以下命令: ...

  4. Ubuntu20.04安装NS3的3.36版本(最新版本)

    安装步骤目录 1 配置虚拟机及Anaconda3 1.1 VMware安装包&Ubuntu的光盘映像文件: 1.2 VMware安装 1.3 Ubuntu安装 1.4 Anaconda3安装 ...

  5. 实用的Linux 安装 zip unzip

    Linux 安装 zip unzip 1.apt-get 安装 apt-get install zip 2.yum 安装 yum install -y unzip zip 命令实例 1.把/home目 ...

  6. nginx linux 安装

    nginx linux 安装 进入http://nginx.org/en/download.html 下载 n  gcc 安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gc ...

  7. Linux安装Nodejs

    Linux安装Nodejs 阿里云镜像: https://npm.taobao.org/mirrors/node/ 选择所需版本,进行下载. 我这边下载的是:https://npm.taobao.or ...

  8. linux命令安装组件,Linux安装各种组件

    [TOC] Linux安装各种组件 ============================= ## 安装JDK 官网下载最新JDK ``` http://www.oracle.com/technet ...

  9. arch linux安装_如何从头开始安装Arch Linux

    arch linux安装 by Andrea Giammarchi 由Andrea Giammarchi In this article, you'll learn how to install Ar ...

最新文章

  1. java基础-基本的输入与输出
  2. 世界不乏爱因斯坦,缺乏的适合他茁壮成长的环境
  3. 异常:java.lang.IllegalArgumentException: Control character in cookie value or attribute.
  4. css——模态框【遮罩层的制作;信息层;往白色的块里添加表单】
  5. OTDR光纤测试仪:您的光纤终极故障排除工具
  6. JS设计模式五:职责链模式
  7. [css] CSS3有哪些新增的特性?
  8. mysql数据库是下面哪种类型的数据库_SQL数据库 选择哪个类型的数据库?
  9. CVS的几个学习小站及配置说明
  10. 小鹏汽车9月总交付10412台 成为新造车势力中第一家月交付过万的企业
  11. python工程师简历项目经验怎么写_班长项目经验简历范文
  12. 循环神经网络、注意力机制、Seq2Seq、Transformer与卷积神经网络(打卡2)
  13. wordpress网址导航源码全局自适应手机端网站导航简约风主题模板
  14. python期末考试题目及答案_Python语言基础答案试题题目及答案,期末考试题库,章节测验答案...
  15. Latex 箭头 下标 符号上下写文字 正方形和三角形
  16. Windows CE学习几个经验
  17. Y6000五口千兆网口5G工业路由器
  18. 2017清北学堂(提高组精英班)集训笔记——图论
  19. vue项目pc端使用rem进行适配 (lib-flexible+postcss-pxtorem)
  20. NGUI与新版Prefab系统冲突问题

热门文章

  1. 读书笔记 - 我读《财务自由之路》 - 博多 舍费尔 / 你真正想要的是什么
  2. 老猿学5G扫盲贴:N6接口用户平面协议栈对应的网络分层模型
  3. clamav(clamav杀毒 启动)
  4. 【已解决】Try using tf.compat.v1.experimental.output_all_intermediates(True).
  5. r语言归一化_R语言︱数据规范化、归一化
  6. 在1688上,中国工厂正在「被看见」
  7. (附源码)计算机毕业设计SSM基于B_S的汽车售后服务管理系统
  8. 虚拟内存修改盘符的设置方法
  9. 【Codeforces Round #560 (Div. 3)】 A B C D E F1 F2
  10. PHP 数组千变万化