A Discrete-Event Network Simulator Home Tutorials  ▼ Docs    ▼ Develop ▼ API
ns3::Time Class Reference

Simulation virtual time values and global simulation resolution. More...

#include "nstime.h"

Collaboration diagram for ns3::Time:

## Classes

struct  Information
How to convert between other units and the current unit. More...

struct  Resolution
Current time unit, and conversion info. More...

## Public Types

enum  Unit {
Y = 0, D = 1, H = 2, MIN = 3,
S = 4, MS = 5, US = 6, NS = 7,
PS = 8, FS = 9, LAST = 10
}
The unit to use to interpret a number representing time. More...

## Public Member Functions

Time ()
Default constructor, with value 0. More...

Time (const Time &o)
Copy constructor. More...

Time (Time &&o)
Move constructor. More...

Time (const std::string &s)
Construct Time object from common time expressions like "1ms". More...

~Time ()
Destructor. More...

TimeWithUnit As (const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit. More...

int Compare (const Time &o) const
Compare this to another Time. More...

bool IsNegative (void) const

bool IsPositive (void) const

bool IsStrictlyNegative (void) const

bool IsStrictlyPositive (void) const

bool IsZero (void) const

operator int64x64_t () const
Cast to int64x64_t. More...

Timeoperator= (const Time &o)
Assignment operator. More...

Numeric constructors.

Construct from a numeric value.

Time (double v)
Construct from a numeric value. More...

Time (int v)
Construct from a numeric value. More...

Time (long int v)
Construct from a numeric value. More...

Time (long long int v)
Construct from a numeric value. More...

Time (unsigned int v)
Construct from a numeric value. More...

Time (unsigned long int v)
Construct from a numeric value. More...

Time (unsigned long long int v)
Construct from a numeric value. More...

Time (const int64x64_t &v)
Construct from a numeric value. More...

Convert to Number in a Unit.

Convert a Time to number, in indicated units.

Conversions to seconds and larger will return doubles, with possible loss of precision. Conversions to units smaller than seconds will by rounded.

double GetYears (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

double GetDays (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

double GetHours (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

double GetMinutes (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

double GetSeconds (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

int64_t GetMilliSeconds (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

int64_t GetMicroSeconds (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

int64_t GetNanoSeconds (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

int64_t GetPicoSeconds (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

int64_t GetFemtoSeconds (void) const
Get an approximation of the time stored in this instance in the indicated unit. More...

Convert to Raw Value.

Convert a Time to a number in the current resolution units.

int64_t GetTimeStep (void) const
Get the raw time value, in the current resolution unit. More...

double GetDouble (void) const
Get the raw time value, in the current resolution unit. More...

int64_t GetInteger (void) const
Get the raw time value, in the current resolution unit. More...

Get Times as Numbers in Specified Units

Get the Time as integers or doubles in the indicated unit.

int64_t ToInteger (enum Unit unit) const
Get the Time value expressed in a particular unit. More...

double ToDouble (enum Unit unit) const
Get the Time value expressed in a particular unit. More...

int64x64_t To (enum Unit unit) const
Get the Time value expressed in a particular unit. More...

## Static Public Member Functions

static Time From (const int64x64_t &value)
Create a Time in the current unit. More...

static enum Unit GetResolution (void)

static Time Max ()
Maximum representable Time. More...

static Time Min ()
Minimum representable Time. More...

static void SetResolution (enum Unit resolution)

static bool StaticInit ()
Function to force static initialization of Time. More...

Create Times from Values and Units.

Create Times from values given in the indicated units.

static Time FromInteger (uint64_t value, enum Unit unit)
Create a Time equal to value in unit unit. More...

static Time FromDouble (double value, enum Unit unit)
Create a Time equal to value in unit unit. More...

static Time From (const int64x64_t &value, enum Unit unit)
Create a Time equal to value in unit unit. More...

## Private Types

typedef std::set< Time * > MarkedTimes
Record all instances of Time, so we can rescale them when the resolution changes. More...

## Static Private Member Functions

static void Clear (Time *const time)
Remove a Time instance from the MarkedTimes, called by ~Time(). More...

static void ClearMarkedTimes ()
Remove all MarkedTimes. More...

static void ConvertTimes (const enum Unit unit)
Convert existing Times to the new unit. More...

static void Mark (Time *const time)
Record a Time instance with the MarkedTimes. More...

static struct InformationPeekInformation (enum Unit timeUnit)
Get the Information record for timeUnit for the current Resolution. More...

static struct ResolutionPeekResolution (void)
Get the current Resolution. More...

static struct Resolution SetDefaultNsResolution (void)
Set the default resolution. More...

static void SetResolution (enum Unit unit, struct Resolution *resolution, const bool convert=true)
Set the current Resolution. More...

## Private Attributes

int64_t m_data
Virtual time value, in the current unit. More...

## Static Private Attributes

static MarkedTimesg_markingTimes = 0
Record of outstanding Time objects which will need conversion when the resolution is set. More...

## Friends

Time Abs (const Time &time)
Absolute value function for Time. More...

Time Max (const Time &ta, const Time &tb)
Max function for Time. More...

Time Min (const Time &ta, const Time &tb)
Min function for Time. More...

class Simulator

bool operator== (const Time &lhs, const Time &rhs)
Arithmetic operator. More...

bool operator!= (const Time &lhs, const Time &rhs)
Inequality operator for Time. More...

bool operator<= (const Time &lhs, const Time &rhs)
Less than or equal operator for Time. More...

bool operator>= (const Time &lhs, const Time &rhs)
Greater than or equal operator for Time. More...

bool operator< (const Time &lhs, const Time &rhs)
Less than operator for Time. More...

bool operator> (const Time &lhs, const Time &rhs)
Greater than operator for Time. More...

Time operator+ (const Time &lhs, const Time &rhs)

Time operator- (const Time &lhs, const Time &rhs)
Difference operator for Time. More...

Time operator* (const Time &lhs, const int64_t &rhs)
Multiplication operator for Time. More...

Time operator* (const int64_t &lhs, const Time &rhs)
Multiplication operator for Time. More...

int64_t operator/ (const Time &lhs, const Time &rhs)
Division operator for Time. More...

Time operator/ (const Time &lhs, const int64_t &rhs)
Division operator for Time. More...

Timeoperator+= (Time &lhs, const Time &rhs)

Timeoperator-= (Time &lhs, const Time &rhs)
Subtraction operator for Time. More...

## Related Functions

(Note that these are not member functions.)

SystemMutexGetMarkingMutex ()

## Detailed Description

Simulation virtual time values and global simulation resolution.

This class defines all the classic C++ addition/subtraction operators: +, -, +=, -=; and all the classic comparison operators: ==, !=, <, >, <=, >=. It is thus easy to add, subtract, or compare Time objects.

For example:

Time t1 = Seconds (10.0);
Time t2 = Seconds (10.0);
Time t3 = t1;
t3 += t2;

You can also use the following non-member functions to manipulate any of these ns3::Time object:

This class also controls the resolution of the underlying time value. The resolution is the smallest representable time interval. The default resolution is nanoseconds.

To change the resolution, use SetResolution(). All Time objects created before the call to SetResolution() will be updated to the new resolution. This can only be done once! (Tracking each Time object uses 4 pointers. For speed, once we convert the existing instances we discard the recording data structure and stop tracking new instances, so we have no way to do a second conversion.)

If you increase the global resolution, you also implicitly decrease the range of your simulation. The global simulation time is stored in a 64 bit integer, whose interpretation will depend on the global resolution. Therefore the maximum duration of your simulation, if you use picoseconds, is 2^64 ps = 2^24 s = 7 months, whereas, had you used nanoseconds, you could have run for 584 years.

Definition at line 102 of file nstime.h.

## Member Typedef Documentation

 typedef std::set< Time * > ns3::Time::MarkedTimes
private

Record all instances of Time, so we can rescale them when the resolution changes.

Internal:

We use a std::set so we can remove the record easily when ~Time() is called.

We don't use Ptr<Time>, because we would have to bloat every Time instance with SimpleRefCount<Time>.

Seems like this should be std::set< Time * const >, but Stack Overflow says otherwise, quoting the standard:

& sect;23.1/3 states that std::set key types must be assignable and copy constructable; clearly a const type will not be assignable.

Definition at line 621 of file nstime.h.

## Member Enumeration Documentation

 enum ns3::Time::Unit

The unit to use to interpret a number representing time.

Enumerator

year, 365 days

day, 24 hours

hour, 60 minutes

MIN

minute, 60 seconds

second

MS

millisecond

US

microsecond

NS

nanosecond

PS

picosecond

FS

femtosecond

LAST

Definition at line 108 of file nstime.h.

## Constructor & Destructor Documentation

 ns3::Time::Time ( )
inline

Default constructor, with value 0.

Definition at line 134 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

Here is the caller graph for this function:

 ns3::Time::Time ( const Time & o )
inline

Copy constructor.

Parameters
 [in] o Time to copy

Definition at line 147 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( Time && o )
inline

Move constructor.

Parameters
 [in] o Time from which take the data

Definition at line 161 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( double v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 179 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( int v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 187 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( long int v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 195 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( long long int v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 203 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( unsigned int v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 211 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( unsigned long int v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 219 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( unsigned long long int v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 227 of file nstime.h.

References g_markingTimes, and Mark().

Here is the call graph for this function:

 ns3::Time::Time ( const int64x64_t & v )
inlineexplicit

Construct from a numeric value.

The current time resolution will be assumed as the unit.

Parameters
 [in] v The value.

Definition at line 235 of file nstime.h.

References g_markingTimes, Mark(), and Time().

Here is the call graph for this function:

 ns3::Time::Time ( const std::string & s )
explicit

Construct Time object from common time expressions like "1ms".

Supported units include:

• s (seconds)
• ms (milliseconds)
• us (microseconds)
• ns (nanoseconds)
• ps (picoseconds)
• fs (femtoseconds)
• min (minutes)
• h (hours)
• d (days)
• y (years)

There can be no white space between the numerical portion and the units. Any otherwise malformed string causes a fatal error to occur.

Parameters
 [in] s The string to parse into a Time

Definition at line 96 of file time.cc.

References D, FromDouble(), FS, g_markingTimes, H, Mark(), MIN, MS, sample-rng-plot::n, NS, NS_ABORT_MSG, NS_LOG_FUNCTION, PS, S, US, and Y.

Here is the call graph for this function:

 ns3::Time::~Time ( )
inline

Destructor.

Definition at line 279 of file nstime.h.

References Clear(), and g_markingTimes.

Here is the call graph for this function:

## Member Function Documentation

 TimeWithUnit ns3::Time::As ( const enum Unit unit ) const

Attach a unit to a Time, to facilitate output in a specific unit.

For example,

Time t (3.14e9); // Pi seconds
std::cout << t.As (Time::MS) << std::endl;

will print +3140.0ms

Parameters
 [in] unit The unit to use.
Returns
The Time with embedded unit.

Definition at line 388 of file time.cc.

Here is the caller graph for this function:

 void ns3::Time::Clear ( Time *const time )
staticprivate

Remove a Time instance from the MarkedTimes, called by ~Time().

Parameters
 [in] time The Time instance to remove.

Definition at line 313 of file time.cc.

Referenced by ~Time().

Here is the call graph for this function:

Here is the caller graph for this function:

 void ns3::Time::ClearMarkedTimes ( )
staticprivate

Remove all MarkedTimes.

Internal:
Has to be visible to the Simulator class, hence the friending.
Internal:

We're called by Simulator::Run, which knows nothing about the mutex, so we need a critical section here.

It would seem natural to use this function at the end of ConvertTimes, but that function already has the mutex. Our SystemMutex throws a fatal error if we try to lock it more than once in the same thread (at least in the unix implementation), so calling this function from ConvertTimes is a bad idea.

Instead, we copy this body into ConvertTimes.

Definition at line 256 of file time.cc.

References g_markingTimes, GetMarkingMutex(), NS_LOG_FUNCTION_NOARGS, and NS_LOG_LOGIC().

Referenced by ns3::Simulator::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

 int ns3::Time::Compare ( const Time & o ) const
inline

Compare this to another Time.

Parameters
 [in] o The other Time
Returns
-1,0,+1 if this < o, this == o, or this > o

Definition at line 318 of file nstime.h.

References m_data.

 void ns3::Time::ConvertTimes ( const enum Unit unit )
staticprivate

Convert existing Times to the new unit.

Parameters
 [in] unit The Unit to convert existing Times to.

Definition at line 343 of file time.cc.

Referenced by SetResolution().

Here is the call graph for this function:

Here is the caller graph for this function:

 static Time ns3::Time::From ( const int64x64_t & value )
inlinestatic

Create a Time in the current unit.

Parameters
 [in] value The value of the new Time.
Returns
A Time with value in the current time unit.

Definition at line 426 of file nstime.h.

References Time().

Here is the call graph for this function:

Here is the caller graph for this function:

 static Time ns3::Time::From ( const int64x64_t & value, enum Unit unit )
inlinestatic

Create a Time equal to value in unit unit.

Parameters
 [in] value The new Time value, expressed in unit [in] unit The unit of value
Returns
The Time representing value in unit

Definition at line 460 of file nstime.h.

Here is the call graph for this function:

 static Time ns3::Time::FromDouble ( double value, enum Unit unit )
inlinestatic

Create a Time equal to value in unit unit.

Parameters
 [in] value The new Time value, expressed in unit [in] unit The unit of value
Returns
The Time representing value in unit

Definition at line 456 of file nstime.h.

References From().

Here is the call graph for this function:

Here is the caller graph for this function:

 static Time ns3::Time::FromInteger ( uint64_t value, enum Unit unit )
inlinestatic

Create a Time equal to value in unit unit.

Parameters
 [in] value The new Time value, expressed in unit [in] unit The unit of value
Returns
The Time representing value in unit

Definition at line 443 of file nstime.h.

Here is the call graph for this function:

Here is the caller graph for this function:

 double ns3::Time::GetDays ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 343 of file nstime.h.

References D, and ToDouble().

Here is the call graph for this function:

 double ns3::Time::GetDouble ( void ) const
inline

Get the raw time value, in the current resolution unit.

Returns
The raw time value

Definition at line 395 of file nstime.h.

References m_data.

Referenced by ns3::BsmApplication::StartApplication(), and ns3::TcpHtcp::UpdateBeta().

Here is the caller graph for this function:

 int64_t ns3::Time::GetFemtoSeconds ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 375 of file nstime.h.

References FS, and ToInteger().

Here is the call graph for this function:

Here is the caller graph for this function:

 double ns3::Time::GetHours ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 347 of file nstime.h.

References H, and ToDouble().

Here is the call graph for this function:

 int64_t ns3::Time::GetInteger ( void ) const
inline

Get the raw time value, in the current resolution unit.

Returns
The raw time value

Definition at line 399 of file nstime.h.

References GetResolution(), GetTimeStep(), and SetResolution().

Here is the call graph for this function:

Here is the caller graph for this function:

 int64_t ns3::Time::GetMicroSeconds ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 363 of file nstime.h.

References ToInteger(), and US.

Here is the call graph for this function:

Here is the caller graph for this function:

 int64_t ns3::Time::GetMilliSeconds ( void ) const
inline
 double ns3::Time::GetMinutes ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 351 of file nstime.h.

References MIN, and ToDouble().

Here is the call graph for this function:

 int64_t ns3::Time::GetNanoSeconds ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 367 of file nstime.h.

References NS, and ToInteger().

Here is the call graph for this function:

Here is the caller graph for this function:

 int64_t ns3::Time::GetPicoSeconds ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 371 of file nstime.h.

References PS, and ToInteger().

Here is the call graph for this function:

 enum Time::Unit ns3::Time::GetResolution ( void )
static
Returns
The current global resolution.

Definition at line 380 of file time.cc.

References PeekResolution(), and ns3::Time::Resolution::unit.

Referenced by GetInteger(), ns3::operator<<(), and ns3::TimePrinter().

Here is the call graph for this function:

Here is the caller graph for this function:

 int64_t ns3::Time::GetTimeStep ( void ) const
inline
 double ns3::Time::GetYears ( void ) const
inline

Get an approximation of the time stored in this instance in the indicated unit.

Returns
An approximate value in the indicated unit.

Definition at line 339 of file nstime.h.

References ToDouble(), and Y.

Here is the call graph for this function:

 bool ns3::Time::IsNegative ( void ) const
inline
Returns
true if the time is negative or zero, false otherwise.

Definition at line 293 of file nstime.h.

References m_data.

 bool ns3::Time::IsPositive ( void ) const
inline
Returns
true if the time is positive or zero, false otherwise.

Definition at line 298 of file nstime.h.

References m_data.

Here is the caller graph for this function:

 bool ns3::Time::IsStrictlyNegative ( void ) const
inline
Returns
true if the time is strictly negative, false otherwise.

Definition at line 303 of file nstime.h.

References m_data.

Referenced by ns3::QosTxop::GetTxopRemaining().

Here is the caller graph for this function:

 bool ns3::Time::IsStrictlyPositive ( void ) const
inline
Returns
true if the time is strictly positive, false otherwise.

Definition at line 308 of file nstime.h.

References m_data.

Here is the caller graph for this function:

 bool ns3::Time::IsZero ( void ) const
inline
Returns
true if the time is zero, false otherwise.

Definition at line 288 of file nstime.h.

References m_data.

Here is the caller graph for this function:

 void ns3::Time::Mark ( Time *const time )
staticprivate

Record a Time instance with the MarkedTimes.

Parameters
 [in] time The Time instance to record.

Definition at line 287 of file time.cc.

References g_markingTimes, GetMarkingMutex(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC(), and NS_LOG_WARN.

Referenced by Time().

Here is the call graph for this function:

Here is the caller graph for this function:

 static Time ns3::Time::Max ( )
inlinestatic

Maximum representable Time.

Definition at line 273 of file nstime.h.

References max, and Time().

Here is the call graph for this function:

Here is the caller graph for this function:

 static Time ns3::Time::Min ( )
inlinestatic

Minimum representable Time.

Definition at line 268 of file nstime.h.

References min, and Time().

Here is the call graph for this function:

Here is the caller graph for this function:

 ns3::Time::operator int64x64_t ( ) const
inline

Cast to int64x64_t.

Definition at line 527 of file nstime.h.

References As(), and m_data.

Here is the call graph for this function:

 Time& ns3::Time::operator= ( const Time & o )
inline

Assignment operator.

Parameters
 [in] o Time to assign.
Returns
The Time.

Definition at line 128 of file nstime.h.

References m_data.

 static struct Information* ns3::Time::PeekInformation ( enum Unit timeUnit )
inlinestaticprivate

Get the Information record for timeUnit for the current Resolution.

Parameters
 [in] timeUnit The Unit to get Information for
Returns
The Information for timeUnit

Definition at line 581 of file nstime.h.

References ns3::Time::Resolution::info, PeekResolution(), and SetResolution().

Referenced by From(), FromInteger(), To(), and ToInteger().

Here is the call graph for this function:

Here is the caller graph for this function:

 static struct Resolution* ns3::Time::PeekResolution ( void )
inlinestaticprivate

Get the current Resolution.

Returns
A pointer to the current Resolution

Definition at line 570 of file nstime.h.

References SetDefaultNsResolution().

Referenced by GetResolution(), PeekInformation(), and SetResolution().

Here is the call graph for this function:

Here is the caller graph for this function:

 struct Time::Resolution ns3::Time::SetDefaultNsResolution ( void )
staticprivate

Set the default resolution.

Returns
The Resolution object for the default resolution.

Definition at line 170 of file time.cc.

References NS, NS_LOG_FUNCTION_NOARGS, and SetResolution().

Referenced by PeekResolution().

Here is the call graph for this function:

Here is the caller graph for this function:

 void ns3::Time::SetResolution ( enum Unit resolution )
static
Parameters
 [in] resolution The new resolution to use

Change the global resolution used to convert all user-provided time values in Time objects and Time objects in user-expected time units.

Definition at line 180 of file time.cc.

References NS_LOG_FUNCTION, and PeekResolution().

Here is the call graph for this function:

Here is the caller graph for this function:

 void ns3::Time::SetResolution ( enum Unit unit, struct Resolution * resolution, const bool convert = true )
staticprivate

Set the current Resolution.

Parameters
 [in] unit The unit to use as the new resolution. [in,out] resolution The Resolution record to update. [in] convert Whether to convert existing Time objects to the new resolution.

Definition at line 189 of file time.cc.

Here is the call graph for this function:

 bool ns3::Time::StaticInit ( )
static

Function to force static initialization of Time.

Returns
true on the first call

Definition at line 63 of file time.cc.

References g_markingTimes, GetMarkingMutex(), and NS_LOG_ERROR.

Here is the call graph for this function:

 int64x64_t ns3::Time::To ( enum Unit unit ) const
inline

Get the Time value expressed in a particular unit.

Parameters
 [in] unit The desired unit
Returns
The Time expressed in unit

Definition at line 509 of file nstime.h.

Referenced by ns3::OnOffApplication::CancelEvents(), ns3::operator<<(), and ToDouble().

Here is the call graph for this function:

Here is the caller graph for this function:

 double ns3::Time::ToDouble ( enum Unit unit ) const
inline

Get the Time value expressed in a particular unit.

Parameters
 [in] unit The desired unit
Returns
The Time expressed in unit

Definition at line 505 of file nstime.h.

References ns3::int64x64_t::GetDouble(), and To().

Here is the call graph for this function:

Here is the caller graph for this function:

 int64_t ns3::Time::ToInteger ( enum Unit unit ) const
inline

Get the Time value expressed in a particular unit.

Parameters
 [in] unit The desired unit
Returns
The Time expressed in unit

Definition at line 491 of file nstime.h.

Here is the call graph for this function:

Here is the caller graph for this function:

## Friends And Related Function Documentation

 Time Abs ( const Time & time )
friend

Absolute value function for Time.

Parameters
 [in] time The input value
Returns
The absolute value of the input value.

Definition at line 915 of file nstime.h.

 SystemMutex & GetMarkingMutex ( )
related
Internal:
Get mutex for critical sections around modification of Time::g_markingTimes
Returns

Definition at line 54 of file time.cc.

Referenced by Clear(), ClearMarkedTimes(), ConvertTimes(), Mark(), and StaticInit().

Here is the caller graph for this function:

 Time Max ( const Time & ta, const Time & tb )
friend

Max function for Time.

Parameters
 [in] ta The first value [in] tb The seconds value
Returns
The max of the two input values.

Definition at line 919 of file nstime.h.

 Time Min ( const Time & ta, const Time & tb )
friend

Min function for Time.

Parameters
 [in] ta The first value [in] tb The seconds value
Returns
The min of the two input values.

Definition at line 923 of file nstime.h.

 bool operator!= ( const Time & lhs, const Time & rhs )
friend

Inequality operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
true if the two input values not are equal.

Definition at line 760 of file nstime.h.

 Time operator* ( const Time & lhs, const int64_t & rhs )
friend

Multiplication operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the product of the two input values.

Definition at line 842 of file nstime.h.

 Time operator* ( const int64_t & lhs, const Time & rhs )
friend

Multiplication operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the product of the two input values.

Definition at line 856 of file nstime.h.

 Time operator+ ( const Time & lhs, const Time & rhs )
friend

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the sum of the two input values.

Definition at line 819 of file nstime.h.

 Time& operator+= ( Time & lhs, const Time & rhs )
friend

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the result of the first input value plus the second input value.

Definition at line 896 of file nstime.h.

 Time operator- ( const Time & lhs, const Time & rhs )
friend

Difference operator for Time.

Parameters
 [in] lhs The first value [in] rhs The seconds value
Returns
the difference of the two input values.

Definition at line 830 of file nstime.h.

 Time& operator-= ( Time & lhs, const Time & rhs )
friend

Subtraction operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the result of the first input value minus the second input value.

Definition at line 908 of file nstime.h.

 int64_t operator/ ( const Time & lhs, const Time & rhs )
friend

Division operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the resultof the first input value divided by the second input value.

Definition at line 870 of file nstime.h.

 Time operator/ ( const Time & lhs, const int64_t & rhs )
friend

Division operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
the resultof the first input value divided by the second input value.

Definition at line 883 of file nstime.h.

 bool operator< ( const Time & lhs, const Time & rhs )
friend

Less than operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
true if the first input value is less than the second input value.

Definition at line 796 of file nstime.h.

 bool operator<= ( const Time & lhs, const Time & rhs )
friend

Less than or equal operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
true if the first input value is less than or equal to the second input value.

Definition at line 772 of file nstime.h.

 bool operator== ( const Time & lhs, const Time & rhs )
friend

Arithmetic operator.

Parameters
 [in] lhs Left hand argument [in] rhs Right hand argument
Returns
The result of the operator.
Parameters
 [in] lhs The first value [in] rhs The second value
Returns
true if the two input values are equal.

Definition at line 748 of file nstime.h.

 bool operator> ( const Time & lhs, const Time & rhs )
friend

Greater than operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
true if the first input value is greater than the second input value.

Definition at line 808 of file nstime.h.

 bool operator>= ( const Time & lhs, const Time & rhs )
friend

Greater than or equal operator for Time.

Parameters
 [in] lhs The first value [in] rhs The second value
Returns
true if the first input value is greater than or equal to the second input value.

Definition at line 784 of file nstime.h.

 friend class Simulator
friend

Definition at line 649 of file nstime.h.

## Member Data Documentation

 Time::MarkedTimes * ns3::Time::g_markingTimes = 0
staticprivate

Record of outstanding Time objects which will need conversion when the resolution is set.

Internal:

Use a classic static variable so we can check in Time ctors without a function call.

We'd really like to initialize this here, but we don't want to require C++0x, so we init in time.cc. To ensure that happens before first use, we add a call to StaticInit (below) to every compilation unit which includes nstime.h.

Definition at line 636 of file nstime.h.

Referenced by Clear(), ClearMarkedTimes(), ConvertTimes(), Mark(), StaticInit(), Time(), and ~Time().

 int64_t ns3::Time::m_data
private

Virtual time value, in the current unit.

Definition at line 721 of file nstime.h.

The documentation for this class was generated from the following files: