A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ()
 
 Time (const Time &o)
 
 Time (double v)
 
 Time (int v)
 
 Time (long int v)
 
 Time (long long int v)
 
 Time (unsigned int v)
 
 Time (unsigned long int v)
 
 Time (unsigned long long int v)
 
 Time (const std::string &s)
 Construct Time object from common time expressions like "1ms". More...
 
 Time (const int64x64_t &value)
 
 ~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
 
double GetDays (void) const
 
double GetDouble (void) const
 
int64_t GetFemtoSeconds (void) const
 
double GetHours (void) const
 
int64_t GetInteger (void) const
 
int64_t GetMicroSeconds (void) const
 
int64_t GetMilliSeconds (void) const
 
double GetMinutes (void) const
 
int64_t GetNanoSeconds (void) const
 
int64_t GetPicoSeconds (void) const
 
double GetSeconds (void) const
 
int64_t GetTimeStep (void) const
 
double GetYears (void) const
 
bool IsNegative (void) const
 
bool IsPositive (void) const
 
bool IsStrictlyNegative (void) const
 
bool IsStrictlyPositive (void) const
 
bool IsZero (void) const
 
 operator int64x64_t () const
 
Timeoperator= (const Time &o)
 
int64x64_t To (enum Unit timeUnit) const
 
double ToDouble (enum Unit timeUnit) const
 
int64_t ToInteger (enum Unit timeUnit) const
 

Static Public Member Functions

static Time From (const int64x64_t &from, enum Unit timeUnit)
 
static Time From (const int64x64_t &value)
 
static Time FromDouble (double value, enum Unit timeUnit)
 
static Time FromInteger (uint64_t value, enum Unit timeUnit)
 
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...
 

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)
 
static struct ResolutionPeekResolution (void)
 
static struct Resolution SetDefaultNsResolution (void)
 
static void SetResolution (enum Unit unit, struct Resolution *resolution, const bool convert=true)
 

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...
 
bool operator!= (const Time &lhs, const Time &rhs)
 
Time operator* (const Time &lhs, const int64_t &rhs)
 
Time operator* (const int64_t &lhs, const Time &rhs)
 
Time operator+ (const Time &lhs, const Time &rhs)
 
Timeoperator+= (Time &lhs, const Time &rhs)
 
Time operator- (const Time &lhs, const Time &rhs)
 
Timeoperator-= (Time &lhs, const Time &rhs)
 
int64_t operator/ (const Time &lhs, const Time &rhs)
 
Time operator/ (const Time &lhs, const int64_t &rhs)
 
bool operator< (const Time &lhs, const Time &rhs)
 
bool operator<= (const Time &lhs, const Time &rhs)
 
bool operator== (const Time &lhs, const Time &rhs)
 
bool operator> (const Time &lhs, const Time &rhs)
 
bool operator>= (const Time &lhs, const Time &rhs)
 
class Simulator
 

Related Functions

(Note that these are not member functions.)

Time Days (double days)
 create ns3::Time instances in units of days (equal to 24 hours). More...
 
Time Days (int64x64_t days)
 
Time FemtoSeconds (uint64_t fs)
 create ns3::Time instances in units of femtoseconds. More...
 
Time FemtoSeconds (int64x64_t fs)
 
SystemMutexGetMarkingMutex ()
 
Time Hours (double hours)
 create ns3::Time instances in units of hours (equal to 60 minutes). More...
 
Time Hours (int64x64_t hours)
 
Time MicroSeconds (uint64_t us)
 create ns3::Time instances in units of microseconds. More...
 
Time MicroSeconds (int64x64_t us)
 
Time MilliSeconds (uint64_t ms)
 create ns3::Time instances in units of milliseconds. More...
 
Time MilliSeconds (int64x64_t ms)
 
Time Minutes (double minutes)
 create ns3::Time instances in units of minutes (equal to 60 seconds). More...
 
Time Minutes (int64x64_t minutes)
 
