diff --git a/examples/mixed-wireless.cc b/examples/mixed-wireless.cc index 10e331b44..bf6ac9215 100644 --- a/examples/mixed-wireless.cc +++ b/examples/mixed-wireless.cc @@ -358,7 +358,7 @@ main (int argc, char *argv[]) /////////////////////////////////////////////////////////////////////////// NS_LOG_INFO ("Run Simulation."); - Simulator::StopAt (Seconds (stopTime)); + Simulator::Stop (Seconds (stopTime)); Simulator::Run (); Simulator::Destroy (); } diff --git a/examples/simple-point-to-point-olsr.cc b/examples/simple-point-to-point-olsr.cc index bd7b39487..0f271daf1 100644 --- a/examples/simple-point-to-point-olsr.cc +++ b/examples/simple-point-to-point-olsr.cc @@ -161,7 +161,7 @@ main (int argc, char *argv[]) PointToPointHelper::EnablePcapAll ("simple-point-to-point-olsr"); PointToPointHelper::EnableAsciiAll (ascii); - Simulator::StopAt (Seconds (30)); + Simulator::Stop (Seconds (30)); NS_LOG_INFO ("Run Simulation."); Simulator::Run (); diff --git a/examples/tcp-large-transfer.cc b/examples/tcp-large-transfer.cc index 610ad0714..50ea99763 100644 --- a/examples/tcp-large-transfer.cc +++ b/examples/tcp-large-transfer.cc @@ -191,7 +191,7 @@ int main (int argc, char *argv[]) PointToPointHelper::EnablePcapAll ("tcp-large-transfer"); - Simulator::StopAt (Seconds(1000)); + Simulator::Stop (Seconds(1000)); Simulator::Run (); Simulator::Destroy (); } diff --git a/examples/wifi-ap.cc b/examples/wifi-ap.cc index 7c2c266fa..c2445f16b 100644 --- a/examples/wifi-ap.cc +++ b/examples/wifi-ap.cc @@ -170,7 +170,7 @@ int main (int argc, char *argv[]) apps.Start (Seconds (0.5)); apps.Stop (Seconds (43.0)); - Simulator::StopAt (Seconds (44.0)); + Simulator::Stop (Seconds (44.0)); Config::Connect ("/NodeList/*/DeviceList/*/Tx", MakeCallback (&DevTxTrace)); Config::Connect ("/NodeList/*/DeviceList/*/Rx", MakeCallback (&DevRxTrace)); diff --git a/samples/main-random-topology.cc b/samples/main-random-topology.cc index 7e4f32334..899a3b1ed 100644 --- a/samples/main-random-topology.cc +++ b/samples/main-random-topology.cc @@ -35,7 +35,7 @@ int main (int argc, char *argv[]) Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange", MakeCallback (&CourseChange)); - Simulator::StopAt (Seconds (100.0)); + Simulator::Stop (Seconds (100.0)); Simulator::Run (); diff --git a/samples/main-random-walk.cc b/samples/main-random-walk.cc index c0219a508..4a2106cf5 100644 --- a/samples/main-random-walk.cc +++ b/samples/main-random-walk.cc @@ -44,7 +44,7 @@ int main (int argc, char *argv[]) Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange", MakeCallback (&CourseChange)); - Simulator::StopAt (Seconds (100.0)); + Simulator::Stop (Seconds (100.0)); Simulator::Run (); diff --git a/src/devices/wifi/wifi-test.cc b/src/devices/wifi/wifi-test.cc index 1103db2e6..dbab90c63 100644 --- a/src/devices/wifi/wifi-test.cc +++ b/src/devices/wifi/wifi-test.cc @@ -81,7 +81,7 @@ WifiTest::RunOne (void) Simulator::Run (); Simulator::Destroy (); - Simulator::StopAt (Seconds (10.0)); + Simulator::Stop (Seconds (10.0)); } bool diff --git a/src/node/application.cc b/src/node/application.cc index ef7b37291..753de0847 100644 --- a/src/node/application.cc +++ b/src/node/application.cc @@ -108,15 +108,13 @@ void Application::StopApplication() // Private helpers void Application::ScheduleStart (const Time &startTime) { - m_startEvent = Simulator::Schedule(startTime - - Simulator::Now(), - &Application::StartApplication, this); + m_startEvent = Simulator::Schedule (startTime, + &Application::StartApplication, this); } void Application::ScheduleStop (const Time &stopTime) { - m_stopEvent = Simulator::Schedule(stopTime - - Simulator::Now(), + m_stopEvent = Simulator::Schedule (stopTime, &Application::StopApplication, this); } diff --git a/src/node/application.h b/src/node/application.h index 36fa34b12..d21ee6a50 100644 --- a/src/node/application.h +++ b/src/node/application.h @@ -53,13 +53,13 @@ class Application : public Object { public: static TypeId GetTypeId (void); - Application(); - virtual ~Application(); + Application (); + virtual ~Application (); /** * \brief Specify application start time - * \param startTime Start time for this application, absolute time, - * relative to the start of the simulation. + * \param startTime Start time for this application, + * relative to the current simulation time. * * Applications start at various times in the simulation scenario. * The Start method specifies when the application should be @@ -67,20 +67,20 @@ public: * private "StartApplication" method defined below, which is called at the * time specified, to cause the application to begin. */ - void Start(const Time& startTime); + void Start (const Time& startTime); /** * \brief Specify application start time. * \param startVariable the random variable to use to pick - * the real start time as an absolute time, in units of - * seconds, relative to the start of the simulation. + * the real start time as a relative time, in units of + * seconds, relative to the current simulation time. */ - void Start(const RandomVariable& startVariable); + void Start (const RandomVariable& startVariable); /** * \brief Specify application stop time * \param stopTime Stop time for this application, relative to the - * start of the simulation. + * current simulation time. * * Once an application has started, it is sometimes useful * to stop the application. The Stop method specifies when an @@ -88,20 +88,20 @@ public: * the private StopApplication method, to be notified when that * time has come. */ - void Stop(const Time& stopTime); + void Stop (const Time& stopTime); /** * \brief Specify application stop time * \param stopVariable the random variable to use to pick * the real stop time, in units of seconds, - * relative to the start of the simulation. + * relative to the current simulation time. */ - void Stop(const RandomVariable& stopVariable); + void Stop (const RandomVariable& stopVariable); /** * \returns the Node to which this Application object is attached. */ - Ptr GetNode() const; + Ptr GetNode () const; /** * \param node the node to which this Application object is attached. diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index 27ac0a26c..91a23862c 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -68,7 +68,7 @@ public: bool IsFinished (void) const; Time Next (void) const; void Stop (void); - void StopAt (Time const &time); + void Stop (Time const &time); EventId Schedule (Time const &time, const Ptr &event); EventId ScheduleNow (const Ptr &event); EventId ScheduleDestroy (const Ptr &event); @@ -249,10 +249,11 @@ SimulatorPrivate::Stop (void) m_stop = true; } void -SimulatorPrivate::StopAt (Time const &at) +SimulatorPrivate::Stop (Time const &time) { - NS_ASSERT (at.IsPositive ()); - m_stopAt = at.GetTimeStep (); + NS_ASSERT (time.IsPositive ()); + Time absolute = Simulator::Now () + time; + m_stopAt = absolute.GetTimeStep (); } EventId SimulatorPrivate::Schedule (Time const &time, const Ptr &event) @@ -485,9 +486,9 @@ Simulator::Stop (void) GetPriv ()->Stop (); } void -Simulator::StopAt (Time const &at) +Simulator::Stop (Time const &time) { - GetPriv ()->StopAt (at); + GetPriv ()->Stop (time); } Time Simulator::Now (void) @@ -1125,7 +1126,7 @@ SimulatorTests::RunTests (void) Simulator::Destroy (); Simulator::Schedule (Seconds (10.0), &SimulatorTests::baz1, this, 0); - Simulator::StopAt (Seconds (1.0)); + Simulator::Stop (Seconds (1.0)); Simulator::Run (); Simulator::Destroy (); diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h index 472fb2c38..b1c4a9ecf 100644 --- a/src/simulator/simulator.h +++ b/src/simulator/simulator.h @@ -126,12 +126,13 @@ public: */ static void Stop (void); /** - * Force the Simulator::run method to return to the caller - * when the expiration time of the next event to be processed - * is greater than or equal to the stop time. - * @param time the stop time. + * Force the Simulator::run method to return to the caller when the + * expiration time of the next event to be processed is greater than + * or equal to the stop time. The stop time is relative to the + * current simulation time. + * @param time the stop time, relative to the current time. */ - static void StopAt (Time const &time); + static void Stop (Time const &time); /** * Schedule an event to expire when the time "now + time"