|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
19 #ifndef WALL_CLOCK_CLOCK_SYNCHRONIZER_H
20 #define WALL_CLOCK_CLOCK_SYNCHRONIZER_H
134 virtual bool DoSynchronize (uint64_t nsCurrent, uint64_t nsDelay);
150 uint64_t
DriftCorrect (uint64_t nsNow, uint64_t nsDelay);
190 struct timeval *result);
a unique identifier for an interface.
virtual void DoSetOrigin(uint64_t ns)
Establish a correspondence between a simulation time and a wall-clock (real) time.
virtual bool DoSynchronize(uint64_t nsCurrent, uint64_t nsDelay)
Wait until the real time is in sync with the specified simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Synchronizer declaration.
uint64_t DriftCorrect(uint64_t nsNow, uint64_t nsDelay)
Compute a correction to the nominal delay to account for realtime drift since the last DoSynchronize.
uint64_t GetNormalizedRealtime(void)
Get the current normalized real time, in ns.
Base class used for synchronizing the simulation events to some real time "wall clock....
uint64_t m_jiffy
Size of the system clock tick, as reported by clock_getres, in ns.
static TypeId GetTypeId(void)
Get the registered TypeId for this class.
static const uint64_t US_PER_SEC
Conversion constant between μs and seconds.
A class which provides a relatively platform-independent conditional-wait thread synchronization prim...
bool SpinWait(uint64_t ns)
Do a busy-wait until the normalized realtime equals the argument or the condition variable becomes tr...
static const uint64_t NS_PER_SEC
Conversion constant between ns and s.
uint64_t GetRealtime(void)
Get the current absolute real time (in ns since the epoch).
virtual void DoEventStart(void)
Record the normalized real time at which the current event is starting execution.
virtual void DoSetCondition(bool cond)
Set the condition variable to tell a possible simulator thread waiting in the Synchronize method that...
uint64_t TimevalToNs(struct timeval *tv)
Convert a timeval to absolute time, in ns.
WallClockSynchronizer()
Constructor.
virtual bool DoRealtime(void)
Return true if this synchronizer is actually synchronizing to a realtime clock.
virtual int64_t DoGetDrift(uint64_t ns)
Get the drift between the real time clock used to synchronize the simulation and the current simulati...
bool SleepWait(uint64_t ns)
Put our process to sleep for some number of nanoseconds.
ns3::SystemCondition declaration.
virtual uint64_t DoGetCurrentRealtime(void)
Retrieve the value of the origin of the underlying normalized wall clock time in Time resolution unit...
virtual void DoSignal(void)
Tell a possible simulator thread waiting in the DoSynchronize method that an event has happened which...
virtual ~WallClockSynchronizer()
Destructor.
Class used for synchronizing the simulation events to a real-time "wall clock" using Posix clock func...
uint64_t m_nsEventStart
Time recorded by DoEventStart.
void TimevalAdd(struct timeval *tv1, struct timeval *tv2, struct timeval *result)
Add two timeval.
void NsToTimeval(int64_t ns, struct timeval *tv)
Convert an absolute time in ns to a timeval.
static const uint64_t US_PER_NS
Conversion constant between μs and ns.
SystemCondition m_condition
Thread synchronizer.
virtual uint64_t DoEventEnd(void)
Return the amount of real time elapsed since the last call to EventStart.