19 #ifndef REALTIME_SIMULATOR_IMPL_H
20 #define REALTIME_SIMULATOR_IMPL_H
95 virtual void Stop (
void);
96 virtual void Stop (
const Time &delay);
104 virtual void Run (
void);
183 uint64_t
NextTs (
void)
const;
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
An identifier for simulation events.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Realtime version of SimulatorImpl.
void ScheduleRealtime(const Time &delay, EventImpl *event)
Schedule a future event execution (in the same context).
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Ptr< Scheduler > m_events
The event list.
virtual void ScheduleWithContext(uint32_t context, const Time &delay, EventImpl *event)
Schedule a future event execution (in a different context).
DestroyEvents m_destroyEvents
Container for events to be run at destroy time.
virtual void DoDispose(void)
Destructor implementation.
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
int m_unscheduledEvents
Unique id for the next event to be scheduled.
virtual EventId Schedule(const Time &delay, EventImpl *event)
Schedule a future event execution (in the same context).
bool Realtime(void) const
Check that the Synchronizer is locked to the real time clock.
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.
RealtimeSimulatorImpl()
Constructor.
bool m_running
Is the simulator currently running.
uint32_t m_currentContext
The event list.
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 Remove(const EventId &ev)
Remove an event from the event list.
Time GetHardLimit(void) const
Get the current fatal error threshold for SynchronizationMode SYNC_HARD_LIMIT.
std::mutex m_mutex
Mutex to control access to key state.
SynchronizationMode m_synchronizationMode
SynchronizationMode policy.
uint64_t NextTs(void) const
Get the timestep of the next event.
virtual void Run(void)
Run the simulation.
uint64_t m_currentTs
Execution context.
void SetHardLimit(Time limit)
Set the fatal error threshold for SynchronizationMode SYNC_HARD_LIMIT.
uint32_t m_uid
Unique id of the current event.
uint64_t m_eventCount
The event count.
uint32_t m_currentUid
Timestep of the current event.
virtual void SetScheduler(ObjectFactory schedulerFactory)
Set the Scheduler to be used to manage the event list.
void ScheduleRealtimeNowWithContext(uint32_t context, EventImpl *event)
Schedule an event to run at the current virtual time.
bool m_stop
Has the stopping condition been reached?
Ptr< Synchronizer > m_synchronizer
The synchronizer in use to track real time.
SynchronizationMode
What to do when we can't maintain real time synchrony.
@ SYNC_BEST_EFFORT
Make a best effort to keep synced to real-time.
@ SYNC_HARD_LIMIT
Keep to real time within the hard limit tolerance configured with SetHardLimit, or die trying.
Time m_hardLimit
The maximum allowable drift from real-time in SYNC_HARD_LIMIT mode.
static TypeId GetTypeId(void)
Get the registered TypeId for this class.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
void ScheduleRealtimeWithContext(uint32_t context, const Time &delay, EventImpl *event)
Schedule a future event execution (in a different context).
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
virtual bool IsFinished(void) const
Check if the simulation should finish.
virtual Time Now(void) const
Return the current simulation virtual time.
~RealtimeSimulatorImpl()
Destructor.
virtual uint32_t GetContext(void) const
Get the current simulation context.
bool Running(void) const
Is the simulator running?
virtual uint64_t GetEventCount(void) const
Get the number of events executed.
void ProcessOneEvent(void)
Process the next event.
std::thread::id m_main
Main thread.
RealtimeSimulatorImpl::SynchronizationMode GetSynchronizationMode(void) const
Get the SynchronizationMode.
void SetSynchronizationMode(RealtimeSimulatorImpl::SynchronizationMode mode)
Set the SynchronizationMode.
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 Destroy()
Execute the events scheduled with ScheduleDestroy().
std::list< EventId > DestroyEvents
Container type for events to be run at destroy time.
Time RealtimeNow(void) const
Get the current real time from the synchronizer.
virtual bool IsExpired(const EventId &ev) const
Check if an event has already run or been cancelled.
The SimulatorImpl base class.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
ns3::EventImpl declarations.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ptr smart pointer declaration and implementation.
ns3::Scheduler abstract base class, ns3::Scheduler::Event and ns3::Scheduler::EventKey declarations.
ns3::SimulatorImpl declaration.
ns3::Synchronizer declaration.