NS3 中FANET仿真

Flying Adhoc Network Simulation (FANET) using NS3
上述网站已经给了很完整的教程和源代码,但示例教程是以ns3.31为运行环境的,对于之前搭建的3.38版本会有一些报错。

首先进入目录

cd ns-allinone-3.38/ns-3.38

1. 网站上使用

./waf run scratch/fanetex.cc

我也曾尝试使用这个./waf,差了很多资料失败了,还是使用./ns3、

./ns3 run scratch/fanetex.cc

2. 出现报错:

大概意思有两处发生报错,一个是“WIFI_PHY_STANDARD_80211b",另一处是”Default“部分。

原因在于3.31版本的语法与3.38的有所出入:
(1)WIFI协议的表示方法发生改变

源代码

wifi.SetStandard (WIFI_PHY_STANDARD_80211b);

 修改为

wifi.SetStandard (WIFI_STANDARD_80211b);

(2)创建Yans和PHY对象不需要原代码那样一长串的定义

源代码

  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

修改为

  YansWifiPhyHelper wifiPhy;
  YansWifiChannelHelper wifiChannel;

 3. 再次运行

./ns3 run scratch/fanetex.cc

运行完毕目录中会生成.tr、.cap 、.xml文件,其中.tr数据量较大,tracemetrics分析会很费时间按,cap文件使用wireshark观察,xml使用NetAnim打开

4. 我将生成的xml文件命名为Fanetex2D和Fanetex3D,以2D为例

cd ..
cd netanim-3.109
./NetAnim

ns3::FlowMonitorHelper’ and ‘ns3::Ptr<ns3::FlowMonitor>’) 84 | flowMonitor = flowHelper.InstallAll(); | ^ In file included from /home/lxa/repos/ns-3-allinone/ns-3.37/build/include/ns3/flow-monitor-helper.h:1, from /home/lxa/repos/ns-3-allinone/ns-3.37/build/include/ns3/flow-monitor-module.h:6, from /home/lxa/repos/ns-3-allinone/ns-3.37/scratch/fanet-simplified-olsr.cc:9: /home/lxa/repos/ns-3-allinone/ns-3.37/src/flow-monitor/helper/flow-monitor-helper.h:48:24: note: candidate: ‘ns3::FlowMonitorHelper& ns3::FlowMonitorHelper::operator=(const ns3::FlowMonitorHelper&)’ <deleted> 48 | FlowMonitorHelper& operator=(const FlowMonitorHelper&) = delete; | ^~~~~~~~ /home/lxa/repos/ns-3-allinone/ns-3.37/src/flow-monitor/helper/flow-monitor-helper.h:48:34: note: no known conversion for argument 1 from ‘ns3::Ptr<ns3::FlowMonitor>’ to ‘const ns3::FlowMonitorHelper&’ 48 | FlowMonitorHelper& operator=(const FlowMonitorHelper&) = delete; | ^~~~~~~~~~~~~~~~~~~~~~~~ /home/lxa/repos/ns-3-allinone/ns-3.37/scratch/fanet-simplified-olsr.cc:87:12: error: base operand of ‘->’ has non-pointer type ‘ns3::FlowMonitorHelper’ 87 | flowMonitor->CheckForLostPackets(); | ^~ /home/lxa/repos/ns-3-allinone/ns-3.37/scratch/fanet-simplified-olsr.cc:89:61: error: base operand of ‘->’ has non-pointer type ‘ns3::FlowMonitorHelper’ 89 | std::map<FlowId, FlowMonitor::FlowStats> stats = flowMonitor->GetFlowStats(); | ^~ /home/lxa/repos/ns-3-allinone/ns-3.37/scratch/fanet-simplified-olsr.cc:110:1: error: expected ‘}’ at end of input 110 | } | ^ /home/lxa/repos/ns-3-allinone/ns-3.37/scratch/fanet-simplified-olsr.cc:15:1: note: to match this ‘{’ 15 | { | ^ make[3]: *** [scratch/CMakeFiles/scratch_fanet-simplified-olsr.dir/build.make:65:scratch/CMakeFiles/scratch_fanet-simplified-olsr.dir/fanet-simplified-olsr.cc.o] 错误 1 make[2]: *** [CMakeFiles/Makefile2:17732:scratch/CMakeFiles/scratch_fanet-simplified-olsr.dir/all] 错误 2 make[1]: *** [CMakeFiles/Makefile2:17738:scratch/CMakeFiles/scratch_fanet-simplified-olsr.dir/rule] 错误 2 make: *** [Makefile:5844:scratch_fanet-simplified-olsr] 错误 2
03-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值