I am trying to understand what the position of all the nodes in the third script are as I build on my understanding and practice of navigating the NS-3 code and functionality. So, I extended the tracing example of the tutorial. I get output for all STA nodes, but not the AP node. I found a very similar discussion occurring in a topic from long back:
But after the author of the post pointed out the "and/or", I read Mathieu's reply as to conceding to the point that it should print the position for the AP.
Let me show you all that I have worked on and looked at. Below is my modified version of the network diagram (I only made note of capture points and client/server).
The interesting thing to me is that the AP node is written to the left of the third STA node. However, I believe the AP node should be positioned at (0,10) according to the PositionAllocator for the example. So, it is interesting to see it is shown as to the right of the third STA node.
// Default Network Topology
// (& means pcap listening point)
//
// Wifi 10.1.3.0
// AP
// * * * &*
// | | | | 10.1.1.0
// Cn5 n6 n7 n0&--------------&n1 n2 n3 Sn4
// point-to-point | | | |
// &================
// LAN 10.1.2.0
I have not modified the mobility portion of the code. Since GridWidth is 3, I agree with the positions of the first three nodes, but not of the AP.
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.Install (wifiStaNodes);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (wifiApNode);
Here is my implementation of printing all nodes positions and the callback function (sink) is shown next. I just modified it to print time.
std::ostringstream oss4; //cant get this one to work
oss4 << "/NodeList/" << wifiApNode.Get (0)->GetId () << "/$ns3::MobilityModel/CourseChange";
Config::Connect (oss4.str (), MakeCallback (&CourseChanged));
//std::cout << oss4.str () << std::endl; //printed the string once to make sure it is correct.
std::ostringstream oss;
oss << "/NodeList/" << wifiStaNodes.Get (nWifi - 1)->GetId () << "/$ns3::MobilityModel/CourseChange";
Config::Connect (oss.str (), MakeCallback (&CourseChanged));
std::ostringstream oss2;
oss2 << "/NodeList/" << wifiStaNodes.Get (nWifi - 2)->GetId () << "/$ns3::MobilityModel/CourseChange";
Config::Connect (oss2.str (), MakeCallback (&CourseChanged));
std::ostringstream oss3;
oss3 << "/NodeList/" << wifiStaNodes.Get (nWifi - 3)->GetId () << "/$ns3::MobilityModel/CourseChange";
Config::Connect (oss3.str (), MakeCallback (&CourseChanged));
void
CourseChanged (std::string context, Ptr<const MobilityModel> model)
{
Vector position = model->GetPosition ();
NS_LOG_UNCOND ( "At time " << Simulator::Now ().GetSeconds () << " " << context << " x = " << position.x << ", y = " << position.y);
}
Results
Below is one of my results. The single line having "Test" was when I notoriously added a cout line to "ConstantPositionMobilityModel::DoSetPosition" to see if the function was being called. It was printed. I see the positions of all 3 STAs of course, but not the AP.
Waf: Leaving directory `/home/andrew/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (1m5.206s)
Test
At time 0 /NodeList/5/$ns3::MobilityModel/CourseChange x = 0, y = 0
At time 0 /NodeList/6/$ns3::MobilityModel/CourseChange x = 5, y = 0
At time 0 /NodeList/7/$ns3::MobilityModel/CourseChange x = 10, y = 0
At time 3.04945 /NodeList/5/$ns3::MobilityModel/CourseChange x = -5.0353, y = -8.63978
At time 3.10419 /NodeList/6/$ns3::MobilityModel/CourseChange x = 14.5294, y = -3.03146
At time 4.21141 /NodeList/7/$ns3::MobilityModel/CourseChange x = 0.654123, y = -3.55733
I attempted to navigate the code to see if I could find out.
From "MobilityHelper::Install (Ptr<Node> node) const" it seems to me that the Mobility Model "SetPosition" function should be called.
Vector position = m_position->GetNext ();
model->SetPosition (position);
Which will:
which will call NotifyCourseChange. Since, the initial position of the STA nodes is printed or at least the initial position of even the 0,0 STA node is printed. I would imagine that the AP node would as well.
Do you know what I am missing here? Perhaps AP nodes are treated differently in terms of mobility, but I couldn't find anything on that.
The last suggestion Mathieu had was to have a periodic timer. If anyone could elaborate on his suggestion or provide a link to where something similar is done, I think I can figure it out. I did a little searching