Time NanoSeconds (uint64_t ns)
 create ns3::Time instances in units of nanoseconds. More...
 
Time NanoSeconds (int64x64_t ns)
 
std::ostream & operator<< (std::ostream &os, const Time &time)
 Time output streamer. More...
 
std::istream & operator>> (std::istream &is, Time &time)
 Time input streamer. More...
 
Time PicoSeconds (uint64_t ps)
 create ns3::Time instances in units of picoseconds. More...
 
Time PicoSeconds (int64x64_t ps)
 
Time Seconds (double seconds)
 create ns3::Time instances in units of seconds. More...
 
Time Seconds (int64x64_t seconds)
 
Time Years (double years)
 create ns3::Time instances in units of years (equal to 365 days). More...
 
Time Years (int64x64_t years)
 

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, substract, 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 79 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 561 of file nstime.h.

Member Enumeration Documentation

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 85 of file nstime.h.

Constructor & Destructor Documentation

ns3::Time::Time ( )
inline

Definition at line 105 of file nstime.h.

References g_markingTimes, and Mark().

Referenced by From(), FromInteger(), Max(), and Min().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 113 of file nstime.h.

References g_markingTimes, and Mark().

+ Here is the call graph for this function:

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

Definition at line 121 of file nstime.h.

References g_markingTimes, and Mark().

+ Here is the call graph for this function:

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

Definition at line 129 of file nstime.h.

References g_markingTimes, and Mark().

+ Here is the call graph for this function:

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

Definition at line 137 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

Definition at line 145 of file nstime.h.

References g_markingTimes, and Mark().

+ Here is the call graph for this function:

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

Definition at line 153 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

Definition at line 161 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

Definition at line 169 of file nstime.h.

References g_markingTimes, and Mark().

+ 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
sThe string to parse into a Time

Definition at line 92 of file time.cc.

References D, FromDouble(), FS, g_markingTimes, H, Mark(), MIN, MS, 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 217 of file nstime.h.

References Clear(), and g_markingTimes.

+ Here is the call graph for this function:

ns3::Time::Time ( const int64x64_t value)
inlineexplicit

Definition at line 480 of file nstime.h.

References g_markingTimes, and Mark().

+ 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
unit[in] The unit to use.

Definition at line 384 of file time.cc.

Referenced by TimeIntputOutputTestCase::DoRun(), and ns3::operator<<().

+ 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()

Definition at line 309 of file time.cc.

References g_markingTimes, GetMarkingMutex(), NS_ASSERT, NS_ASSERT_MSG, 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:

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 252 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
Returns
-1,0,+1 if this < o, this == o, or this > o

Definition at line 263 of file nstime.h.

References m_data.

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

Convert existing Times to the new unit.

Definition at line 339 of file time.cc.

References g_markingTimes, GetMarkingMutex(), m_data, NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, and ToInteger().

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 from,
enum Unit  timeUnit 
)
inlinestatic

Definition at line 446 of file nstime.h.

References ns3::Time::Information::fromMul, ns3::int64x64_t::MulByInvert(), PeekInformation(), Time(), and ns3::Time::Information::timeFrom.

Referenced by Days(), FemtoSeconds(), FromDouble(), Hours(), MicroSeconds(), MilliSeconds(), Minutes(), NanoSeconds(), PicoSeconds(), Seconds(), and Years().

+ 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

Definition at line 488 of file nstime.h.

References Time().

+ Here is the call graph for this function:

static Time ns3::Time::FromDouble ( double  value,
enum Unit  timeUnit 
)
inlinestatic
Parameters
valueto convert into a Time object
timeUnitthe unit of the value to convert
Returns
a new Time object
See also
FromInteger, ToInteger, ToDouble

Definition at line 431 of file nstime.h.

References From().

Referenced by Days(), Hours(), ns3::RttMeanDeviation::Measurement(), Minutes(), Seconds(), Time(), and Years().

