A Discrete-Event Network Simulator
API
Virtual Time

Management of virtual time in real world units. More...

+ Collaboration diagram for Virtual Time:

Modules

 Standard Time Units.
 Convenience constructors in standard units.
 

Files

file  nstime.h
 Declaration of classes ns3::Time and ns3::TimeWithUnit, and the TimeValue implementation classes.
 
file  time-printer.cc
 ns3::DefaultTimePrinter implementation.
 
file  time-printer.h
 Declaration of ns3::TimePrinter function pointer type and ns3::DefaultTimePrinter function.
 
file  time.cc
 ns3::Time, ns3::TimeWithUnit and ns3::TimeValue attribute value implementations.
 

Classes

class  ns3::Time
 Simulation virtual time values and global simulation resolution. More...
 
class  ns3::TimeWithUnit
 A Time with attached unit, to facilitate output in that unit. More...
 

Functions

Ptr< const AttributeCheckerns3::MakeTimeChecker (const Time min, const Time max)
 Helper to make a Time checker with bounded range. More...
 
Ptr< const AttributeCheckerns3::MakeTimeChecker (void)
 Helper to make an unbounded Time checker. More...
 
Ptr< const AttributeCheckerns3::MakeTimeChecker (const Time min)
 Helper to make a Time checker with a lower bound. More...
 
Time ns3::TimeStep (uint64_t ts)
 
bool ns3::operator== (const Time &lhs, const Time &rhs)
 Equality operator for Time. More...
 
bool ns3::operator!= (const Time &lhs, const Time &rhs)
 Inequality operator for Time. More...
 
bool ns3::operator<= (const Time &lhs, const Time &rhs)
 Less than or equal operator for Time. More...
 
bool ns3::operator>= (const Time &lhs, const Time &rhs)
 Greater than or equal operator for Time. More...
 
bool ns3::operator< (const Time &lhs, const Time &rhs)
 Less than operator for Time. More...
 
bool ns3::operator> (const Time &lhs, const Time &rhs)
 Greater than operator for Time. More...
 
Time ns3::operator+ (const Time &lhs, const Time &rhs)
 Addition operator for Time. More...
 
Time ns3::operator- (const Time &lhs, const Time &rhs)
 Difference operator for Time. More...
 
Time ns3::operator* (const Time &lhs, const int64_t &rhs)
 Multiplication operator for Time. More...
 
Time ns3::operator* (const int64_t &lhs, const Time &rhs)
 Multiplication operator for Time. More...
 
Time ns3::operator* (const Time &lhs, const int64x64_t &rhs)
 Multiplication operator for Time. More...
 
Time ns3::operator* (const int64x64_t &lhs, const Time &rhs)
 Multiplication operator for Time. More...
 
int64x64_t ns3::operator/ (const Time &lhs, const Time &rhs)
 Division operator for Time. More...
 
Time ns3::operator/ (const Time &lhs, const int64_t &rhs)
 Division operator for Time. More...
 
Time ns3::operator/ (const Time &lhs, const int64x64_t &rhs)
 Division operator for Time. More...
 
Timens3::operator+= (Time &lhs, const Time &rhs)
 Addition operator for Time. More...
 
Timens3::operator-= (Time &lhs, const Time &rhs)
 Subtraction operator for Time. More...
 
std::ostream & ns3::operator<< (std::ostream &os, const Time &time)
 Time output streamer. More...
 
std::istream & ns3::operator>> (std::istream &is, Time &time)
 Time input streamer. More...
 
Time ns3::Abs (const Time &time)
 
Time ns3::Max (const Time &ta, const Time &tb)
 
Time ns3::Min (const Time &ta, const Time &tb)
 

Detailed Description

Management of virtual time in real world units.

The underlying simulator is unit agnostic, just dealing with dimensionless virtual time. Models usually need to handle time in real world units, such as seconds, and conversions/scaling between different units, between minutes and seconds, for example.

The convenience constructors in the Standard Units module make it easy to create Times in specific units.

The Time::SetResolution() function allows a one-time change of the base resolution, before Simulator::Run().

Function Documentation

◆ Abs()

Time ns3::Abs ( const Time time)
inline
Parameters
[in]timeThe input value
Returns
The absolute value of the input value.

Definition at line 968 of file nstime.h.

References ns3::Time::m_data.

◆ MakeTimeChecker() [1/3]

Ptr< const AttributeChecker > ns3::MakeTimeChecker ( const Time  min,
const Time  max 
)

Helper to make a Time checker with bounded range.

Both limits are inclusive

Parameters
[in]minMinimum allowed value.
[in]maxMaximum allowed value.
Returns
The AttributeChecker

