|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
57 static TypeId tid =
TypeId (
"ns3::RealtimeSimulatorImpl")
59 .SetGroupName (
"Core")
61 .AddAttribute (
"SynchronizationMode",
62 "What to do if the simulation cannot keep up with real time.",
67 .AddAttribute (
"HardLimit",
68 "Maximum acceptable real-time jitter (used in conjunction with SynchronizationMode=HardLimit)",
139 if (ev->IsCancelled () ==
false)
158 while (
m_events->IsEmpty () ==
false)
161 scheduler->Insert (next);
193 uint64_t tsDelay = 0;
223 "RealtimeSimulatorImpl::ProcessOneEvent (): Synchronizer reports not Realtime ()");
250 tsDelay = tsNext - tsNow;
331 "RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty");
342 "RealtimeSimulatorImpl::ProcessOneEvent(): "
343 "next.GetTs() earlier than m_currentTs (list order error)");
381 "Hard real-time limit exceeded (jitter = " << tsJitter <<
")");
417 "RealtimeSimulatorImpl::NextTs(): event queue is empty");
428 "RealtimeSimulatorImpl::Run(): Simulator already running");
439 uint64_t tsDelay = 1000000000;
443 bool process =
false;
478 "RealtimeSimulatorImpl::Run(): Empty queue and unprocessed events");
649 "RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext(): schedule for time < m_currentTs");
715 if (
id.GetUid () == 2)
739 event.
impl =
id.PeekEventImpl ();
740 event.key.m_ts =
id.GetTs ();
741 event.key.m_context =
id.GetContext ();
742 event.key.m_uid =
id.GetUid ();
746 event.impl->Cancel ();
747 event.impl->Unref ();
756 id.PeekEventImpl ()->Cancel ();
763 if (
id.GetUid () == 2)
765 if (
id.PeekEventImpl () == 0
766 ||
id.PeekEventImpl ()->IsCancelled ())
790 if (
id.PeekEventImpl () == 0
793 ||
id.PeekEventImpl ()->IsCancelled ())
806 return TimeStep (0x7fffffffffffffffLL);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< Scheduler > m_events
The event list.
virtual uint64_t GetEventCount(void) const
Get the number of events executed.
void SetSynchronizationMode(RealtimeSimulatorImpl::SynchronizationMode mode)
Set the SynchronizationMode.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
NS_FATAL_x macro definitions.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
virtual EventId Schedule(const Time &delay, EventImpl *event)
Schedule a future event execution (in the same context).
virtual void Run(void)
Run the simulation.
Time RealtimeNow(void) const
Get the current real time from the synchronizer.
An identifier for simulation events.
@ SYNC_BEST_EFFORT
Make a best effort to keep synced to real-time.
virtual void Remove(const EventId &ev)
Remove an event from the event list.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_uid
Unique id of the current event.
Realtime version of SimulatorImpl.
ns3::BooleanValue attribute value declarations.
virtual void SetScheduler(ObjectFactory schedulerFactory)
Set the Scheduler to be used to manage the event list.
virtual Time Now(void) const
Return the current simulation virtual time.
EventImpl * impl
Pointer to the event implementation.
uint32_t m_currentContext
The event list.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
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...
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
ns3::Synchronizer declaration.
void ScheduleRealtimeNow(EventImpl *event)
Schedule an event to run at the current virtual time.
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
void ScheduleRealtimeNowWithContext(uint32_t context, EventImpl *event)
Schedule an event to run at the current virtual time.
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...
Ptr< Synchronizer > m_synchronizer
The synchronizer in use to track real time.
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
SynchronizationMode
What to do when we can't maintain real time synchrony.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
uint64_t NextTs(void) const
Get the timestep of the next event.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold variables of type enum.
ns3::Scheduler abstract base class, ns3::Scheduler::Event and ns3::Scheduler::EventKey declarations.
virtual void ScheduleWithContext(uint32_t context, const Time &delay, EventImpl *event)
Schedule a future event execution (in a different context).
RealtimeSimulatorImpl()
Constructor.
uint64_t m_ts
Event time stamp.
void SetHardLimit(Time limit)
Set the fatal error threshold for SynchronizationMode SYNC_HARD_LIMIT.
virtual bool IsFinished(void) const
Check if the simulation should finish.
Time m_hardLimit
The maximum allowable drift from real-time in SYNC_HARD_LIMIT mode.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
~RealtimeSimulatorImpl()
Destructor.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
EventKey key
Key for sorting and ordering Events.
void ScheduleRealtimeWithContext(uint32_t context, const Time &delay, EventImpl *event)
Schedule a future event execution (in a different context).
uint32_t m_context
Event context.
virtual uint32_t GetContext(void) const
Get the current simulation context.
ns3::WallClockSynchronizer declaration.
ns3::PointerValue attribute value declarations and template implementations.
A class which provides a simple way to implement a Critical Section.
Instantiate subclasses of ns3::Object.
ns3::EventImpl declarations.
bool m_running
Is the simulator currently running.
Simulation virtual time values and global simulation resolution.
void ProcessOneEvent(void)
Process the next event.
void Unref(void) const
Decrement the reference count.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint64_t m_currentTs
Execution context.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
int m_unscheduledEvents
Unique id for the next event to be scheduled.
static bool Equals(ThreadId id)
Compares an ThreadId with the current ThreadId .
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
static ThreadId Self(void)
Returns the current thread Id.
bool IsPositive(void) const
Exactly equivalent to t >= 0.
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
System-independent mutex primitive, ns3::SystemMutex, and ns3::CriticalSection.
The SimulatorImpl base class.
void ScheduleRealtime(const Time &delay, EventImpl *event)
Schedule a future event execution (in the same context).
virtual void DoDispose(void)
Destructor implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint64_t m_eventCount
The event count.
SystemMutex m_mutex
Mutex to control access to key state.
ns3::Simulator declaration.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
ns3::RealtimeSimulatorImpl declaration.
Time GetHardLimit(void) const
Get the current fatal error threshold for SynchronizationMode SYNC_HARD_LIMIT.
SystemThread::ThreadId m_main
Main SystemThread.
DestroyEvents m_destroyEvents
Container for events to be run at destroy time.
bool Realtime(void) const
Check that the Synchronizer is locked to the real time clock.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
bool m_stop
Has the stopping condition been reached?
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
bool Running(void) const
Is the simulator running?
SynchronizationMode m_synchronizationMode
SynchronizationMode policy.
static TypeId GetTypeId(void)
Get the registered TypeId for this class.
RealtimeSimulatorImpl::SynchronizationMode GetSynchronizationMode(void) const
Get the SynchronizationMode.
uint32_t m_currentUid
Timestep of the current event.
virtual bool IsExpired(const EventId &ev) const
Check if an event has already run or been cancelled.
ns3::Ptr smart pointer declaration and implementation.
@ NO_CONTEXT
Flag for events not associated with any particular context.
@ SYNC_HARD_LIMIT
Keep to real time within the hard limit tolerance configured with SetHardLimit, or die trying.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint32_t m_uid
Event unique id.
ns3::EnumValue attribute value declarations.