A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
realtime-simulator-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #ifndef REALTIME_SIMULATOR_IMPL_H
20 #define REALTIME_SIMULATOR_IMPL_H
21 
22 #include "simulator-impl.h"
23 #include "system-thread.h"
24 
25 #include "scheduler.h"
26 #include "synchronizer.h"
27 #include "event-impl.h"
28 
29 #include "ptr.h"
30 #include "assert.h"
31 #include "log.h"
32 #include "system-mutex.h"
33 
34 #include <list>
35 
36 namespace ns3 {
37 
42 {
43 public:
44  static TypeId GetTypeId (void);
45 
53  };
54 
57 
58  virtual void Destroy ();
59  virtual bool IsFinished (void) const;
60  virtual void Stop (void);
61  virtual void Stop (Time const &time);
62  virtual EventId Schedule (Time const &time, EventImpl *event);
63  virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
64  virtual EventId ScheduleNow (EventImpl *event);
65  virtual EventId ScheduleDestroy (EventImpl *event);
66  virtual void Remove (const EventId &ev);
67  virtual void Cancel (const EventId &ev);
68  virtual bool IsExpired (const EventId &ev) const;
69  virtual void Run (void);
70  virtual Time Now (void) const;
71  virtual Time GetDelayLeft (const EventId &id) const;
72  virtual Time GetMaximumSimulationTime (void) const;
73  virtual void SetScheduler (ObjectFactory schedulerFactory);
74  virtual uint32_t GetSystemId (void) const;
75  virtual uint32_t GetContext (void) const;
76 
77  void ScheduleRealtimeWithContext (uint32_t context, Time const &time, EventImpl *event);
78  void ScheduleRealtime (Time const &time, EventImpl *event);
79  void ScheduleRealtimeNowWithContext (uint32_t context, EventImpl *event);
80  void ScheduleRealtimeNow (EventImpl *event);
81  Time RealtimeNow (void) const;
82 
85 
86  void SetHardLimit (Time limit);
87  Time GetHardLimit (void) const;
88 
89 private:
90  bool Running (void) const;
91  bool Realtime (void) const;
92  uint64_t NextTs (void) const;
93  void ProcessOneEvent (void);
94  virtual void DoDispose (void);
95 
96  typedef std::list<EventId> DestroyEvents;
98  bool m_stop;
99  bool m_running;
100 
101  // The following variables are protected using the m_mutex
104  uint32_t m_uid;
105  uint32_t m_currentUid;
106  uint64_t m_currentTs;
108 
110 
112 
117 
122 
123  SystemThread::ThreadId m_main;
124 };
125 
126 } // namespace ns3
127 
128 #endif /* REALTIME_SIMULATOR_IMPL_H */
void ScheduleRealtimeNowWithContext(uint32_t context, EventImpl *event)
void SetSynchronizationMode(RealtimeSimulatorImpl::SynchronizationMode mode)
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual EventId ScheduleNow(EventImpl *event)
virtual EventId Schedule(Time const &time, EventImpl *event)
void ScheduleRealtimeNow(EventImpl *event)
virtual Time GetMaximumSimulationTime(void) const
Time m_hardLimit
The maximum allowable drift from real-time in SYNC_HARD_LIMIT mode.
SynchronizationMode m_synchronizationMode
The policy to use if the simulation cannot keep synchronized to real-time.
void ScheduleRealtimeWithContext(uint32_t context, Time const &time, EventImpl *event)
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)
RealtimeSimulatorImpl::SynchronizationMode GetSynchronizationMode(void) const
Make a best effort to keep synced to real-time.
virtual Time Now(void) const
Return the "current simulation time".
virtual void Run(void)
Run the simulation until one of:
virtual void Destroy()
This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak...
std::list< EventId > DestroyEvents
virtual void Remove(const EventId &ev)
Remove an event from the event list.
Doxygen introspection did not find any typical Config paths.
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.
virtual Time GetDelayLeft(const EventId &id) const
virtual uint32_t GetSystemId(void) const
A class which provides a relatively platform-independent Mutual Exclusion thread synchronization prim...
Definition: system-mutex.h:50
virtual bool IsExpired(const EventId &ev) const
This method has O(1) complexity.
virtual void SetScheduler(ObjectFactory schedulerFactory)
instantiate subclasses of ns3::Object.
a simulation event
Definition: event-impl.h:39
an identifier for simulation events.
Definition: event-id.h:46
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...
void ScheduleRealtime(Time const &time, EventImpl *event)
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.
Definition: type-id.h:49
Doxygen introspection did not find any typical Config paths.