+ 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  timeUnit 
)
inlinestatic
Parameters
valueto convert into a Time object
timeUnitthe unit of the value to convert
Returns
a new Time object

This method interprets the input value according to the input unit and constructs a matching Time object.

See also
FromDouble, ToDouble, ToInteger

Definition at line 390 of file nstime.h.

References ns3::Time::Information::factor, ns3::Time::Information::fromMul, PeekInformation(), and Time().

Referenced by FemtoSeconds(), MicroSeconds(), MilliSeconds(), NanoSeconds(), PicoSeconds(), and ns3::RttMeanDeviation::RetransmitTimeout().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double ns3::Time::GetDays ( void  ) const
inline
Returns
an approximation in days of the time stored in this instance.

Definition at line 338 of file nstime.h.

References D, and ToDouble().

+ Here is the call graph for this function:

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

Definition at line 358 of file nstime.h.

References m_data.

int64_t ns3::Time::GetFemtoSeconds ( void  ) const
inline
Returns
an approximation in femtoseconds of the time stored in this instance.

Definition at line 313 of file nstime.h.

References FS, and ToInteger().

+ Here is the call graph for this function:

double ns3::Time::GetHours ( void  ) const
inline
Returns
an approximation in hours of the time stored in this instance.

Definition at line 330 of file nstime.h.

References H, and ToDouble().

+ Here is the call graph for this function:

int64_t ns3::Time::GetInteger ( void  ) const
inline
double ns3::Time::GetMinutes ( void  ) const
inline
Returns
an approximation in minutes of the time stored in this instance.

Definition at line 322 of file nstime.h.

References MIN, and ToDouble().

+ Here is the call graph for this function:

int64_t ns3::Time::GetPicoSeconds ( void  ) const
inline
Returns
an approximation in picoseconds of the time stored in this instance.

Definition at line 305 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 376 of file time.cc.

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

Referenced by ns3::operator<<().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double ns3::Time::GetSeconds ( void  ) const
inline
Returns
an approximation in seconds of the time stored in this instance.

Definition at line 272 of file nstime.h.

References S, and ToDouble().

