Ubuntu 20.04安装ns3

前言

  • 我的环境: Ubuntu 20.04,安装的是ns3-3.30.1

安装依赖包

  • 请以官网为准:https://www.nsnam.org/wiki/Installation#Ubuntu.2FDebian.2FMint
  • 有几个地方需要自己改一下,我在下面标了
  • 建议全程使用root用户进行安装,否则自行添加 sudo
    • su --
  • 首先是C++和python3(其实ubuntu 20.04已经内置了)
 apt-get install g++ python3
  • 如果你要安装的版本是3.30或3.31或ns-3-dev,你还需要安装(推荐安装)
 apt-get install python3-dev pkg-config sqlite3
  • 对Python(开发)的最低要求:为了使用ns-3-allinone存储库(从Git克隆),需要其他软件包才能获取并成功安装pybindgen和netanim。
 apt-get install python3-setuptools git
  • qt5
 apt-get install qt5-default mercurial
  • ns-3-pyviz可视化工具的依赖(安装失败也没事儿,这个以后再说)

    • 对于ns-3.28和更早的版本,PyViz基于GTK + 2,GooCanvas和GraphViz࿱

  • 7
    点赞
  • 78
    收藏
    觉得还不错? 一键收藏
  • 29
    评论
"ns3 first.cc" 可能是一个IT类问题,它可能指的是使用ns-3网络仿真器创建的第一个C++程序。如果是这样,下面是一些参考答案: ns-3是一个用于网络仿真的开源C++库。 "ns3 first.cc" 可能指的是创建ns-3程序的第一个源代码文件。下面是一个简单的示例程序,用于在ns-3中创建一个简单的网络拓扑,并演示如何在拓扑中发送和接收数据包。 ```c++ #include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" using namespace ns3; NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); int main (int argc, char *argv[]) { Time::SetResolution (Time::NS); LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); NodeContainer nodes; nodes.Create (2); PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); NetDeviceContainer devices; devices = pointToPoint.Install (nodes); InternetStackHelper stack; stack.Install (nodes); Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices); UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (10.0)); UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (10.0)); Simulator::Run (); Simulator::Destroy (); return 0; } ``` 这个程序创建了两个节点,将它们连接在一起,并在其中一个节点上启动一个UDP echo服务器,然后在另一个节点上启动一个UDP echo客户端。在客户端上,它向服务器发送一个数据包,服务器将接收它并将其回显回去。这个程序可以通过编译器编译并在ns-3中运行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 29
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值