Tracing CourseChange of AP node in the tutorial example third

484 views
Skip to first unread message

Andrew Stanton

unread,
Mar 11, 2013, 11:06:48 AM3/11/13
to ns-3-...@googlegroups.com
Hello,

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:


Mathieu first noted the CourseChange attribute description, which I also read:

The value of the position and/or velocity vector changed

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.

Well, it depends on the mobility model you use. The
ConstantPositionMobilityModel will emit CourseChange whenever the
position changes.


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:

void 
MobilityModel::SetPosition (const Vector &position)
{
  DoSetPosition (position);
}

which will:

void
ConstantPositionMobilityModel::DoSetPosition (const Vector &position)
{
  m_position = position;
  NotifyCourseChange ();
}

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.

Conclusion/Final Questions:

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

Regards
~ Andrew Stanton

Andrew Stanton

unread,
Mar 11, 2013, 11:29:19 AM3/11/13
to ns-3-...@googlegroups.com
Sorry, a few typos from:



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.

Corrections:

Let me show you all what 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 to the right 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.
 

Konstantinos

unread,
Mar 11, 2013, 11:36:06 AM3/11/13
to ns-3-...@googlegroups.com
Dear Andrew,

Mathews answer was clear. The ChangeCourse callback will fire if there is ANY change in the mobility of a node.
Since you have your AP node with constant position, it will not change its position by it self. You can change it with a callback your self, which will cause the ChangeCourse to fire.

For the rest of the nodes (STA), you see the changes because they change automatically with the random way point model.

Andrew Stanton

unread,
Mar 11, 2013, 12:08:05 PM3/11/13
to ns-3-...@googlegroups.com
Hello Konstantinos,


Thank you for your reply.  You said:

Mathews answer was clear. The ChangeCourse callback will fire if there is ANY change in the mobility of a node.
Since you have your AP node with constant position, it will not change its position by it self.

I believe you are right.  But, there is some confusion left for me to sort out.  I did look at the functions for "RandomWalk2dMobilityModel" but could not sort out my doubt.


Previously I said:

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.

To extend on my point.  I am saying that it seems that the STA nodes are still being printed for their initial positions.  To me, if setting the APs position is not a course change, then neither would setting the position for the STA nodes.  I believe nodes default position is (0,0) so n5 doesn't even have any change of position.


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


The only reasoning I have to go along with what your saying is that more is happening for the random walk nodes by the time the NotifyCourseChange is fired and the resulting callback is fired besides the initial position.

Also, are you saying that in ConstantPositionMobilityModel that NotifyCourseChange will be called, it just will not result in a callback because there is no change in the position of the node? Where is that logic/code?


void
ConstantPositionMobilityModel::DoSetPosition (const Vector &position)
{
  m_position = position;
  NotifyCourseChange ();
}

You can change it with a callback your self, which will cause the ChangeCourse to fire.

I have searched, but I have not found any other examples of implementing my own callback besides what we see in tracing.  Could I do something like:

  std::ostringstream oss;
  oss << "/NodeList/" << wifiApNode.Get (0)->GetId () << "/$ns3::MobilityModel/Position";

  Config::Connect (oss.str (), MakeCallback (&MySinkCallBack));

Or is it more simple, like just changing the position with a few calls into the MobilityModel of the AP node?


Regards
~ Andrew Stanton


Konstantinos

unread,
Mar 11, 2013, 12:18:28 PM3/11/13
to ns-3-...@googlegroups.com


On Monday, 11 March 2013 16:08:05 UTC, Andrew Stanton wrote:
Hello Konstantinos,

Thank you for your reply.  You said:

Mathews answer was clear. The ChangeCourse callback will fire if there is ANY change in the mobility of a node.
Since you have your AP node with constant position, it will not change its position by it self.

I believe you are right.  But, there is some confusion left for me to sort out.  I did look at the functions for "RandomWalk2dMobilityModel" but could not sort out my doubt.

Previously I said:

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.

To extend on my point.  I am saying that it seems that the STA nodes are still being printed for their initial positions.  To me, if setting the APs position is not a course change, then neither would setting the position for the STA nodes.  I believe nodes default position is (0,0) so n5 doesn't even have any change of position.

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


This is fired here (as initial positions for you) because the speed was changed at t=0. Their position is still the same.

The only reasoning I have to go along with what your saying is that more is happening for the random walk nodes by the time the NotifyCourseChange is fired and the resulting callback is fired besides the initial position.

Also, are you saying that in ConstantPositionMobilityModel that NotifyCourseChange will be called, it just will not result in a callback because there is no change in the position of the node? Where is that logic/code?

I can't understand that. If you mean for the initial position, I guess that would make sense. you shouldn't see the initial and only position of a node with constant position model

Andrew Stanton

unread,
Mar 11, 2013, 1:27:59 PM3/11/13
to ns-3-...@googlegroups.com
Ok, I understand what you are saying.

Thanks for your help.

~ Andrew
Reply all
Reply to author
Forward
0 new messages