Referenced by ns3::dsr::RouteCache::AddRoute_Link(), ns3::AsciiLrWpanMacTransmitSinkWithContext(), ns3::AsciiLrWpanMacTransmitSinkWithoutContext(), ns3::AsciiPhyReceiveSinkWithContext(), ns3::AsciiPhyReceiveSinkWithoutContext(), ns3::AsciiPhyRxOkEvent(), ns3::AsciiPhyTransmitSinkWithContext(), ns3::AsciiPhyTransmitSinkWithoutContext(), ns3::AsciiPhyTxEvent(), ns3::WimaxHelper::AsciiRxEvent(), ns3::WimaxHelper::AsciiTxEvent(), ns3::UanPhyCalcSinrFhFsk::CalcSinrDb(), ns3::InterferenceHelper::CalculateChunkSuccessRate(), ns3::SimpleOfdmWimaxPhy::CalculateDataRate(), ns3::DistributedSimulatorImpl::CalculateLookAhead(), ns3::BasicEnergySource::CalculateRemainingEnergy(), ns3::LiIonEnergySource::CalculateRemainingEnergy(), ns3::LteUeRrc::CancelEnteringTrigger(), ns3::LteUeRrc::CancelLeavingTrigger(), ns3::AcousticModemEnergyModel::ChangeState(), ns3::WifiRadioEnergyModel::ChangeState(), CheckQueueSize(), LteX2HandoverMeasuresTestCase::CheckStats(), LteX2HandoverTestCase::CheckStatsAWhileAfterHandover(), ns3::UanMacRcGw::ComputeAlpha(), ns3::UanMacRcGw::ComputeExpS(), BatteryLifetimeTest::ConstantLoadTest(), Ns2MobilityHelperTest::CourseChange(), WaypointMobilityModelNotifyTest::CourseChangeCallback(), ns3::AnimationInterface::CsmaPhyTxEndTrace(), CwndChange(), CwndTracer(), Ns3TcpLossTestCase::CwndTracer(), ns3::AsciiTraceHelper::DefaultDequeueSinkWithContext(), ns3::AsciiTraceHelper::DefaultDequeueSinkWithoutContext(), ns3::AsciiTraceHelper::DefaultDropSinkWithContext(), ns3::AsciiTraceHelper::DefaultDropSinkWithoutContext(), ns3::AsciiTraceHelper::DefaultEnqueueSinkWithContext(), ns3::AsciiTraceHelper::DefaultEnqueueSinkWithoutContext(), ns3::AsciiTraceHelper::DefaultReceiveSinkWithContext(), ns3::AsciiTraceHelper::DefaultReceiveSinkWithoutContext(), ns3::AnimationInterface::DevTxTrace(), ns3::TraceFadingLossModel::DoCalcRxPowerSpectralDensity(), ns3::SimpleOfdmWimaxPhy::DoGetFrameDurationCode(), ns3::SimpleOfdmWimaxPhy::DoGetNrBytes(), ns3::SimpleOfdmWimaxPhy::DoGetNrSymbols(), ns3::dot11s::HwmpProtocol::DoInitialize(), ns3::MeshWifiInterfaceMac::DoInitialize(), ns3::RipNg::DoInitialize(), TimesWithSignsTestCase::DoRun(), ns3::SimpleOfdmWimaxPhy::DoSetPhyParameters(), ns3::RandomWalk2dMobilityModel::DoWalk(), ns3::GaussMarkovMobilityModel::DoWalk(), ns3::TcpWestwood::DupAck(), LteHandoverDelayTestCase::EnbHandoverEndOkCallback(), ns3::LteTestSinrChunkProcessor::End(), ns3::LteCtrlSinrChunkProcessor::End(), ns3::LteDataSinrChunkProcessor::End(), ns3::LteRsReceivedPowerChunkProcessor::End(), ns3::LteInterferencePowerChunkProcessor::End(), ns3::BaseStationNetDevice::EndDlSubFrame(), ns3::BaseStationNetDevice::EndUlSubFrame(), ns3::UanMacCw::Enqueue(), ns3::TcpWestwood::EstimateBW(), ns3::ShannonSpectrumErrorModel::EvaluateChunk(), ns3::LteTestSinrChunkProcessor::EvaluateSinrChunk(), ns3::LteCtrlSinrChunkProcessor::EvaluateSinrChunk(), ns3::LteDataSinrChunkProcessor::EvaluateSinrChunk(), ns3::LteRsReceivedPowerChunkProcessor::EvaluateSinrChunk(), ns3::LteInterferencePowerChunkProcessor::EvaluateSinrChunk(), ExampleFunction(), ns3::dsr::RouteCache::FindSameRoute(), ns3::SpectrumAnalyzer::GenerateReport(), GenerateTraffic(), ns3::UanMacRcGw::GetExpPdk(), ns3::dsdv::RoutingProtocol::GetSettlingTime(), ns3::JakesProcess::Oscillator::GetValueAt(), ns3::AnimationInterface::GetXMLOpenClose_linkupdate(), ns3::AnimationInterface::GetXMLOpenClose_nodeupdate(), ns3::AnimationInterface::GetXMLOpenClose_routing(), ns3::AnimationInterface::GetXMLOpenClose_rp(), ns3::AnimationInterface::GetXMLOpenCloseUpdateNodeColor(), ns3::AnimationInterface::GetXMLOpenCloseUpdateNodeCounter(), ns3::AnimationInterface::GetXMLOpenCloseUpdateNodeDescription(), ns3::AnimationInterface::GetXMLOpenCloseUpdateNodeImage(), ns3::AnimationInterface::GetXMLOpenCloseUpdateNodePosition(), ns3::AnimationInterface::GetXMLOpenCloseUpdateNodeSize(), MyModel::HandleEvent(), DynamicGlobalRoutingTestCase::HandleRead(), ns3::dsr::RouteCache::IncStability(), ns3::RedQueue::InitializeParams(), ns3::SubscriberStationNetDevice::InitSubscriberStationNetDevice(), ns3::aodv::RoutingTableEntry::Invalidate(), ns3::Ipv4L3ProtocolDropSinkWithContext(), ns3::Ipv4L3ProtocolDropSinkWithoutContext(), ns3::Ipv4L3ProtocolRxSinkWithContext(), ns3::Ipv4L3ProtocolRxSinkWithoutContext(), ns3::Ipv4L3ProtocolTxSinkWithContext(), ns3::Ipv4L3ProtocolTxSinkWithoutContext(), ns3::Ipv6L3ProtocolDropSinkWithContext(), ns3::Ipv6L3ProtocolDropSinkWithoutContext(), ns3::Ipv6L3ProtocolRxSinkWithContext(), ns3::Ipv6L3ProtocolRxSinkWithoutContext(), ns3::Ipv6L3ProtocolTxSinkWithContext(), ns3::Ipv6L3ProtocolTxSinkWithoutContext(), ns3::ArpCache::Entry::IsExpired(), ns3::olsr::RoutingProtocol::LinkSensing(), main(), ns3::aodv::RoutingTable::MarkLinkAsUnidirectional(), ns3::BaseStationNetDevice::MarkUplinkAllocations(), modify(), NotifyConnectionEstablishedEnb(), NotifyConnectionEstablishedUe(), NotifyHandoverEndOkEnb(), NotifyHandoverEndOkUe(), NotifyHandoverStartEnb(), NotifyHandoverStartUe(), ns3::UanMacCw::NotifyTxStart(), ns3::operator*(), ns3::operator<<(), LrWpanCcaTestCase::PhyRxBegin(), LrWpanCcaTestCase::PhyRxDrop(), LrWpanCcaTestCase::PhyRxEnd(), LrWpanCcaTestCase::PhyTxBegin(), LrWpanCcaTestCase::PhyTxEnd(), LrWpanCcaTestCase::PlmeCcaConfirm(), ns3::SeqTsHeader::Print(), ns3::UanHeaderRcData::Print(), ns3::dsdv::RoutingTableEntry::Print(), ns3::UanHeaderRcRts::Print(), ns3::UanHeaderRcCtsGlobal::Print(), ns3::UanHeaderRcCts::Print(), PrintCellInfo(), IpAddressHelper::PrintIpAddresses(), PrintReceivedPacket(), ns3::dsdv::RoutingProtocol::PrintRoutingTable(), ns3::aodv::RoutingProtocol::PrintRoutingTable(), ns3::Ipv4ListRouting::PrintRoutingTable(), ns3::Ipv6ListRouting::PrintRoutingTable(), ns3::RipNg::PrintRoutingTable(), ns3::Ipv6StaticRouting::PrintRoutingTable(), ns3::UplinkSchedulerMBQoS::ProcessBandwidthRequest(), ns3::AnimPacketInfo::ProcessRxEnd(), ns3::AnimationInterface::PurgePendingCsma(), ns3::AnimationInterface::PurgePendingLte(), ns3::AnimationInterface::PurgePendingWifi(), ns3::AnimationInterface::PurgePendingWimax(), RandomFunction(), ns3::UanMacRc::ReceiveOkFromPhy(), ns3::dsdv::RoutingProtocol::RecvDsdv(), ns3::dot11s::HwmpProtocol::Report(), ns3::flame::FlameProtocol::Report(), ns3::dot11s::PeerLink::Report(), ns3::MeshWifiInterfaceMac::Report(), ns3::MeshHelper::Report(), ns3::FlowMonitor::ReportLastRx(), SampleEmitter::Reschedule(), NetAnimExperiment::ResetData(), Experiment::ResetData(), ns3::TcpWestwood::Retransmit(), ns3::RttMeanDeviation::RetransmitTimeout(), ns3::RttEstimator::RttEstimator(), ns3::RvBatteryModel::RvModelAFunction(), ns3::UanMacRc::ScheduleData(), ns3::dsr::DsrRouting::ScheduleNetworkPacketRetry(), ns3::dsr::DsrRouting::ScheduleRreqRetry(), ns3::aodv::RoutingProtocol::SendRerrMessage(), ns3::aodv::RoutingProtocol::SendRerrWhenNoRouteToForward(), ns3::RipNg::SendTriggeredRouteUpdate(), ns3::RipNg::SendUnsolicitedRouteUpdate(), ns3::UanHeaderRcData::Serialize(), ns3::UanHeaderRcRts::Serialize(), ns3::UanHeaderRcCtsGlobal::Serialize(), ns3::UanHeaderRcCts::Serialize(), ns3::dot11s::PeerLink::SetBeaconInformation(), ns3::SimpleDeviceEnergyModel::SetCurrentA(), ns3::olsr::MessageHeader::Hello::SetHTime(), ns3::UanPdp::SetTap(), ns3::olsr::MessageHeader::SetVTime(), showPosition(), DynamicGlobalRoutingTestCase::SinkRx(), SocketPrinter(), SsThreshTracer(), ns3::dsr::DsrRouting::Start(), ns3::UanMacRcGw::StartCycle(), ns3::BaseStationNetDevice::StartDlSubFrame(), Ns3TcpStateTestCase::StartFlow(), Ns3TcpLossTestCase::StartFlow(), ns3::BaseStationNetDevice::StartFrame(), ns3::UanMacCw::StartTimer(), ns3::BaseStationNetDevice::StartUlSubFrame(), StateChangeNotification(), ns3::UanPdp::SumTapsC(), ns3::UanPdp::SumTapsFromMaxC(), ns3::UanPdp::SumTapsFromMaxNc(), ns3::UanPdp::SumTapsNc(), TestDeterministicByTime(), ns3::TimePrinter(), ns3::CsmaNetDevice::TransmitCompleteEvent(), ns3::CsmaChannel::TransmitEnd(), ns3::PointToPointNetDevice::TransmitStart(), ns3::CsmaNetDevice::TransmitStart(), LteHandoverDelayTestCase::UeHandoverEndOkCallback(), ns3::ConstantVelocityHelper::Update(), BatteryLifetimeTest::VariableLoadTest(), ns3::WriteAveragePowerSpectralDensityReport(), ns3::AnimationInterface::WriteDummyPacket(), Ns3TcpStateTestCase::WriteUntilBufferFull(), and Ns3TcpLossTestCase::WriteUntilBufferFull().

