ns3::Simulator Class Reference
[Simulator]

Control the scheduling of simulation events. More...

#include <simulator.h>

List of all members.

Static Public Member Functions

static void SetImplementation (Ptr< SimulatorImpl > impl)
static Ptr< SimulatorImplGetImplementation (void)
static void SetScheduler (Ptr< Scheduler > scheduler)
static void EnableLogTo (char const *filename) NS_DEPRECATED
static void Destroy (void)
static bool IsFinished (void)
static Time Next (void)
static void Run (void)
static void RunOneEvent (void)
static void Stop (void)
static void Stop (Time const &time)
template<typename MEM , typename OBJ >
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj)
template<typename MEM , typename OBJ , typename T1 >
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1)
template<typename MEM , typename OBJ , typename T1 , typename T2 >
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 >
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 >
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
static EventId Schedule (Time const &time, void(*f)(void))
template<typename U1 , typename T1 >
static EventId Schedule (Time const &time, void(*f)(U1), T1 a1)
template<typename U1 , typename U2 , typename T1 , typename T2 >
static EventId Schedule (Time const &time, void(*f)(U1, U2), T1 a1, T2 a2)
template<typename U1 , typename U2 , typename U3 , typename T1 , typename T2 , typename T3 >
static EventId Schedule (Time const &time, void(*f)(U1, U2, U3), T1 a1, T2 a2, T3 a3)
template<typename U1 , typename U2 , typename U3 , typename U4 , typename T1 , typename T2 , typename T3 , typename T4 >
static EventId Schedule (Time const &time, void(*f)(U1, U2, U3, U4), T1 a1, T2 a2, T3 a3, T4 a4)
template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
static EventId Schedule (Time const &time, void(*f)(U1, U2, U3, U4, U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
template<typename MEM , typename OBJ >
static EventId ScheduleNow (MEM mem_ptr, OBJ obj)
template<typename MEM , typename OBJ , typename T1 >
static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1)
template<typename MEM , typename OBJ , typename T1 , typename T2 >
static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 >
static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 >
static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
static EventId ScheduleNow (void(*f)(void))
template<typename U1 , typename T1 >
static EventId ScheduleNow (void(*f)(U1), T1 a1)
template<typename U1 , typename U2 , typename T1 , typename T2 >
static EventId ScheduleNow (void(*f)(U1, U2), T1 a1, T2 a2)
template<typename U1 , typename U2 , typename U3 , typename T1 , typename T2 , typename T3 >
static EventId ScheduleNow (void(*f)(U1, U2, U3), T1 a1, T2 a2, T3 a3)
template<typename U1 , typename U2 , typename U3 , typename U4 , typename T1 , typename T2 , typename T3 , typename T4 >
static EventId ScheduleNow (void(*f)(U1, U2, U3, U4), T1 a1, T2 a2, T3 a3, T4 a4)
template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
static EventId ScheduleNow (void(*f)(U1, U2, U3, U4, U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
template<typename MEM , typename OBJ >
static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj)
template<typename MEM , typename OBJ , typename T1 >
static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1)
template<typename MEM , typename OBJ , typename T1 , typename T2 >
static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 >
static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 >
static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
static EventId ScheduleDestroy (void(*f)(void))
template<typename U1 , typename T1 >
static EventId ScheduleDestroy (void(*f)(U1), T1 a1)
template<typename U1 , typename U2 , typename T1 , typename T2 >
static EventId ScheduleDestroy (void(*f)(U1, U2), T1 a1, T2 a2)
template<typename U1 , typename U2 , typename U3 , typename T1 , typename T2 , typename T3 >
static EventId ScheduleDestroy (void(*f)(U1, U2, U3), T1 a1, T2 a2, T3 a3)
template<typename U1 , typename U2 , typename U3 , typename U4 , typename T1 , typename T2 , typename T3 , typename T4 >
static EventId ScheduleDestroy (void(*f)(U1, U2, U3, U4), T1 a1, T2 a2, T3 a3, T4 a4)
template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
static EventId ScheduleDestroy (void(*f)(U1, U2, U3, U4, U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
static void Remove (const EventId &id)
static void Cancel (const EventId &id)
static bool IsExpired (const EventId &id)
static Time Now (void)
static Time GetDelayLeft (const EventId &id)
static Time GetMaximumSimulationTime (void)
static EventId Schedule (Time const &time, const Ptr< EventImpl > &event)
static EventId ScheduleDestroy (const Ptr< EventImpl > &event)
static EventId ScheduleNow (const Ptr< EventImpl > &event)

Private Member Functions

 Simulator ()
 ~Simulator ()

Static Private Member Functions

static EventId DoSchedule (Time const &time, EventImpl *event)
static EventId DoScheduleNow (EventImpl *event)
static EventId DoScheduleDestroy (EventImpl *event)

Detailed Description

Control the scheduling of simulation events.

The internal simulation clock is maintained as a 64-bit integer in a unit specified by the user through the TimeStepPrecision::Set function. This means that it is not possible to specify event expiration times with anything better than this user-specified accuracy. Events whose expiration time is the same modulo this accuracy are scheduled in FIFO order: the first event inserted in the scheduling queue is scheduled to expire first.

A simple example of how to use the Simulator class to schedule events is shown below:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include "ns3/simulator.h"
#include "ns3/nstime.h"
#include <iostream>

using namespace ns3;

class MyModel {
public:
  void Start (void);
private:
  void DealWithEvent (double eventValue);
};

void 
MyModel::Start (void)
{
  Simulator::Schedule (Seconds (10.0), 
                       &MyModel::DealWithEvent, 
                       this, Simulator::Now ().GetSeconds ());
}
void
MyModel::DealWithEvent (double value)
{
  std::cout << "Member method received event at " << Simulator::Now ().GetSeconds () 
            << "s started at " << value << "s" << std::endl;
}

static void 
random_function (MyModel *model)
{
  std::cout << "random function received event at " << 
      Simulator::Now ().GetSeconds () << "s" << std::endl;
  model->Start ();
}


int main (int argc, char *argv[])
{
  MyModel model;

  Simulator::Schedule (Seconds (10.0), &random_function, &model);

  Simulator::Run ();

  Simulator::Destroy ();
}

Definition at line 57 of file simulator.h.


Constructor & Destructor Documentation

ns3::Simulator::Simulator (  )  [private]
ns3::Simulator::~Simulator (  )  [private]

Member Function Documentation

void ns3::Simulator::Cancel ( const EventId id  )  [static]

Set the cancel bit on this event: the event's associated function will not be invoked when it expires. This method has the same visible effect as the ns3::Simulator::remove method but its algorithmic complexity is much lower: it has O(1) complexity. This method has the exact same semantics as ns3::EventId::cancel. Note that it is not possible to cancel events which were scheduled for the "destroy" time. Doing so will result in a program error (crash).

Parameters:
id the event to cancel

Definition at line 268 of file simulator.cc.

References ns3::SimulatorImpl::Cancel(), ns3::GetImpl(), and NS_LOG_FUNCTION.

Referenced by ns3::OnOffApplication::CancelEvents(), ns3::Application::DoDispose(), ns3::DataCalculator::DoDispose(), ns3::SimulatorTests::RunOneTest(), ns3::EmuNetDevice::Start(), ns3::EmuNetDevice::Stop(), ns3::UdpEchoClient::StopApplication(), and ns3::EventGarbageCollector::~EventGarbageCollector().

void ns3::Simulator::Destroy ( void   )  [static]

Every event scheduled by the Simulator::insertAtDestroy method is invoked. Then, we ensure that any memory allocated by the Simulator is freed. This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak checker. After this method has been invoked, it is actually possible to restart a new simulation with a set of calls to Simulator::run and Simulator::insert_*.

Definition at line 114 of file simulator.cc.

References ns3::LogSetTimePrinter(), NS_LOG_FUNCTION_NOARGS, and ns3::PeekImpl().

Referenced by ns3::DcfManagerTest::EndTest(), ns3::WifiTest::RunOne(), ns3::WatchdogTests::RunTests(), ns3::TimerTests::RunTests(), ns3::SimulatorTests::RunTests(), ns3::GlobalRouteManagerImplTest::RunTests(), ns3::UdpSocketImplTest::RunTests(), ns3::PointToPointTest::RunTests(), ns3::SimulatorTests::RunTestsConst(), ns3::TcpSocketImplTest::Test1(), ns3::TcpSocketImplTest::Test2(), and ns3::TcpSocketImplTest::Test3().

EventId ns3::Simulator::DoSchedule ( Time const &  time,
EventImpl event 
) [static, private]

Definition at line 223 of file simulator.cc.

References ns3::GetImpl(), and ns3::SimulatorImpl::Schedule().

Referenced by Schedule().

EventId ns3::Simulator::DoScheduleDestroy ( EventImpl event  )  [static, private]

Definition at line 233 of file simulator.cc.

References ns3::GetImpl(), and ns3::SimulatorImpl::ScheduleDestroy().

Referenced by ScheduleDestroy().

EventId ns3::Simulator::DoScheduleNow ( EventImpl event  )  [static, private]

Definition at line 228 of file simulator.cc.

References ns3::GetImpl(), and ns3::SimulatorImpl::ScheduleNow().

Referenced by ScheduleNow().

void ns3::Simulator::EnableLogTo ( char const *  filename  )  [static]

Definition at line 141 of file simulator.cc.

Time ns3::Simulator::GetDelayLeft ( const EventId id  )  [static]
Parameters:
id the event id to analyse
Returns:
the delay left until the input event id expires. if the event is not running, this method returns zero.

Definition at line 196 of file simulator.cc.

References ns3::SimulatorImpl::GetDelayLeft(), ns3::GetImpl(), and NS_LOG_FUNCTION.

Referenced by ns3::TcpSocketImpl::CommonNewAck(), ns3::TcpSocketImpl::Destroy(), ns3::DcfManager::DoRestartAccessTimeoutIfNeeded(), and ns3::NqstaWifiMac::RestartBeaconWatchdog().

Ptr< SimulatorImpl > ns3::Simulator::GetImplementation ( void   )  [static]

Definition at line 300 of file simulator.cc.

References ns3::GetImpl().

Referenced by ns3::EmuNetDevice::ReadThread().

Time ns3::Simulator::GetMaximumSimulationTime ( void   )  [static]
Returns:
the maximum simulation time at which an event can be scheduled.

The returned value will always be bigger than or equal to Simulator::Now.

Definition at line 288 of file simulator.cc.

References ns3::GetImpl(), ns3::SimulatorImpl::GetMaximumSimulationTime(), and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::DcfManager::DoRestartAccessTimeoutIfNeeded().

bool ns3::Simulator::IsExpired ( const EventId id  )  [static]

This method has O(1) complexity. Note that it is not possible to test for the expiration of events which were scheduled for the "destroy" time. Doing so will result in a program error (crash). An event is said to "expire" when it starts being scheduled which means that if the code executed by the event calls this function, it will get true.

Parameters:
id the event to test for expiration
Returns:
true if the event has expired, false otherwise.

Definition at line 275 of file simulator.cc.

References ns3::GetImpl(), ns3::SimulatorImpl::IsExpired(), and NS_LOG_FUNCTION.

bool ns3::Simulator::IsFinished ( void   )  [static]

If there any any events lefts to be scheduled, return true. Return false otherwise.

Definition at line 145 of file simulator.cc.

References ns3::GetImpl(), ns3::SimulatorImpl::IsFinished(), and NS_LOG_FUNCTION_NOARGS.

Time ns3::Simulator::Next ( void   )  [static]

If Simulator::isFinished returns true, the behavior of this method is undefined. Otherwise, it returns the microsecond-based time of the next event expected to be scheduled.

Definition at line 152 of file simulator.cc.

References ns3::GetImpl(), ns3::SimulatorImpl::Next(), and NS_LOG_FUNCTION_NOARGS.

Time ns3::Simulator::Now ( void   )  [static]

Return the "current simulation time".

Definition at line 187 of file simulator.cc.

References ns3::GetImpl(), and ns3::SimulatorImpl::Now().

Referenced by ns3::InterferenceHelper::AppendEvent(), ns3::OnOffApplication::CancelEvents(), ns3::TcpSocketImpl::CommonNewAck(), ns3::YansWifiChannelHelper::Default(), ns3::Ns2ExtWifiChannelHelper::Default(), ns3::TcpSocketImpl::Destroy(), ns3::DcfManager::DoRestartAccessTimeoutIfNeeded(), ns3::TcpSocketImpl::DupAck(), ns3::olsr::AgentImpl::DupTupleTimerExpire(), ns3::WatchdogTests::Expire(), ns3::Watchdog::Expire(), ns3::ArpCache::Flush(), ns3::olsr::AgentImpl::ForwardDefault(), ns3::YansWifiPhyStateHelper::GetState(), ns3::Ns2ExtWifiPhyStateHelper::GetState(), ns3::ArpCache::HandleWaitReplyTimeout(), ns3::olsr::AgentImpl::IfaceAssocTupleTimerExpire(), ns3::DcfManager::IsBusy(), ns3::MacLow::IsNavZero(), ns3::olsr::AgentImpl::LinkTupleAdded(), ns3::olsr::AgentImpl::LinkTupleUpdated(), ns3::NqstaWifiMac::MissedBeacons(), ns3::olsr::AgentImpl::MprSelTupleTimerExpire(), ns3::olsr::AgentImpl::Nb2hopTupleTimerExpire(), ns3::olsr::AgentImpl::NeighborLoss(), ns3::DcfManagerTest::NotifyAccessGranted(), ns3::DcfManagerTest::NotifyCollision(), ns3::DcfManagerTest::NotifyInternalCollision(), ns3::MacLow::NotifyNav(), ns3::DcfManager::NotifyNavStartNow(), ns3::TcpSocketImpl::PersistTimeout(), ns3::olsr::AgentImpl::ProcessHello(), ns3::olsr::AgentImpl::ProcessTc(), ns3::olsr::AgentImpl::RecvOlsr(), ns3::olsr::AgentImpl::RemoveLinkTuple(), ns3::NqstaWifiMac::RestartBeaconWatchdog(), ns3::TcpSocketImpl::Retransmit(), ns3::TcpSocketImpl::ReTxTimeout(), ns3::olsr::AgentImpl::RoutingTableComputation(), ns3::EventGarbageCollectorTests::RunTests(), ns3::TcpSocketImpl::SendEmptyPacket(), ns3::OnOffApplication::SendPacket(), ns3::TcpSocketImpl::SendPendingData(), ns3::RttEstimator::SentSeq(), ns3::YansWifiPhy::StartReceivePacket(), ns3::Ns2ExtWifiPhy::StartReceivePacket(), ns3::ArpCache::StartWaitReplyTimer(), ns3::TimePrinter(), ns3::olsr::AgentImpl::TopologyTupleTimerExpire(), ns3::DcfManager::UpdateBackoff(), ns3::OnoeWifiRemoteStation::UpdateMode(), and ns3::AmrrWifiRemoteStation::UpdateMode().

void ns3::Simulator::Remove ( const EventId id  )  [static]

Remove an event from the event list. This method has the same visible effect as the ns3::EventId::Cancel method but its algorithmic complexity is much higher: it has often O(log(n)) complexity, sometimes O(n), sometimes worse. Note that it is not possible to remove events which were scheduled for the "destroy" time. Doing so will result in a program error (crash).

Parameters:
id the event to remove from the list of scheduled events.

Definition at line 261 of file simulator.cc.

References ns3::GetImpl(), NS_LOG_FUNCTION, and ns3::SimulatorImpl::Remove().

Referenced by ns3::SimulatorTests::B(), ns3::ArpCache::DoDispose(), ns3::RandomWalk2dMobilityModel::DoSetPosition(), ns3::RandomDirection2dMobilityModel::DoSetPosition(), and ns3::SimulatorTests::RunTests().

void ns3::Simulator::Run ( void   )  [static]
void ns3::Simulator::RunOneEvent ( void   )  [static]

Process only the next simulation event, then return immediately.

Definition at line 166 of file simulator.cc.

References ns3::GetImpl(), NS_LOG_FUNCTION_NOARGS, and ns3::SimulatorImpl::RunOneEvent().

EventId ns3::Simulator::Schedule ( Time const &  time,
const Ptr< EventImpl > &  event 
) [static]
Parameters:
time delay until the event expires
event the event to schedule
Returns:
a unique identifier for the newly-scheduled event.

This method will be typically used by language bindings to delegate events to their own subclass of the EventImpl base class.

Definition at line 203 of file simulator.cc.

References DoSchedule(), ns3::GetPointer(), and NS_LOG_FUNCTION.

template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
EventId ns3::Simulator::Schedule ( Time const &  time,
void(*)(U1, U2, U3, U4, U5)  f,
T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline, static]
Parameters:
time the relative expiration time of the event.
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
a4 the fourth argument to pass to the function to invoke
a5 the fifth argument to pass to the function to invoke
Returns:
an id for the scheduled event.

Definition at line 716 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename U3 , typename U4 , typename T1 , typename T2 , typename T3 , typename T4 >
EventId ns3::Simulator::Schedule ( Time const &  time,
void(*)(U1, U2, U3, U4)  f,
T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline, static]
Parameters:
time the relative expiration time of the event.
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
a4 the fourth argument to pass to the function to invoke
Returns:
an id for the scheduled event.

Definition at line 709 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename U3 , typename T1 , typename T2 , typename T3 >
EventId ns3::Simulator::Schedule ( Time const &  time,
void(*)(U1, U2, U3)  f,
T1  a1,
T2  a2,
T3  a3 
) [inline, static]
Parameters:
time the relative expiration time of the event.
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
Returns:
an id for the scheduled event.

Definition at line 702 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename T1 , typename T2 >
EventId ns3::Simulator::Schedule ( Time const &  time,
void(*)(U1, U2)  f,
T1  a1,
T2  a2 
) [inline, static]
Parameters:
time the relative expiration time of the event.
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
Returns:
an id for the scheduled event.

Definition at line 695 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename U1 , typename T1 >
EventId ns3::Simulator::Schedule ( Time const &  time,
void(*)(U1)  f,
T1  a1 
) [inline, static]
Parameters:
time the relative expiration time of the event.
f the function to invoke
a1 the first argument to pass to the function to invoke
Returns:
an id for the scheduled event.

Definition at line 688 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

EventId ns3::Simulator::Schedule ( Time const &  time,
void(*)(void)  f 
) [static]
Parameters:
time the relative expiration time of the event.
f the function to invoke
Returns:
an id for the scheduled event.

Definition at line 240 of file simulator.cc.

References DoSchedule(), ns3::MakeEvent(), and NS_LOG_FUNCTION.

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
EventId ns3::Simulator::Schedule ( Time const &  time,
MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline, static]
Parameters:
time the relative expiration time of the event.
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
a4 the fourth argument to pass to the invoked method
a5 the fifth argument to pass to the invoked method
Returns:
an id for the scheduled event.

Definition at line 681 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 >
EventId ns3::Simulator::Schedule ( Time const &  time,
MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline, static]
Parameters:
time the relative expiration time of the event.
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
a4 the fourth argument to pass to the invoked method
Returns:
an id for the scheduled event.

Definition at line 674 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 >
EventId ns3::Simulator::Schedule ( Time const &  time,
MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3 
) [inline, static]
Parameters:
time the relative expiration time of the event.
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
Returns:
an id for the scheduled event.

Definition at line 667 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 >
EventId ns3::Simulator::Schedule ( Time const &  time,
MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2 
) [inline, static]
Parameters:
time the relative expiration time of the event.
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
Returns:
an id for the scheduled event.

Definition at line 660 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 >
EventId ns3::Simulator::Schedule ( Time const &  time,
MEM  mem_ptr,
OBJ  obj,
T1  a1 
) [inline, static]
Parameters:
time the relative expiration time of the event.
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
Returns:
an id for the scheduled event.

Definition at line 653 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

template<typename MEM , typename OBJ >
EventId ns3::Simulator::Schedule ( Time const &  time,
MEM  mem_ptr,
OBJ  obj 
) [inline, static]

Schedule an event to expire at the relative time "time" is reached. This can be thought of as scheduling an event for the current simulation time plus the Time passed as a parameter

When the event expires (when it becomes due to be run), the input method will be invoked on the input object.

Parameters:
time the relative expiration time of the event.
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
Returns:
an id for the scheduled event.

Definition at line 645 of file simulator.h.

References DoSchedule(), and ns3::MakeEvent().

Referenced by ns3::DcfManagerTest::AddAccessRequest(), ns3::DcfManagerTest::AddNavReset(), ns3::DcfManagerTest::AddNavStart(), ns3::DcfManagerTest::AddRxErrorEvt(), ns3::DcfManagerTest::AddRxOkEvt(), ns3::SimulatorTests::B(), ns3::RandomDirection2dMobilityModel::BeginPause(), ns3::RandomWaypointMobilityModel::BeginWalk(), ns3::TcpSocketImpl::CommonNewAck(), ns3::WifiTest::CreateOne(), ns3::DcfManager::DoRestartAccessTimeoutIfNeeded(), ns3::RandomWalk2dMobilityModel::DoWalk(), ns3::olsr::AgentImpl::DupTupleTimerExpire(), ns3::Watchdog::Expire(), ns3::olsr::AgentImpl::ForwardDefault(), ns3::MacLow::ForwardDown(), ns3::ArpCache::HandleWaitReplyTimeout(), ns3::olsr::AgentImpl::IfaceAssocTupleTimerExpire(), ns3::Ns2MobilityHelper::LayoutObjectStore(), ns3::olsr::AgentImpl::LinkSensing(), ns3::olsr::AgentImpl::LinkTupleTimerExpire(), ns3::MakeTimerImpl(), ns3::NqstaWifiMac::MissedBeacons(), ns3::olsr::AgentImpl::MprSelTupleTimerExpire(), ns3::olsr::AgentImpl::Nb2hopTupleTimerExpire(), ns3::TcpSocketImpl::NewRx(), ns3::MacLow::NotifyNav(), ns3::TcpSocketImpl::PersistTimeout(), ns3::Watchdog::Ping(), ns3::olsr::AgentImpl::PopulateMprSelectorSet(), ns3::olsr::AgentImpl::PopulateTwoHopNeighborSet(), ns3::olsr::AgentImpl::ProcessMid(), ns3::TcpSocketImpl::ProcessPacketAction(), ns3::olsr::AgentImpl::ProcessTc(), ns3::MacLow::ReceiveError(), ns3::MacLow::ReceiveOk(), ns3::NqstaWifiMac::RestartBeaconWatchdog(), ns3::TcpSocketImpl::Retransmit(), ns3::SimulatorTests::RunOneTest(), ns3::WatchdogTests::RunTests(), ns3::SimulatorTests::RunTests(), ns3::PointToPointTest::RunTests(), ns3::EventGarbageCollectorTests::RunTests(), ns3::SimulatorTests::RunTestsConst(), ns3::OnOffApplication::ScheduleNextTx(), ns3::Application::ScheduleStart(), ns3::OnOffApplication::ScheduleStartEvent(), ns3::Application::ScheduleStop(), ns3::OnOffApplication::ScheduleStopEvent(), ns3::UdpEchoClient::ScheduleTransmit(), ns3::YansWifiChannel::Send(), ns3::Ns2ExtWifiChannel::Send(), ns3::NqstaWifiMac::SendAssociationRequest(), ns3::TcpSocketImpl::SendEmptyPacket(), ns3::NqapWifiMac::SendOneBeacon(), ns3::TcpSocketImpl::SendPendingData(), ns3::NqstaWifiMac::SendProbeRequest(), ns3::MacLow::SendRtsForPacket(), ns3::RandomDirection2dMobilityModel::SetDirectionAndSpeed(), ns3::RandomWaypointMobilityModel::Start(), ns3::EmuNetDevice::Start(), ns3::DataCalculator::Start(), ns3::MacLow::StartDataTxTimers(), ns3::YansWifiPhy::StartReceivePacket(), ns3::Ns2ExtWifiPhy::StartReceivePacket(), ns3::ArpCache::StartWaitReplyTimer(), Stop(), ns3::EmuNetDevice::Stop(), ns3::DataCalculator::Stop(), ns3::olsr::AgentImpl::TopologyTupleTimerExpire(), ns3::CsmaNetDevice::TransmitCompleteEvent(), ns3::CsmaChannel::TransmitEnd(), ns3::PointToPointNetDevice::TransmitStart(), ns3::PointToPointChannel::TransmitStart(), and ns3::CsmaNetDevice::TransmitStart().

EventId ns3::Simulator::ScheduleDestroy ( const Ptr< EventImpl > &  event  )  [static]
Parameters:
event the event to schedule
Returns:
a unique identifier for the newly-scheduled event.

This method will be typically used by language bindings to delegate events to their own subclass of the EventImpl base class.

Definition at line 217 of file simulator.cc.

References DoScheduleDestroy(), ns3::GetPointer(), and NS_LOG_FUNCTION.

template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
EventId ns3::Simulator::ScheduleDestroy ( void(*)(U1, U2, U3, U4, U5)  f,
T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
a4 the fourth argument to pass to the function to invoke
a5 the fifth argument to pass to the function to invoke

Definition at line 899 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename U3 , typename U4 , typename T1 , typename T2 , typename T3 , typename T4 >
EventId ns3::Simulator::ScheduleDestroy ( void(*)(U1, U2, U3, U4)  f,
T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
a4 the fourth argument to pass to the function to invoke

Definition at line 891 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename U3 , typename T1 , typename T2 , typename T3 >
EventId ns3::Simulator::ScheduleDestroy ( void(*)(U1, U2, U3)  f,
T1  a1,
T2  a2,
T3  a3 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke

Definition at line 883 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename T1 , typename T2 >
EventId ns3::Simulator::ScheduleDestroy ( void(*)(U1, U2)  f,
T1  a1,
T2  a2 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke

Definition at line 875 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename U1 , typename T1 >
EventId ns3::Simulator::ScheduleDestroy ( void(*)(U1)  f,
T1  a1 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke

Definition at line 867 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

EventId ns3::Simulator::ScheduleDestroy ( void(*)(void)  f  )  [static]
Parameters:
f the function to invoke

Definition at line 254 of file simulator.cc.

References DoScheduleDestroy(), ns3::MakeEvent(), and NS_LOG_FUNCTION.

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
EventId ns3::Simulator::ScheduleDestroy ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
a4 the fourth argument to pass to the invoked method
a5 the fifth argument to pass to the invoked method

Definition at line 858 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 >
EventId ns3::Simulator::ScheduleDestroy ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
a4 the fourth argument to pass to the invoked method

Definition at line 850 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 >
EventId ns3::Simulator::ScheduleDestroy ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method

Definition at line 842 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 >
EventId ns3::Simulator::ScheduleDestroy ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method

Definition at line 834 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 >
EventId ns3::Simulator::ScheduleDestroy ( MEM  mem_ptr,
OBJ  obj,
T1  a1 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method

Definition at line 826 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

template<typename MEM , typename OBJ >
EventId ns3::Simulator::ScheduleDestroy ( MEM  mem_ptr,
OBJ  obj 
) [inline, static]

Schedule an event to expire at Destroy time. All events scheduled to expire at "Destroy" time are scheduled FIFO, after all normal events have expired and only when Simulator::Destroy is invoked.

Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method

Definition at line 817 of file simulator.h.

References DoScheduleDestroy(), and ns3::MakeEvent().

Referenced by ns3::NodeListPriv::DoGet(), ns3::SimulationSingleton< T >::GetObject(), ns3::SimulatorTests::RunTests(), and ns3::SimulatorTests::RunTestsConst().

EventId ns3::Simulator::ScheduleNow ( const Ptr< EventImpl > &  event  )  [static]
Parameters:
event the event to schedule
Returns:
a unique identifier for the newly-scheduled event.

This method will be typically used by language bindings to delegate events to their own subclass of the EventImpl base class.

Definition at line 210 of file simulator.cc.

References DoScheduleNow(), ns3::GetPointer(), and NS_LOG_FUNCTION.

template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
EventId ns3::Simulator::ScheduleNow ( void(*)(U1, U2, U3, U4, U5)  f,
T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
a4 the fourth argument to pass to the function to invoke
a5 the fifth argument to pass to the function to invoke

Definition at line 808 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename U3 , typename U4 , typename T1 , typename T2 , typename T3 , typename T4 >
EventId ns3::Simulator::ScheduleNow ( void(*)(U1, U2, U3, U4)  f,
T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke
a4 the fourth argument to pass to the function to invoke

Definition at line 800 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename U3 , typename T1 , typename T2 , typename T3 >
EventId ns3::Simulator::ScheduleNow ( void(*)(U1, U2, U3)  f,
T1  a1,
T2  a2,
T3  a3 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke
a3 the third argument to pass to the function to invoke

Definition at line 792 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename U1 , typename U2 , typename T1 , typename T2 >
EventId ns3::Simulator::ScheduleNow ( void(*)(U1, U2)  f,
T1  a1,
T2  a2 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke
a2 the second argument to pass to the function to invoke

Definition at line 784 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename U1 , typename T1 >
EventId ns3::Simulator::ScheduleNow ( void(*)(U1)  f,
T1  a1 
) [inline, static]
Parameters:
f the function to invoke
a1 the first argument to pass to the function to invoke

Definition at line 776 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

EventId ns3::Simulator::ScheduleNow ( void(*)(void)  f  )  [static]
Parameters:
f the function to invoke

Definition at line 247 of file simulator.cc.

References DoScheduleNow(), ns3::MakeEvent(), and NS_LOG_FUNCTION.

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
EventId ns3::Simulator::ScheduleNow ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
a4 the fourth argument to pass to the invoked method
a5 the fifth argument to pass to the invoked method

Definition at line 767 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 , typename T4 >
EventId ns3::Simulator::ScheduleNow ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3,
T4  a4 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method
a4 the fourth argument to pass to the invoked method

Definition at line 759 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 , typename T3 >
EventId ns3::Simulator::ScheduleNow ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2,
T3  a3 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method
a3 the third argument to pass to the invoked method

Definition at line 751 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 , typename T2 >
EventId ns3::Simulator::ScheduleNow ( MEM  mem_ptr,
OBJ  obj,
T1  a1,
T2  a2 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method
a2 the second argument to pass to the invoked method

Definition at line 743 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename MEM , typename OBJ , typename T1 >
EventId ns3::Simulator::ScheduleNow ( MEM  mem_ptr,
OBJ  obj,
T1  a1 
) [inline, static]
Parameters:
mem_ptr member method pointer to invoke
obj the object on which to invoke the member method
a1 the first argument to pass to the invoked method

Definition at line 735 of file simulator.h.

References DoScheduleNow(), and ns3::MakeEvent().

template<typename MEM , typename OBJ >
EventId ns3::Simulator::ScheduleNow ( MEM  mem_ptr,
OBJ  obj 
) [inline, static]
void ns3::Simulator::SetImplementation ( Ptr< SimulatorImpl impl  )  [static]
Parameters:
impl a new simulator implementation

The simulator provides a mechanism to swap out different implementations. For example, the default implementation is a single-threaded simulator that performs no realtime synchronization. By calling this method, you can substitute in a new simulator implementation that might be multi- threaded and synchronize events to a realtime clock.

The simulator implementation can be set when the simulator is not running.

Definition at line 295 of file simulator.cc.

References NS_FATAL_ERROR.

void ns3::Simulator::SetScheduler ( Ptr< Scheduler scheduler  )  [static]
Parameters:
scheduler a new event scheduler

The event scheduler can be set at any time: the events scheduled in the previous scheduler will be transfered to the new scheduler before we start to use it.

Definition at line 134 of file simulator.cc.

References ns3::GetImpl(), NS_LOG_FUNCTION, and ns3::SimulatorImpl::SetScheduler().

Referenced by ns3::SimulatorTests::RunTests().

void ns3::Simulator::Stop ( Time const &  time  )  [static]

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.

Parameters:
time the stop time, relative to the current time.

Definition at line 180 of file simulator.cc.

References NS_LOG_FUNCTION, Schedule(), and Stop().

void ns3::Simulator::Stop ( void   )  [static]

If an event invokes this method, it will be the last event scheduled by the Simulator::run method before returning to the caller.

Definition at line 173 of file simulator.cc.

References ns3::GetImpl(), NS_LOG_LOGIC, and ns3::SimulatorImpl::Stop().

Referenced by ns3::WifiTest::RunOne(), ns3::SimulatorTests::RunTests(), and Stop().


The documentation for this class was generated from the following files:
Generated on Thu Dec 3 14:12:16 2009 for NS-3 by  doxygen 1.6.3