57 static TypeId tid =
TypeId (
"ns3::RealtimeSimulatorImpl")
59 .AddConstructor<RealtimeSimulatorImpl> ()
60 .AddAttribute (
"SynchronizationMode",
61 "What to do if the simulation cannot keep up with real time.",
66 .AddAttribute (
"HardLimit",
67 "Maximum acceptable real-time jitter (used in conjunction with SynchronizationMode=HardLimit)",
137 if (ev->IsCancelled () ==
false)
156 while (
m_events->IsEmpty () ==
false)
159 scheduler->Insert (next);
191 uint64_t tsDelay = 0;
221 "RealtimeSimulatorImpl::ProcessOneEvent (): Synchronizer reports not Realtime ()");
248 tsDelay = tsNext - tsNow;
329 "RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty");
339 "RealtimeSimulatorImpl::ProcessOneEvent(): "
340 "next.GetTs() earlier than m_currentTs (list order error)");
378 "Hard real-time limit exceeded (jitter = " << tsJitter <<
")");
414 "RealtimeSimulatorImpl::NextTs(): event queue is empty");
425 "RealtimeSimulatorImpl::Run(): Simulator already running");
436 uint64_t tsDelay = 1000000000;
440 bool process =
false;
475 "RealtimeSimulatorImpl::Run(): Empty queue and unprocessed events");
647 "RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext(): schedule for time < m_currentTs");
713 if (
id.GetUid () == 2)
737 event.
impl =
id.PeekEventImpl ();
738 event.key.m_ts =
id.GetTs ();
739 event.key.m_context =
id.GetContext ();
740 event.key.m_uid =
id.GetUid ();
744 event.impl->Cancel ();
745 event.impl->Unref ();
754 id.PeekEventImpl ()->Cancel ();
761 if (
id.GetUid () == 2)
763 if (
id.PeekEventImpl () == 0 ||
764 id.PeekEventImpl ()->IsCancelled ())
788 if (
id.PeekEventImpl () == 0 ||
791 id.PeekEventImpl ()->IsCancelled ())
806 return TimeStep (0x7fffffffffffffffLL);
NS_FATAL_x macro definitions.
Boolean attribute value declarations.
void ProcessOneEvent(void)
void ScheduleRealtimeNowWithContext(uint32_t context, EventImpl *event)
void SetSynchronizationMode(RealtimeSimulatorImpl::SynchronizationMode mode)
Simulation virtual time values and global simulation resolution.
Ptr< Synchronizer > m_synchronizer
Smart pointer class similar to boost::intrusive_ptr.
bool IsPositive(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
ns3::EventImpl declarations.
uint64_t NextTs(void) const
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
Make a best effort to keep synced to real-time.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual EventId Schedule(Time const &time, EventImpl *event)
Schedule a future event execution (in the same context).
SystemThread::ThreadId m_main
uint64_t m_ts
Event time stamp.
Smart pointer implementation.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
SynchronizationMode
Enumeration of the types of packets supported in the class.
void ScheduleRealtimeNow(EventImpl *event)
static ThreadId Self(void)
Returns the current thread Id.
EventImpl * impl
Pointer to the event implementation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time RealtimeNow(void) const
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
Time m_hardLimit
The maximum allowable drift from real-time in SYNC_HARD_LIMIT mode.
virtual void DoDispose(void)
Destructor implementation.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
ns3::Simulator declaration.
Time GetHardLimit(void) const
SynchronizationMode m_synchronizationMode
The policy to use if the simulation cannot keep synchronized to real-time.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
void ScheduleRealtimeWithContext(uint32_t context, Time const &time, EventImpl *event)
DestroyEvents m_destroyEvents
virtual void DoDispose(void)
Destructor implementation.
virtual EventId ScheduleDestroy(EventImpl *event)
Schedule an event to run at the end of the simulation, after the Stop() time or condition has been re...
virtual void ScheduleWithContext(uint32_t context, Time const &time, EventImpl *event)
Schedule a future event execution (in a different context).
Ptr< Scheduler > m_events
RealtimeSimulatorImpl::SynchronizationMode GetSynchronizationMode(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
System-independent mutex primitive, ns3::SystemMutex, and ns3::CriticalSection.
static TypeId GetTypeId(void)
ns3::Scheduler abstract base class, ns3::Scheduler::Event and ns3::Scheduler::EventKey declarations...
Hold variables of type enum.
EventKey key
Key for sorting and ordering Events.
AttributeValue implementation for Time.
virtual Time Now(void) const
Return the current simulation virtual time.
virtual void Run(void)
Run the simulation.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
A class which provides a simple way to implement a Critical Section.
uint32_t m_uid
Event unique id.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
void Unref(void) const
Decrement the reference count.
Enum attribute value declarations.
ns3::WallClockSynchronizer declaration.
virtual void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
virtual bool IsExpired(const EventId &id) const
Check if an event has already run or been cancelled.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void Remove(const EventId &id)
Remove an event from the event list.
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
void SetHardLimit(Time limit)
int64_t GetTimeStep(void) const
Time TimeStep(uint64_t ts)
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
ns3::Synchronizer declaration.
static bool Equals(ThreadId id)
Compares an ThreadId with the current ThreadId .
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void SetScheduler(ObjectFactory schedulerFactory)
Set the Scheduler to be used to manage the event list.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
Instantiate subclasses of ns3::Object.
An identifier for simulation events.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool Realtime(void) const
virtual uint32_t GetContext(void) const
Get the current simulation context.
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
void ScheduleRealtime(Time const &time, EventImpl *event)
virtual bool IsFinished(void) const
Check if the simulation should finish.
Pointer attribute value declarations and template implementations.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
uint32_t m_currentContext
uint32_t m_context
Event context.
The SimulatorImpl base class.