+ Here is the call graph for this function:

double ns3::Time::GetYears ( void  ) const
inline
Returns
an approximation in years of the time stored in this instance.

Definition at line 346 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 235 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 242 of file nstime.h.

References m_data.

Referenced by ns3::DefaultSimulatorImpl::Schedule(), and ns3::RealtimeSimulatorImpl::Schedule().

+ 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 249 of file nstime.h.

References m_data.

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

Definition at line 256 of file nstime.h.

References m_data.

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

Definition at line 228 of file nstime.h.

References m_data.

Referenced by main(), and ns3::YansWifiPhy::StartReceivePacket().

+ Here is the caller graph for this function:

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

Record a Time instance with the MarkedTimes.

Definition at line 283 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 209 of file nstime.h.

References Time().

Referenced by ns3::MakeTimeChecker().

+ 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 202 of file nstime.h.

References Time().

Referenced by ns3::MakeTimeChecker().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 476 of file nstime.h.

References m_data.

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

Definition at line 100 of file nstime.h.

References m_data.

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

Definition at line 533 of file nstime.h.

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

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

Definition at line 528 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

Definition at line 166 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
resolutionthe 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 176 of file time.cc.

References NS_LOG_FUNCTION, and PeekResolution().

Referenced by main(), and SetDefaultNsResolution().

