IBR-DTNSuite  0.12
dtn::utils::Clock Class Reference

#include <Clock.h>

Collaboration diagram for dtn::utils::Clock:
Collaboration graph

Static Public Member Functions

static dtn::data::Timestamp getMonotonicTimestamp ()
 
static dtn::data::Timestamp getTime ()
 
static bool isExpired (const dtn::data::Timestamp &timestamp, const dtn::data::Number &lifetime)
 
static bool isExpired (const dtn::data::Bundle &b)
 
static bool isExpired (const dtn::data::MetaBundle &m)
 
static dtn::data::Timestamp getExpireTime (const dtn::data::Bundle &b)
 
static dtn::data::Timestamp getExpireTime (const dtn::data::Timestamp &timestamp, const dtn::data::Number &lifetime) __attribute__((deprecated))
 
static dtn::data::Timestamp getExpireTime (const dtn::data::Number &lifetime)
 
static void settimeofday (struct timeval *tv)
 
static void gettimeofday (struct timeval *tv)
 
static void getdtntimeofday (struct timeval *tv)
 
static void setOffset (const struct timeval &tv)
 
static struct timeval & getOffset ()
 
static double getRating ()
 
static void setRating (double val)
 
static bool shouldModifyClock ()
 
static void setModifyClock (bool val)
 
static double toDouble (const timeval &val)
 
static dtn::data::Timestamp getUptime ()
 

Static Public Attributes

static const dtn::data::Timestamp TIMEVAL_CONVERSION = 946684800
 

Detailed Description

Definition at line 71 of file Clock.h.

Member Function Documentation

void dtn::utils::Clock::getdtntimeofday ( struct timeval *  tv)
static

Get the time of the day like ::gettimeofday(), but correct the value by the known clock offset and the bundle protocol time offset.

Parameters
tv

Definition at line 249 of file Clock.cpp.

References dtn::data::SDNV< E >::get(), gettimeofday(), shouldModifyClock(), and TIMEVAL_CONVERSION.

Referenced by getTime(), and dtn::data::DTNTime::set().

Here is the call graph for this function:

dtn::data::Timestamp dtn::utils::Clock::getExpireTime ( const dtn::data::Timestamp timestamp,
const dtn::data::Number lifetime 
)
static

This method is deprecated because it does not recognize the AgeBlock as alternative age verification.

Definition at line 103 of file Clock.cpp.

dtn::data::Timestamp dtn::utils::Clock::getExpireTime ( const dtn::data::Number lifetime)
static

Returns the timestamp when this lifetime is going to be expired depending on the current knowledge of time.

Parameters
lifetimeThe lifetime in seconds.
Returns
A DTN timestamp.

Definition at line 108 of file Clock.cpp.

References getTime().

Here is the call graph for this function:

struct timeval & dtn::utils::Clock::getOffset ( )
static

Returns the local offset of the clock (prior set by setOffset)

Definition at line 171 of file Clock.cpp.

Referenced by dtn::daemon::NativeDaemon::getStats().

double dtn::utils::Clock::getRating ( )
static

Defines an estimation about the precision of the local time. If the clock is definitely wrong the value is zero and one when we have a perfect time sync. Everything between one and zero gives an abstract knowledge about the rating of the local clock.

Definition at line 59 of file Clock.cpp.

Referenced by dtn::daemon::DTNTPWorker::callbackBundleReceived(), dtn::daemon::NativeDaemon::getStats(), isExpired(), dtn::daemon::DTNTPWorker::onUpdateBeacon(), dtn::daemon::DTNTPWorker::raiseEvent(), dtn::data::PrimaryBlock::relabel(), dtn::daemon::Configuration::Security::TLSRequired(), and dtn::core::BundleCore::validate().

void dtn::utils::Clock::gettimeofday ( struct timeval *  tv)
static

Get the time of the day like ::gettimeofday(), but correct the value by the known clock offset.

Parameters
tv

Definition at line 230 of file Clock.cpp.

References shouldModifyClock().

Referenced by dtn::daemon::DTNTPWorker::callbackBundleReceived(), getdtntimeofday(), setOffset(), settimeofday(), and dtn::daemon::DTNTPWorker::TimeSyncMessage::TimeSyncMessage().

Here is the call graph for this function:

dtn::data::Timestamp dtn::utils::Clock::getUptime ( )
static

Return the seconds since the last start-up

Definition at line 283 of file Clock.cpp.

References getMonotonicTimestamp().

Referenced by dtn::daemon::NativeDaemon::getStats().

Here is the call graph for this function:

bool dtn::utils::Clock::isExpired ( const dtn::data::Timestamp timestamp,
const dtn::data::Number lifetime 
)
static

Check if a timestamp is expired

Returns
True if the timestamp is expired

Definition at line 146 of file Clock.cpp.

References getRating(), and getTime().

Referenced by dtn::storage::MemoryBundleStorage::get(), dtn::storage::SimpleBundleStorage::get(), isExpired(), and dtn::core::BundleCore::validate().

Here is the call graph for this function:

bool dtn::utils::Clock::isExpired ( const dtn::data::Bundle b)
static

Check if a bundle is expired

Returns
True if the bundle is expired

Definition at line 121 of file Clock.cpp.

References dtn::data::Bundle::find(), dtn::data::AgeBlock::getSeconds(), isExpired(), dtn::data::PrimaryBlock::lifetime, and dtn::data::BundleID::timestamp.

Here is the call graph for this function:

bool dtn::utils::Clock::isExpired ( const dtn::data::MetaBundle m)
static

Check if a meta bundle is expired

Returns
True if the meta bundle is expired

Definition at line 138 of file Clock.cpp.

References dtn::data::MetaBundle::expiretime, and getTime().

Here is the call graph for this function:

void dtn::utils::Clock::setModifyClock ( bool  val)
static

Set the clock modification parameter returned by Clock::shouldModifyClock()

Definition at line 77 of file Clock.cpp.

Referenced by dtn::daemon::Configuration::TimeSync::load().

void dtn::utils::Clock::setOffset ( const struct timeval &  tv)
static

set the local offset of the clock

Parameters
tv

Definition at line 176 of file Clock.cpp.

References gettimeofday(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::LogLevel::info, settimeofday(), shouldModifyClock(), and toDouble().

Here is the call graph for this function:

void dtn::utils::Clock::setRating ( double  val)
static
void dtn::utils::Clock::settimeofday ( struct timeval *  tv)
static

Tells the internal clock the offset to the common network time.

Definition at line 205 of file Clock.cpp.

References gettimeofday(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::LogLevel::info, shouldModifyClock(), and toDouble().

Referenced by setOffset().

Here is the call graph for this function:

bool dtn::utils::Clock::shouldModifyClock ( )
static

if set to true, the function settimeofday() and setOffset() will modify the clock of the host instead of storing the local offset.

Definition at line 72 of file Clock.cpp.

Referenced by getdtntimeofday(), gettimeofday(), setOffset(), and settimeofday().

double dtn::utils::Clock::toDouble ( const timeval &  val)
static

Member Data Documentation

const dtn::data::Timestamp dtn::utils::Clock::TIMEVAL_CONVERSION = 946684800
static

The number of seconds between 1/1/1970 and 1/1/2000.

Definition at line 154 of file Clock.h.

Referenced by getdtntimeofday().


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