ns-3环境搭建

ns-3 Network Simulator

ns-3 is a discrete-event network simulator for internet systems, targeted primarily for research and educational use. ns-3 is free, open-source software, licensed under the Gun GPLv2 license, and maintained by a worldwide community.

ns-3 是一款由 C++ 语言编写的开源网络仿真软件,主要运行平台是Linux。在ns-3中,网络拓扑中的节点、链路、协议栈的各个层次等被抽象成为各种C++类。仿真时,用C++ 语言编写一个仿真脚本,通过类的对象之间的函数调用形成关联,从而构建网络拓扑、为节点安装必要的网络协议栈等。ns-3的默认安装支持大量常见的网络协议,如无线局域网(基于IEEE802.11 系列标准,即WiFi)、4G LTE 网络、无线传感器网络等。此外,借助C++面向对象所带来的高度可扩展性,第三方可以为ns-3添加新的模块,实现新的网络协议。例如,5GNR、同步轨道卫星(GeostationaryEarth Orbit,GEO)通信系统、低轨卫星(LowEarth Orbit,LEO)星座通信网络等当前研究较为热门的系统均有一些第三方实现。作为开源项目,ns-3也会适时地将一些成熟的第三方模块纳入默认安装。

Linux basic

linux命令

修改root密码

sudo passwd root

tar 解压命令

-c:建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件

-z:有gzip属性的-j:有bz2属性的-Z:有compress属性的-v:显示所有过程

-O:将文件解开到标准输出

linux环境

Download

ns-3下载安装过程

下载源代码及解压

$ wget https://www.nsnam.org/releases/ns-allinone-3.41.tar.bz2

$ tar xfj na-allinone-3.41/ns.tar.bz2

这一步基本不会出现什么问题,下载失败便是网络问题,解决办法:修改下载超时时长或在Windows下载好直接拖入虚拟机中。

Building and testing ns-3

官方教程文档原文:Once you have obtained the source either by downloading a release or by cloning a Git repository, the next step is to configure the build using the CMake build system. The below commands make use of a Python wrapper around CMake, called ns3, that simplifies the command-line syntax, resembling Waf syntax. Thereare several options to control the build, but enabling the example programs and the tests, for a default build profile (with asserts enabled and and support for ns-3 logging) is what is usually done at first:

翻译:通过下载发行版或克隆 Git 存储库获得源代码之后,下一步是使用 CMake 构建系统配置构建。下面的命令使用了 CMake 的 Python 包装器 ns3,它简化了命令行语法,类似于 Waf 语法。对于默认的构建配置文件(启用断言并支持 ns-3日志记录) ,控制构建有几个选项,但是启用示例程序和测试通常是首先要做的事情:

$ ./ns3 configure --enable-examples --enable-tests

Depending on how fast your CPU is, the configuration command can take anywhere from a few seconds to a minute. Then, use the ns3 program to build the ns-3 module libraries and executables:

翻译:根据 CPU 的运行速度,配置命令可能需要几秒钟到一分钟的时间。然后,使用 ns3程序构建 ns-3模块库和可执行文件:

$ ./ns3 build

教程中指出配置环境需要CMake来搭建系统,若系统中没有cmake需要下载

$ sudo apt-get cmake

问题:GNU 7.5.0 compiler is below the minimum required version 9.0.0 。

Solution:更新编译器或者降低ns-3版本(首先尝试更新编译器,更新到9.0.0,测试还是出错,若要使用最高版本,使用最新镜像的ISO。我这里使用的是ubuntu-22.04-beta-desktop-amd64。 ns-3低版本使用ns-allinone-3.27.tar.bz2后测试正常)

问题:无法运行./ns3 configure 显示没有这个moudle

Solution:如原文所讲,The below commands make use of a Python wrapper around CMake, called ns3。运行ns3是使用Python脚本实现的,没有cmake自然运行不了,解决办法就是下载cmake

完成环境构建运行自带的测试脚本

$ ./test.py

测试全部通过

ps: If they pass, you have made a successful initial build of ns-3.

  • 26
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值