+ 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
bool ns3::Time::StaticInit ( )
static

Function to force static initialization of Time.

Definition at line 59 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  timeUnit) const
inline

Definition at line 462 of file nstime.h.

References m_data, ns3::int64x64_t::MulByInvert(), PeekInformation(), ns3::Time::Information::timeTo, and ns3::Time::Information::toMul.

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  timeUnit) const
inline
Parameters
timeUnitthe unit of the value to return
Returns
double time value

Convert the input time into a floating point value according to the requested time unit.

Definition at line 442 of file nstime.h.

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

Referenced by GetDays(), GetHours(), GetMinutes(), GetSeconds(), GetYears(), and ns3::RttMeanDeviation::Measurement().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t ns3::Time::ToInteger ( enum Unit  timeUnit) const
inline
Parameters
timeUnitthe unit of the value to return
Returns
int64_t time value

Convert the input time into an integer value according to the requested time unit.

Definition at line 410 of file nstime.h.

References ns3::Time::Information::factor, m_data, PeekInformation(), and ns3::Time::Information::toMul.

Referenced by ConvertTimes(), GetFemtoSeconds(), GetMicroSeconds(), GetMilliSeconds(), GetNanoSeconds(), GetPicoSeconds(), and ns3::RttMeanDeviation::RetransmitTimeout().

