How to set up the position allocator when using Ramdomwaypoint model in NS-3

馋奶兔 提交于 2019-12-13 18:03:01

问题


I tried to alter the example code(third.cc) by replacing the mobility model name(RandomWalk2dMobilityModel) with RandomWaypointMobilityModel. After running the code, it turned out to be an output like

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

So basically this is the most relevant code with the error msg

MobilityHelper mobility;

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", // "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));

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

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

mobility.Install (wifiApNode);

What I am confused about is before setting mobility model, there has already set up the position allocator it worked for randomwalk2d, however, obviously it does not work for randomwaypoint model. So how to deal with it? I'll appreciate if there is someone who can help me to figure it out.

Many thanks.


回答1:


There should be actually TWO position allocators when you are using RandomWayPointModel.

  • The first, the one you have already used, is for the initial position of the nodes.

  • The second though, is an attribute to the RandomWayPointModel and it is used to pick a destination point. Please refer to the documentation for more details.



来源:https://stackoverflow.com/questions/44593991/how-to-set-up-the-position-allocator-when-using-ramdomwaypoint-model-in-ns-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!