diff --git a/samples/main-random-walk.cc b/samples/main-random-walk.cc index e1c308359..b1b542c17 100644 --- a/samples/main-random-walk.cc +++ b/samples/main-random-walk.cc @@ -10,6 +10,8 @@ #include "ns3/command-line.h" #include "ns3/simulator.h" #include "ns3/nstime.h" +#include "ns3/node.h" +#include "ns3/node-list.h" using namespace ns3; @@ -39,15 +41,15 @@ int main (int argc, char *argv[]) RandomTopology topology; - std::vector > objects; for (uint32_t i = 0; i < 100; i++) { - Ptr notifier = Create (); - notifier->TraceConnect ("/course-change", MakeCallback (&CourseChange)); - objects.push_back (notifier); + Ptr node = Create (); + node->AddInterface (Create ()); } - topology.Layout (objects.begin (), objects.end ()); + topology.Layout (NodeList::Begin (), NodeList::End ()); + NodeList::Connect ("/nodes/*/$MobilityModelNotifier/course-change", + MakeCallback (&CourseChange)); Simulator::StopAt (Seconds (100.0));