Definition at line 446 of file time.cc.

References ns3::Copy(), ns3::Create(), ns3::TimeValue::Get(), ns3::max(), ns3::min(), NS_LOG_FUNCTION, and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::BasicEnergySource::GetTypeId(), ns3::HeConfiguration::GetTypeId(), ns3::DelayJitterEstimationTimestampTag::GetTypeId(), ns3::FrameCaptureModel::GetTypeId(), ns3::LteFfrDistributedAlgorithm::GetTypeId(), ns3::LteRlcAm::GetTypeId(), ns3::Probe::GetTypeId(), ns3::UdpEchoClient::GetTypeId(), ns3::V4Ping::GetTypeId(), ns3::Ping6::GetTypeId(), ns3::RttEstimator::GetTypeId(), ns3::UdpClient::GetTypeId(), ns3::AmrrWifiManager::GetTypeId(), ns3::DhcpServer::GetTypeId(), ns3::BasicEnergyHarvester::GetTypeId(), ns3::dot11s::PeerLink::GetTypeId(), ns3::TcpHybla::GetTypeId(), ns3::RvBatteryModel::GetTypeId(), ns3::DhcpClient::GetTypeId(), ns3::OnoeWifiManager::GetTypeId(), ns3::RandomWalk2dMobilityModel::GetTypeId(), ns3::SimpleChannel::GetTypeId(), ns3::ApWifiMac::GetTypeId(), ns3::TraceFadingLossModel::GetTypeId(), ns3::TcpSocket::GetTypeId(), ns3::WifiMac::GetTypeId(), ns3::TcpHtcp::GetTypeId(), ns3::PointToPointEpcHelper::GetTypeId(), ns3::Ipv6PmtuCache::GetTypeId(), ns3::MeshWifiInterfaceMac::GetTypeId(), ns3::PieQueueDisc::GetTypeId(), ns3::UanMacCw::GetTypeId(), ns3::aodv::RoutingProtocol::GetTypeId(), ns3::PointToPointChannel::GetTypeId(), ns3::Icmpv6L4Protocol::GetTypeId(), ns3::PacketSocketClient::GetTypeId(), ns3::SpectrumAnalyzer::GetTypeId(), ns3::dsdv::RoutingProtocol::GetTypeId(), ns3::RealtimeSimulatorImpl::GetTypeId(), ns3::TcpLedbat::GetTypeId(), ns3::WaveformGenerator::GetTypeId(), ns3::NoBackhaulEpcHelper::GetTypeId(), ns3::WifiMacQueue::GetTypeId(), ns3::RraaWifiManager::GetTypeId(), ns3::CobaltQueueDisc::GetTypeId(), ns3::UanMacRcGw::GetTypeId(), ns3::Application::GetTypeId(), ns3::TvSpectrumTransmitter::GetTypeId(), ns3::CoDelQueueDisc::GetTypeId(), ns3::dot11s::HwmpProtocol::GetTypeId(), ns3::DynamicQueueLimits::GetTypeId(), ns3::PointToPointNetDevice::GetTypeId(), ns3::BridgeNetDevice::GetTypeId(), ns3::BaseStationNetDevice::GetTypeId(), ns3::ArpCache::GetTypeId(), EpsBearerTagUdpClient::GetTypeId(), ns3::LiIonEnergySource::GetTypeId(), ns3::A3RsrpHandoverAlgorithm::GetTypeId(), ns3::ChannelCoordinator::GetTypeId(), ns3::RrpaaWifiManager::GetTypeId(), ns3::SixLowPanNetDevice::GetTypeId(), ns3::WimaxPhy::GetTypeId(), ns3::Txop::GetTypeId(), ns3::ThreeGppHttpVariables::GetTypeId(), ns3::SubscriberStationNetDevice::GetTypeId(), ns3::UplinkSchedulerMBQoS::GetTypeId(), ns3::RedQueueDisc::GetTypeId(), ns3::flame::FlameRtable::GetTypeId(), ns3::Ipv4L3Protocol::GetTypeId(), ns3::GaussMarkovMobilityModel::GetTypeId(), ns3::FdNetDevice::GetTypeId(), ns3::LteUePhy::GetTypeId(), ns3::olsr::RoutingProtocol::GetTypeId(), ns3::flame::FlameProtocol::GetTypeId(), ns3::RadioBearerStatsCalculator::GetTypeId(), ns3::WifiPhy::GetTypeId(), ns3::CsmaChannel::GetTypeId(), ns3::AthstatsWifiTraceSink::GetTypeId(), ns3::dsr::DsrRouting::GetTypeId(), AttributeObjectTest::GetTypeId(), ns3::QosTxop::GetTypeId(), TimestampTag::GetTypeId(), ns3::TapBridge::GetTypeId(), ns3::StaWifiMac::GetTypeId(), ns3::FlowMonitor::GetTypeId(), ns3::LteUeRrc::GetTypeId(), ns3::MinstrelWifiManager::GetTypeId(), ns3::UanMacRc::GetTypeId(), ns3::Rip::GetTypeId(), ns3::RipNg::GetTypeId(), ns3::MinstrelHtWifiManager::GetTypeId(), ns3::TcpSocketBase::GetTypeId(), ns3::LteEnbRrc::GetTypeId(), and ns3::MakeTimeChecker().