+ 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
timethe input value
Returns
the absolute value of the input value.

Definition at line 737 of file nstime.h.

Time Days ( double  days)
related

create ns3::Time instances in units of days (equal to 24 hours).

For example:

Time t = Days (2.0);
Parameters
daysdays value

Definition at line 895 of file nstime.h.

References D, and FromDouble().

+ Here is the call graph for this function:

Time Days ( int64x64_t  days)
related
See also
Minutes(uint64_t)

Definition at line 983 of file nstime.h.

References D, and From().

+ Here is the call graph for this function:

Time FemtoSeconds ( uint64_t  fs)
related

create ns3::Time instances in units of femtoseconds.

For example:

Parameters
fsfemtoseconds value

Definition at line 850 of file nstime.h.

References FromInteger(), and FS.

+ Here is the call graph for this function:

Time FemtoSeconds ( int64x64_t  fs)
related
See also
FemtoSeconds(uint64_t)

Definition at line 959 of file nstime.h.

References From(), and FS.

+ Here is the call graph for this function:

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

Definition at line 50 of file time.cc.

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

+ Here is the caller graph for this function:

Time Hours ( double  hours)
related

create ns3::Time instances in units of hours (equal to 60 minutes).

For example:

Time t = Hours (2.0);
Parameters
hourshours value

Definition at line 880 of file nstime.h.

References FromDouble(), and H.

+ Here is the call graph for this function:

Time Hours ( int64x64_t  hours)
related
See also
Minutes(uint64_t)

Definition at line 975 of file nstime.h.

References From(), and H.

+ Here is the call graph for this function:

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

Max function for Time.

Parameters
tathe first value
tbthe seconds value
Returns
the max of the two input values.

Definition at line 717 of file nstime.h.

Time MicroSeconds ( uint64_t  us)
related

create ns3::Time instances in units of microseconds.

For example:

Parameters
usmicroseconds value

Definition at line 805 of file nstime.h.

References FromInteger(), and US.

+ Here is the call graph for this function:

Time MicroSeconds ( int64x64_t  us)
related
See also
MicroSeconds(uint64_t)

Definition at line 935 of file nstime.h.

References From(), and US.

+ Here is the call graph for this function:

Time MilliSeconds ( uint64_t  ms)
related

create ns3::Time instances in units of milliseconds.

For example:

Parameters
msmilliseconds value

Definition at line 790 of file nstime.h.

References FromInteger(), and MS.

Referenced by main(), and operator<<().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time MilliSeconds ( int64x64_t  ms)
related
See also
MilliSeconds(uint64_t)

