RTP Audio System  2.0.0
RoundTripTimePinger Class Reference

Round Trip Time Pinger. More...

#include <roundtriptimepinger.h>

Inheritance diagram for RoundTripTimePinger:
TimedThread MultiTimerThread< Timers > Thread Synchronizable

List of all members.

Classes

struct  Ping4Packet
struct  Ping6Packet

Public Member Functions

 RoundTripTimePinger (Socket *ping4socket, Socket *ping6socket, const card64 delay=1000000)
 ~RoundTripTimePinger ()
bool ready () const
cardinal getHosts ()
double getAlpha ()
void setAlpha (const double alpha)
card64 getMaxPingDelay ()
void setMaxPingDelay (const card64 delay)
cardinal getRoundTripTime (const InternetAddress &address, const card8 trafficClass=0x00)
bool addHost (const InternetAddress &address, const card8 trafficClass=0x00)
void removeHost (const InternetAddress &address, const card8 trafficClass=0x00)
void activateLogger (std::ostream *scriptStream, std::ostream *dataStream, const char *dataName)
void deactivateLogger ()
bool isLogging () const
void writeGPHeader (std::ostream &os, const char *dataName, const cardinal lineStyle=1)
void writeGPData (std::ostream &os)

Static Public Attributes

static const cardinal MaxRoundTripTime = 180000000
static const double UnreachableFactor = 2.0
static const card64 MinUnreachableAsumption = 2500000

Private Member Functions

void timerEvent ()
void calculateRoundTripTime (const InternetAddress &address, const card8 trafficClass, const card64 sendTime, const card64 arrivalTime)
card16 calculateChecksum (const card16 *addr, const cardinal length, card16 csum)
card64 sendPing4 (const InternetAddress &destination, const card8 trafficClass, const card16 sequenceNumber)
card64 sendPing6 (const InternetAddress &destination, const card8 trafficClass, const card16 sequenceNumber)
bool receiveEcho4 ()
bool receiveEcho6 ()
void checkUnreachable (PingerHost &host)

Private Attributes

SocketPing4Socket
SocketPing6Socket
double RoundTripTimeAlpha
std::multiset< PingerHostHostSet
card64 GPHeaderTimeStamp
bool Ready
bool Logger
std::ostream * LoggerScriptStream
std::ostream * LoggerDataStream
card64 MaxPingDelay
Randomizer Random

Friends

std::ostream & operator<< (std::ostream &os, RoundTripTimePinger &pinger)

Detailed Description

Round Trip Time Pinger.

This class implements a round trip time pinger.

Author:
Thomas Dreibholz
Version:
1.0

Constructor & Destructor Documentation

RoundTripTimePinger::RoundTripTimePinger ( Socket ping4socket,
Socket ping6socket,
const card64  delay = 1000000 
)

Constructor.

Parameters:
ping4socketSocket for IPv4 pings.
ping6socketSocket for IPv6 pings.
delayMaximum delay between two pings in microseconds.

Member Function Documentation

void RoundTripTimePinger::activateLogger ( std::ostream *  scriptStream,
std::ostream *  dataStream,
const char *  dataName 
)

Activate logger. Very important: Logging will be deactivated by addHost() and removeHost() calls!

Parameters:
scriptStreamScript output stream.
dataStreamData output stream.
dataNameData file name (for GNUplot's plot command).
bool RoundTripTimePinger::addHost ( const InternetAddress address,
const card8  trafficClass = 0x00 
)

Add host to RoundTripTimePinger list.

Parameters:
addressHost address.
trafficClassTraffic class.
Returns:
true, if host has been added; false otherwise (duplicate).
card16 RoundTripTimePinger::calculateChecksum ( const card16 addr,
const cardinal  length,
card16  csum 
) [private]
void RoundTripTimePinger::calculateRoundTripTime ( const InternetAddress address,
const card8  trafficClass,
const card64  sendTime,
const card64  arrivalTime 
) [private]

Deactivate logger.

double RoundTripTimePinger::getAlpha ( ) [inline]

Get constant alpha: RTT = alpha * oldValue + (1 - alpha) * newValue.

Returns:
alpha.

Get number of hosts in RoundTripTimePinger.

Returns:
Number of hosts.

Get maximum delay between two pings in microseconds.

Returns:
Delay in microseconds.
cardinal RoundTripTimePinger::getRoundTripTime ( const InternetAddress address,
const card8  trafficClass = 0x00 
)

Get round trip time for given host and traffic class.

Parameters:
trafficClassTraffic class.
Returns:
Round trip time in microseconds; -1 for hosts not in list or unreachable.
bool RoundTripTimePinger::isLogging ( ) const [inline]

Check, if logger is running.

bool RoundTripTimePinger::ready ( ) const [inline]

Check, if RoundTripTimePinger is ready.

Returns:
true, if RoundTripTimePinger is ready; false otherwise.
void RoundTripTimePinger::removeHost ( const InternetAddress address,
const card8  trafficClass = 0x00 
)

Remove host from RoundTripTimePinger list.

Parameters:
addressHost address.
trafficClassTraffic class.
card64 RoundTripTimePinger::sendPing4 ( const InternetAddress destination,
const card8  trafficClass,
const card16  sequenceNumber 
) [private]
card64 RoundTripTimePinger::sendPing6 ( const InternetAddress destination,
const card8  trafficClass,
const card16  sequenceNumber 
) [private]
void RoundTripTimePinger::setAlpha ( const double  alpha) [inline]

Set constant alpha: RTT = alpha * oldValue + (1 - alpha) * newValue.

Parameters:
alphaAlpha.
void RoundTripTimePinger::setMaxPingDelay ( const card64  delay) [inline]

Set maximum delay between two pings in microseconds.

Parameters:
delayDelay in microseconds.
void RoundTripTimePinger::timerEvent ( ) [private, virtual]

The virtual timerEvent() method, which contains the timed thread's implementation. It has to be implemented by classes, which inherit TimedThread. This method is called regularly with the given interval.

Implements TimedThread.

void RoundTripTimePinger::writeGPData ( std::ostream &  os)

Write GNUplot data line.

Parameters:
osOutput stream.
void RoundTripTimePinger::writeGPHeader ( std::ostream &  os,
const char *  dataName,
const cardinal  lineStyle = 1 
)

Write GNUplot header. Very important: This header will become invalid when calling addHost() or removeHost()!

Parameters:
osOutput stream.
dataNameName of data file.
lineStyleFirst GNUplot line style or 0 for using GNUplot's defaults.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
RoundTripTimePinger pinger 
) [friend]

Friend output operator.


Member Data Documentation

std::multiset<PingerHost> RoundTripTimePinger::HostSet [private]
std::ostream* RoundTripTimePinger::LoggerDataStream [private]
std::ostream* RoundTripTimePinger::LoggerScriptStream [private]
const cardinal RoundTripTimePinger::MaxRoundTripTime = 180000000 [static]

Maximum round trip time in microseconds.

MinUnreachableAsumption: Assume current round trip time to be diff = now - host.LastEchoTimeStamp, if diff > MinUnreachableAsumption (for OS delay) or diff > UnreachableFactor * MaxRawRoundTripTime (for real network delay).

const double RoundTripTimePinger::UnreachableFactor = 2.0 [static]

Unreachable Factor: Assume current round trip time to be diff = now - host.LastEchoTimeStamp, if diff > MinUnreachableAsumption (for OS delay) or diff > UnreachableFactor * MaxRawRoundTripTime (for real network delay).


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines