Incorrect example code in the tutorial

24 views
Skip to first unread message

Peter Braun

unread,
Apr 14, 2016, 7:27:37 AM4/14/16
to ns-3-users
Hello!

I'm going through the NS-3 tutorial. Actually I believe that the example code provided in the 'Tracing / Connect with Config' section is incorrect.

This code is provided as an example:

Ptr<Object> theObject = wifiStaNodes.Get (nWifi - 1);
theObject
->TraceConnect ("CourseChange", MakeCallback (&CourseChange));

Actually what it does is to try to connect Node's CourseChange Attribute to CourseChange() callback. Although Node does not have such attribute.

Instead I think the correct code would be something like this:

Ptr<Object> o = wifiStaNodes.Get (nWifi - 1)->GetObject<MobilityModel>();
o
->TraceConnect("CourseChange", "ctx", MakeCallback (CourseChange));

Please cross check.

Thanks,
Peter


Tommaso Pecorella

unread,
Apr 27, 2016, 7:40:51 PM4/27/16
to ns-3-users, Tom Henderson
Hi Peter,

sorry if I didn't reply earlier. You're totally right, the tutorial code won't work.
It won't work because:
1) TraceConnect wants 3 arguments, and in the examples there are 2, and
2) The connection won't work, because TraceConnect doesn't search into aggregated objects. As a consequence, it won't find any trace named "CourseChange" in the Node object.


We'll fix the tutorial, thanks.

Cheers,

T.
Reply all
Reply to author
Forward
0 new messages