52 static TypeId tid =
TypeId (
"ns3::RealtimeSimulatorImpl")
54 .AddConstructor<RealtimeSimulatorImpl> ()
55 .AddAttribute (
"SynchronizationMode",
56 "What to do if the simulation cannot keep up with real time.",
61 .AddAttribute (
"HardLimit",
62 "Maximum acceptable real-time jitter (used in conjunction with SynchronizationMode=HardLimit)",
132 if (ev->IsCancelled () ==
false)
151 while (
m_events->IsEmpty () ==
false)
154 scheduler->Insert (next);
186 uint64_t tsDelay = 0;
216 "RealtimeSimulatorImpl::ProcessOneEvent (): Synchronizer reports not Realtime ()");
243 tsDelay = tsNext - tsNow;
324 "RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty");
334 "RealtimeSimulatorImpl::ProcessOneEvent(): "
335 "next.GetTs() earlier than m_currentTs (list order error)");
373 "Hard real-time limit exceeded (jitter = " << tsJitter <<
")");
409 "RealtimeSimulatorImpl::NextTs(): event queue is empty");
420 "RealtimeSimulatorImpl::Run(): Simulator already running");
431 uint64_t tsDelay = 1000000000;
435 bool process =
false;
470 "RealtimeSimulatorImpl::Run(): Empty queue and unprocessed events");
642 "RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext(): schedule for time < m_currentTs");
708 if (
id.GetUid () == 2)
732 event.
impl =
id.PeekEventImpl ();
733 event.key.m_ts =
id.GetTs ();
734 event.key.m_context =
id.GetContext ();
735 event.key.m_uid =
id.GetUid ();
739 event.impl->Cancel ();
740 event.impl->Unref ();
749 id.PeekEventImpl ()->Cancel ();
801 return TimeStep (0x7fffffffffffffffLL);
void ProcessOneEvent(void)
void ScheduleRealtimeNowWithContext(uint32_t context, EventImpl *event)
void SetSynchronizationMode(RealtimeSimulatorImpl::SynchronizationMode mode)
keep track of time values and allow control of global simulation resolution
Ptr< Synchronizer > m_synchronizer
smart pointer class similar to boost::intrusive_ptr
bool IsPositive(void) const
#define NS_LOG_FUNCTION(parameters)
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)
uint64_t NextTs(void) const
virtual EventId ScheduleNow(EventImpl *event)
virtual EventId Schedule(Time const &time, EventImpl *event)
Time TimeStep(uint64_t ts)
SystemThread::ThreadId m_main
void ScheduleRealtimeNow(EventImpl *event)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Time RealtimeNow(void) const
virtual Time GetMaximumSimulationTime(void) const
Time m_hardLimit
The maximum allowable drift from real-time in SYNC_HARD_LIMIT mode.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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.
EventImpl * PeekEventImpl(void) const
void ScheduleRealtimeWithContext(uint32_t context, Time const &time, EventImpl *event)
DestroyEvents m_destroyEvents
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual EventId ScheduleDestroy(EventImpl *event)
virtual void ScheduleWithContext(uint32_t context, Time const &time, EventImpl *event)
#define NS_FATAL_ERROR(msg)
fatal error handling
Ptr< Scheduler > m_events
RealtimeSimulatorImpl::SynchronizationMode GetSynchronizationMode(void) const
static TypeId GetTypeId(void)
Make a best effort to keep synced to real-time.
hold variables of type 'enum'
hold objects of type ns3::Time
virtual Time Now(void) const
Return the "current simulation time".
virtual void Run(void)
Run the simulation until one of:
Ptr< Object > Create(void) const
A class which provides a simple way to implement a Critical Section.
virtual void Destroy()
This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak...
void Unref(void) const
Decrement the reference count.
virtual void Remove(const EventId &ev)
Remove an event from the event list.
uint32_t GetUid(void) const
#define NS_LOG_LOGIC(msg)
virtual void Cancel(const EventId &ev)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
SynchronizationMode
Enumeration of the types of packets supported in the class.
static bool Equals(ThreadId id)
Compares an TharedId with the current ThreadId .
virtual Time GetDelayLeft(const EventId &id) const
virtual uint32_t GetSystemId(void) const
void SetHardLimit(Time limit)
int64_t GetTimeStep(void) const
static Time Now(void)
Return the "current simulation time".
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
virtual bool IsExpired(const EventId &ev) const
This method has O(1) complexity.
#define NS_ASSERT_MSG(condition, message)
virtual void SetScheduler(ObjectFactory schedulerFactory)
instantiate subclasses of ns3::Object.
an identifier for simulation events.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
bool Realtime(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
virtual uint32_t GetContext(void) const
virtual void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::Run method bef...
NS_LOG_COMPONENT_DEFINE("RealtimeSimulatorImpl")
void ScheduleRealtime(Time const &time, EventImpl *event)
static ThreadId Self(void)
Returns the current thread Id.
virtual bool IsFinished(void) const
If there are no more events lefts to be scheduled, or if simulation time has already reached the "sto...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
uint32_t m_currentContext
uint64_t GetTs(void) const
Doxygen introspection did not find any typical Config paths.