Regarding tracing multiple points

25 views
Skip to first unread message

Raj Bakhunchhe

unread,
Apr 1, 2022, 3:20:45 AM4/1/22
to ns-3-...@googlegroups.com
Dear all,
As I was going through the ns-3 documentation/Building Topologies/ Building Wireless Network, there is an extension to the tutorial/third.cc example. The additional code includes the tracing of a specific node position. The code is as follows:
std::ostringstream oss;
oss << "/NodeList/" <<wifiStaNodes.Get (nWifi-1) ->GetId() <<"/$ns3::MobilityModel/CourseChange";

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

Now my question is: How can I trace all the nodes' positions? With the above code, I can only trace only one node's position.

Tom Henderson

unread,
Apr 1, 2022, 8:54:21 AM4/1/22
to ns-3-...@googlegroups.com, Raj Bakhunchhe
Use a wildcard '*' instead of 'wifiStaNodes.Get (nWifi-1)->GetId ()'; i.e.:
oss << "/NodeList/*/$ns3::MobilityModel/CourseChange";

or more simply:
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
MakeCallback (&CourseChange));

You will be able to determine which node actually called the callback by
inspecting the 'context' argument of the trace sink; i.e., the mobility
model will pass back a string with the '*' replaced by the node ID of
the node that invoked the callback.

- Tom

Raj Bakhunchhe

unread,
Apr 1, 2022, 9:26:24 AM4/1/22
to Tom Henderson, ns-3-...@googlegroups.com
Thank you so much Tom. I got the output. One more question though, I am not getting the outputs in order like 1,2,3,..,1,2,3..., instead I get like 1,2,3,...,1,3,2,.. So does this mean the tracing is done according to the node movement instead of regular orderly tracing?

Sincerely,
Raj Bakhunchhe

Tom Henderson

unread,
Apr 1, 2022, 9:45:56 AM4/1/22
to ns-3-...@googlegroups.com
On 4/1/22 06:26, Raj Bakhunchhe wrote:
> Thank you so much Tom. I got the output. One more question though, I
> am not getting the outputs in order like 1,2,3,..,1,2,3..., instead I
> get like 1,2,3,...,1,3,2,.. So does this mean the tracing is done
> according to the node movement instead of regular orderly tracing?
The tracing function is called based on the order in which the scheduler
executes events.  If you have events occurring at logically the same
time, the order that you see represents the order in which the scheduler
is storing those events with the same timestamp.  I would think it would
be fairly consistent but there may be a subtle interaction that is
reordering them.

Raj Bakhunchhe

unread,
Apr 1, 2022, 9:50:46 AM4/1/22
to ns-3-...@googlegroups.com
Thank you for the clarification Tom. I really appreciate it.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/53ee070a-a476-4cbe-ccc0-ba575e4c2823%40tomh.org.
Reply all
Reply to author
Forward
0 new messages