+ Here is the call graph for this function:

◆ MakeTimeChecker() [2/3]

ns3::Ptr< const ns3::AttributeChecker > ns3::MakeTimeChecker ( void  )
inline

Helper to make an unbounded Time checker.


Returns
The AttributeChecker
The AttributeChecker.
See also
AttributeChecker

Definition at line 1145 of file nstime.h.

References ns3::MakeTimeChecker(), ns3::Time::Max(), and ns3::Time::Min().

+ Here is the call graph for this function:

◆ MakeTimeChecker() [3/3]

Ptr<const AttributeChecker> ns3::MakeTimeChecker ( const Time  min)
inline

Helper to make a Time checker with a lower bound.

Parameters
[in]minMinimum allowed value.
Returns
The AttributeChecker

Definition at line 1158 of file nstime.h.

References ns3::MakeTimeChecker(), ns3::Time::Max(), and ns3::min().

+ Here is the call graph for this function:

◆ Max()

Time ns3::Max ( const Time ta,
const Time tb 
)
inline
Parameters
[in]taThe first value
[in]tbThe seconds value
Returns
The max of the two input values.

Definition at line 972 of file nstime.h.

References ns3::Time::m_data.

◆ Min()

Time ns3::Min ( const Time ta,
const Time tb 
)
inline
Parameters
[in]taThe first value
[in]tbThe seconds value
Returns
The min of the two input values.

Definition at line 976 of file nstime.h.

References ns3::Time::m_data.

◆ operator!=()

bool ns3::operator!= ( const Time lhs,
const Time rhs 
)
inline

Inequality operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
true if the two input values not are equal.

Definition at line 773 of file nstime.h.

References ns3::Time::m_data.

◆ operator*() [1/4]

Time ns3::operator* ( const Time lhs,
const int64_t &  rhs 
)
inline

Multiplication operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the product of the two input values.

Definition at line 855 of file nstime.h.

References ns3::Time::m_data.

◆ operator*() [2/4]

Time ns3::operator* ( const int64_t &  lhs,
const Time rhs 
)
inline

Multiplication operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the product of the two input values.

Definition at line 869 of file nstime.h.

References ns3::Time::m_data.

◆ operator*() [3/4]

Time ns3::operator* ( const Time lhs,
const int64x64_t rhs 
)
inline

Multiplication operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the product of the two input values.

Definition at line 883 of file nstime.h.

References ns3::Time::m_data.

◆ operator*() [4/4]

Time ns3::operator* ( const int64x64_t lhs,
const Time rhs 
)
inline

Multiplication operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the product of the two input values.

Definition at line 897 of file nstime.h.

◆ operator+()

Time ns3::operator+ ( const Time lhs,
const Time rhs 
)
inline

Addition operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the sum of the two input values.

Definition at line 832 of file nstime.h.

References ns3::Time::m_data.

◆ operator+=()

Time& ns3::operator+= ( Time lhs,
const Time rhs 
)
inline

Addition operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the result of the first input value plus the second input value.

Definition at line 950 of file nstime.h.

References ns3::Time::m_data.

◆ operator-()

Time ns3::operator- ( const Time lhs,
const Time rhs 
)
inline

Difference operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe seconds value
Returns
the difference of the two input values.

Definition at line 843 of file nstime.h.

References ns3::Time::m_data.

◆ operator-=()

Time& ns3::operator-= ( Time lhs,
const Time rhs 
)
inline

Subtraction operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the result of the first input value minus the second input value.

Definition at line 962 of file nstime.h.

References ns3::Time::m_data.

◆ operator/() [1/3]

int64x64_t ns3::operator/ ( const Time lhs,
const Time rhs 
)
inline

Division operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the resultof the first input value divided by the second input value.

Definition at line 909 of file nstime.h.

References ns3::Time::m_data.

◆ operator/() [2/3]

Time ns3::operator/ ( const Time lhs,
const int64_t &  rhs 
)
inline

