next up previous contents index
Next: 4.1.2 Event creation and Up: 4.1 Event Scheduling Previous: 4.1 Event Scheduling   Contents   Index

4.1.1 Simulation time

Simulation time is kept track of internally using a 64bit integer in units of nanoseconds. To make sure that this internal variable can be easily changed to represent a higher-precision time or that we can use a variable with a larger dynamic range, user programs never access directly this time variable. Instead, the current simulation time is exported to the user through a single method Simulator::Now () which returns an opaque object of type Time. Users can also easily create instances of this type through the functions Seconds, MilliSeconds, MicroSeconds, or NanoSeconds each of which takes a single argument in the specified unit and returns an instance of a Time object.

Instances of the class Time can be used just like normal integers or floating-point values: they support all the normal arithmetic operators and can be converted to values in a specific time unit with Time::GetSeconds, Time::GetMilliSeconds, Time::GetMicroSeconds, and, Time::GetNanoSeconds.

These instances of the class Time store their time value in a 64.64bit fixed-point integer variable. That is, the user-visible time variables are kept track of with 64 bits of fractional integer precision. If users are careful to perform all their arithemtic operations on Time variables, they can easily ensure that their code will behave exactly in the same way on multiple platforms.


next up previous contents index
Next: 4.1.2 Event creation and Up: 4.1 Event Scheduling Previous: 4.1 Event Scheduling   Contents   Index
Tom Henderson 2007-06-17