Definition at line 927 of file nstime.h.

References From(), and MS.

+ Here is the call graph for this function:

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

Min function for Time.

Parameters
tathe first value
tbthe seconds value
Returns
the min of the two input values.

Definition at line 727 of file nstime.h.

Time Minutes ( double  minutes)
related

create ns3::Time instances in units of minutes (equal to 60 seconds).

For example:

Time t = Minutes (2.0);
Parameters
minutesmintues value

Definition at line 865 of file nstime.h.

References FromDouble(), and MIN.

+ Here is the call graph for this function:

Time Minutes ( int64x64_t  minutes)
related
See also
Minutes(uint64_t)

Definition at line 967 of file nstime.h.

References From(), and MIN.

+ Here is the call graph for this function:

Time NanoSeconds ( uint64_t  ns)
related

create ns3::Time instances in units of nanoseconds.

For example:

Parameters
nsnanoseconds value

Definition at line 820 of file nstime.h.

References FromInteger(), and NS.

+ Here is the call graph for this function:

Time NanoSeconds ( int64x64_t  ns)
related
See also
NanoSeconds(uint64_t)

Definition at line 943 of file nstime.h.

References From(), and NS.

+ Here is the call graph for this function:

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

Definition at line 641 of file nstime.h.

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

Definition at line 674 of file nstime.h.

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

Definition at line 681 of file nstime.h.

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

Definition at line 665 of file nstime.h.

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

Definition at line 700 of file nstime.h.

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

Definition at line 669 of file nstime.h.

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

Definition at line 705 of file nstime.h.

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

Definition at line 688 of file nstime.h.

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

Definition at line 694 of file nstime.h.

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

Definition at line 656 of file nstime.h.

std::ostream & operator<< ( std::ostream &  os,
const Time time 
)
related

Time output streamer.

Generates output such as "3.96ns". Times are printed with the following format flags (independent of the stream flags):

  • showpos
  • fixed
  • left The stream width and precision are ignored; Time output always includes ".0".

Definition at line 391 of file time.cc.

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

Definition at line 646 of file nstime.h.

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

Definition at line 636 of file nstime.h.

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

Definition at line 661 of file nstime.h.

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

Definition at line 651 of file nstime.h.

std::istream & operator>> ( std::istream &  is,
Time time 
)
related

Time input streamer.

Uses the Time::Time (const std::string &) constructor

Definition at line 430 of file time.cc.

Time PicoSeconds ( uint64_t  ps)
related

create ns3::Time instances in units of picoseconds.

For example:

Parameters
pspicoseconds value

Definition at line 835 of file nstime.h.

References FromInteger(), and PS.

+ Here is the call graph for this function:

Time PicoSeconds ( int64x64_t  ps)
related
See also
PicoSeconds(uint64_t)

Definition at line 951 of file nstime.h.

References From(), and PS.

+ Here is the call graph for this function:

Time Seconds ( double  seconds)
related

create ns3::Time instances in units of seconds.

For example:

Time t = Seconds (2.0);
Parameters
secondsseconds value

Definition at line 774 of file nstime.h.

References FromDouble(), and S.

Referenced by AttributeTestCase< T >::DoRun(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time Seconds ( int64x64_t  seconds)
related
See also
Seconds(double)

Definition at line 919 of file nstime.h.

References From(), and S.

+ Here is the call graph for this function:

friend class Simulator
friend

Definition at line 587 of file nstime.h.

Time Years ( double  years)
related

create ns3::Time instances in units of years (equal to 365 days).

For example:

Time t = Years (2.0);
Parameters
yearsyears value

Definition at line 910 of file nstime.h.

References FromDouble(), and Y.

+ Here is the call graph for this function:

Time Years ( int64x64_t  years)
related
See also
Minutes(uint64_t)

Definition at line 991 of file nstime.h.

References From(), and Y.

+ Here is the call graph for this function:

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 576 of file nstime.h.

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


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