c++ - 在 NS-3 中使用 Ramdomwaypoint 模型时如何设置位置分配器

标签 c++ ns-3

我尝试通过将移动模型名称 (RandomWalk2dMobilityModel) 替换为 RandomWaypointMobilityModel 来更改示例代码 (third.cc)。运行代码后,结果是这样的输出

assert failed. cond="m_position", msg="No position allocator added before using this model"

所以基本上这是与错误消息最相关的代码

MobilityHelper 移动性;

mobility.SetPositionAllocator ("ns3::GridPositionAllocator",

"MinX", DoubleValue (0.0),

"MinY", DoubleValue (0.0),

"DeltaX", DoubleValue (5.0),

"DeltaY", DoubleValue (10.0),

"GridWidth", UintegerValue (3),

"LayoutType", StringValue ("RowFirst"));

//mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", //"边界", RectangleValue (Rectangle (-50, 50, -50, 50)));

mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel");
mobility.Install (wifiStaNodes);

mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

mobility.Install (wifiApNode);

我感到困惑的是在设置移动模型之前,已经设置了它适用于 randomwalk2d 的 position allocator,但是,显然它不适用于 randomwaypoint 模型。那么如何处理呢? 如果有人可以帮助我解决这个问题,我将不胜感激。

非常感谢。

最佳答案

当您使用 RandomWayPointModel 时,实际上应该有两个位置分配器。

  • 第一个,您已经使用过的,用于节点的初始位置。

  • 第二个是 RandomWayPointModel 的属性,用于选择目标点。请引用documentation更多细节。

关于c++ - 在 NS-3 中使用 Ramdomwaypoint 模型时如何设置位置分配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44593991/

相关文章:

c++ - GL_TEXTURE_CUBE_MAP 中具有不同分辨率的面孔

c++ - Windows中的管道句柄如何关闭? (_pclose() 的 fclose())?

c++ - 在最新的 C++ 中,如何创建一个具有按组和子组(如树)组织的成员函数的类?

c++ - NS3 添加新模块 - gcc 未找到包含的 header

eclipse - 在 Eclipse 下启用 ns-3 日志记录

具有特征的类的 C++ 重载运算符

c++ - 使用可变参数函数 C++

c++ - 如何使用 WAF 链接静态库?

c++ - 字符串赋值错误

c++ - 将 NS3 返回/退出代码(通过 waf)捕获为 Bash 脚本中的变量