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

#include <Clock.h>

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

Static Public Member Functions

static dtn::data::Timestamp getUnixTimestamp ()
 
static dtn::data::Timestamp getTime ()
 
static bool isExpired (const dtn::data::Bundle &b)
 
static bool isExpired (const dtn::data::Timestamp &timestamp, const dtn::data::Number &lifetime=0) __attribute__((deprecated))
 
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 dtn::data::Number getLifetime (const dtn::data::BundleID &id, const dtn::data::Timestamp &expiretime)
 
static void settimeofday (struct timeval *tv)
 
static void gettimeofday (struct timeval *tv)
 
static void setOffset (const struct timeval &tv)
 
static struct timeval & getOffset ()
 
static bool isBad ()
 
static void setBad (bool val)
 
static int getTimezone ()
 
static void setTimezone (int val)
 
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 35 of file Clock.h.

Member Function Documentation

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 118 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 123 of file Clock.cpp.

References getTime().

Here is the call graph for this function:

dtn::data::Number dtn::utils::Clock::getLifetime ( const dtn::data::BundleID id,
const dtn::data::Timestamp expiretime 
)
static

Returns the calculated lifetime in seconds based on the BundleID and the expiretime

Definition at line 128 of file Clock.cpp.

Referenced by dtn::routing::operator>>().

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

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

Definition at line 211 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 77 of file Clock.cpp.

Referenced by dtn::daemon::DTNTPWorker::callbackBundleReceived(), dtn::daemon::NativeDaemon::getStats(), dtn::daemon::DTNTPWorker::raiseEvent(), dtn::daemon::Configuration::Security::TLSRequired(), dtn::daemon::DTNTPWorker::update(), 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 265 of file Clock.cpp.

References shouldModifyClock().

Referenced by dtn::daemon::DTNTPWorker::callbackBundleReceived(), getTime(), getUnixTimestamp(), dtn::daemon::DTNTPWorker::raiseEvent(), dtn::data::DTNTime::set(), setOffset(), settimeofday(), and dtn::daemon::DTNTPWorker::TimeSyncMessage::TimeSyncMessage().

Here is the call graph for this function:

int dtn::utils::Clock::getTimezone ( )
static

Specify a timezone offset in hours

Definition at line 67 of file Clock.cpp.

Referenced by getTime(), and getUnixTimestamp().

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

Return the current unix timestamp adjusted by the configured timezone offset

Definition at line 200 of file Clock.cpp.

References gettimeofday(), and getTimezone().

Referenced by dtn::routing::DeliveryPredictabilityMap::age(), getUptime(), dtn::routing::StaticRoutingExtension::notify(), dtn::routing::ProphetRoutingExtension::ProphetRoutingExtension(), and dtn::core::WallClock::timeout().

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 287 of file Clock.cpp.

References getUnixTimestamp().

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

Here is the call graph for this function:

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

If set to true, all time based functions assume a bad clock and try to use other mechanisms to detect expiration.

Returns
True, if the local clock is marked as bad

Definition at line 57 of file Clock.cpp.

Referenced by getExpireTime(), dtn::daemon::Configuration::params(), and dtn::data::PrimaryBlock::relabel().

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

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

Definition at line 161 of file Clock.cpp.

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

Set the bad state of the clock returned by Clock::isBad()

Definition at line 62 of file Clock.cpp.

Referenced by dtn::daemon::Configuration::params().

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

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

Definition at line 95 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 216 of file Clock.cpp.

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

Referenced by dtn::core::BundleCore::raiseEvent().

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 242 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:

void dtn::utils::Clock::setTimezone ( int  val)
static

Set a timezone offset in hours

Definition at line 72 of file Clock.cpp.

Referenced by dtn::core::BundleCore::onConfigurationChanged().

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 90 of file Clock.cpp.

Referenced by 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 111 of file Clock.h.

Referenced by getTime().


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