Division operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the resultof the first input value divided by the second input value.

Definition at line 923 of file nstime.h.

References ns3::Time::m_data.

◆ operator/() [3/3]

Time ns3::operator/ ( const Time lhs,
const int64x64_t rhs 
)
inline

Division operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
the resultof the first input value divided by the second input value.

Definition at line 937 of file nstime.h.

References ns3::Time::m_data.

◆ operator<()

bool ns3::operator< ( const Time lhs,
const Time rhs 
)
inline

Less than operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
true if the first input value is less than the second input value.

Definition at line 809 of file nstime.h.

References ns3::Time::m_data.

◆ operator<<()

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

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".
Parameters
[in,out]osThe output stream.
[in]timeThe Time to put on the stream.
Returns
The stream.

Definition at line 395 of file time.cc.

References ns3::Time::As(), and ns3::Time::GetResolution().

+ Here is the call graph for this function:

◆ operator<=()

bool ns3::operator<= ( const Time lhs,
const Time rhs 
)
inline

Less than or equal operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
true if the first input value is less than or equal to the second input value.

Definition at line 785 of file nstime.h.

References ns3::Time::m_data.

◆ operator==()

bool ns3::operator== ( const Time lhs,
const Time rhs 
)
inline

Equality operator for Time.

Arithmetic operator.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
true if the two input values are equal.

Definition at line 761 of file nstime.h.

References ns3::Time::m_data.

◆ operator>()

bool ns3::operator> ( const Time lhs,
const Time rhs 
)
inline

Greater than operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
true if the first input value is greater than the second input value.

Definition at line 821 of file nstime.h.

References ns3::Time::m_data.

◆ operator>=()

bool ns3::operator>= ( const Time lhs,
const Time rhs 
)
inline

Greater than or equal operator for Time.

Parameters
[in]lhsThe first value
[in]rhsThe second value
Returns
true if the first input value is greater than or equal to the second input value.

Definition at line 797 of file nstime.h.

References ns3::Time::m_data.

◆ operator>>()

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

Time input streamer.

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

Parameters
[in,out]isThe input stream.
[out]timeThe Time variable to set from the stream data.
Returns
The stream.

Definition at line 435 of file time.cc.

◆ TimeStep()

Time ns3::TimeStep ( uint64_t  ts)
inline
Internal: Scheduler interface
Parameters
[in]tsThe time value, in the current unit.
Returns
A Time.

Definition at line 1119 of file nstime.h.

Referenced by ns3::BuildingListPriv::Add(), ns3::NodeListPriv::Add(), ns3::Application::DoInitialize(), TimeSimpleTestCase::DoRun(), ns3::ThreeGppHttpHeader::GetClientTs(), ns3::NullMessageSimulatorImpl::GetDelayLeft(), ns3::DefaultSimulatorImpl::GetDelayLeft(), ns3::RealtimeSimulatorImpl::GetDelayLeft(), ns3::DistributedSimulatorImpl::GetDelayLeft(), ns3::Timer::GetDelayLeft(), ns3::NullMessageSimulatorImpl::GetMaximumSimulationTime(), ns3::DefaultSimulatorImpl::GetMaximumSimulationTime(), ns3::RealtimeSimulatorImpl::GetMaximumSimulationTime(), ns3::DistributedSimulatorImpl::GetMaximumSimulationTime(), ns3::ThreeGppHttpHeader::GetServerTs(), ns3::SeqTsHeader::GetTs(), ns3::DelayJitterEstimationTimestampTag::GetTxTime(), ns3::Application::GetTypeId(), ns3::NullMessageSimulatorImpl::Next(), ns3::DistributedSimulatorImpl::Next(), ns3::NullMessageSimulatorImpl::Now(), ns3::DefaultSimulatorImpl::Now(), ns3::RealtimeSimulatorImpl::Now(), ns3::DistributedSimulatorImpl::Now(), ns3::SeqTsHeader::Print(), ns3::ThreeGppHttpHeader::Print(), ns3::RealtimeSimulatorImpl::RealtimeNow(), ChannelAccessTestCase::Receive(), AnnexC_TestCase::Receive(), ns3::NullMessageSimulatorImpl::Schedule(), ns3::DefaultSimulatorImpl::Schedule(), ns3::DistributedSimulatorImpl::Schedule(), ns3::NullMessageSimulatorImpl::ScheduleWithContext(), ns3::DefaultSimulatorImpl::ScheduleWithContext(), ns3::TcpSocketBase::Send(), and ns3::Synchronizer::TimeStepToNanosecond().

+ Here is the caller graph for this function: