RTP Trace System  1.0
Coral::RoundTripTimePinger Class Reference

Round Trip Time Pinger. More...

#include <roundtriptimepinger.h>

Inheritance diagram for Coral::RoundTripTimePinger:
Coral::TimedThread Coral::Thread Coral::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 (ostream *scriptStream, ostream *dataStream, const char *dataName)
void deactivateLogger ()
bool isLogging () const
void writeGPHeader (ostream &os, const char *dataName, const cardinal lineStyle=1)
void writeGPData (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 RoundTripTimePinger::calculateChecksum (const card16 *addr, const cardinal length, card16 csum)
card64 RoundTripTimePinger::sendPing4 (const InternetAddress &destination, const card8 trafficClass, const card16 sequenceNumber)
card64 RoundTripTimePinger::sendPing6 (const InternetAddress &destination, const card8 trafficClass, const card16 sequenceNumber)
bool receiveEcho4 ()
bool receiveEcho6 ()
void checkUnreachable (PingerHost &host)

Private Attributes

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

Friends

ostream & operator<< (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

Coral::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 Coral::RoundTripTimePinger::activateLogger ( ostream *  scriptStream,
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 Coral::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).
void Coral::RoundTripTimePinger::calculateRoundTripTime ( const InternetAddress address,
const card8  trafficClass,
const card64  sendTime,
const card64  arrivalTime 
) [private]

Deactivate logger.

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 Coral::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 Coral::RoundTripTimePinger::isLogging ( ) const [inline]

Check, if logger is running.

bool Coral::RoundTripTimePinger::ready ( ) const [inline]

Check, if RoundTripTimePinger is ready.

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

Remove host from RoundTripTimePinger list.

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

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

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

Set maximum delay between two pings in microseconds.

Parameters:
delayDelay in microseconds.
void Coral::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 Coral::TimedThread.

Write GNUplot data line.

Parameters:
osOutput stream.
void Coral::RoundTripTimePinger::writeGPHeader ( 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

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

Friend output operator.


Member Data Documentation

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