RTP Trace System
1.0
|
Round Trip Time Pinger. More...
#include <roundtriptimepinger.h>
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 | |
Socket * | Ping4Socket |
Socket * | Ping6Socket |
double | RoundTripTimeAlpha |
multiset< PingerHost > | HostSet |
card64 | GPHeaderTimeStamp |
bool | Ready |
bool | Logger |
ostream * | LoggerScriptStream |
ostream * | LoggerDataStream |
card64 | MaxPingDelay |
Randomizer | Random |
Friends | |
ostream & | operator<< (ostream &os, RoundTripTimePinger &pinger) |
Round Trip Time Pinger.
This class implements a round trip time pinger.
Coral::RoundTripTimePinger::RoundTripTimePinger | ( | Socket * | ping4socket, |
Socket * | ping6socket, | ||
const card64 | delay = 1000000 |
||
) |
Destructor.
void Coral::RoundTripTimePinger::activateLogger | ( | ostream * | scriptStream, |
ostream * | dataStream, | ||
const char * | dataName | ||
) |
Activate logger. Very important: Logging will be deactivated by addHost() and removeHost() calls!
scriptStream | Script output stream. |
dataStream | Data output stream. |
dataName | Data file name (for GNUplot's plot command). |
bool Coral::RoundTripTimePinger::addHost | ( | const InternetAddress & | address, |
const card8 | trafficClass = 0x00 |
||
) |
Add host to RoundTripTimePinger list.
address | Host address. |
trafficClass | Traffic class. |
void Coral::RoundTripTimePinger::calculateRoundTripTime | ( | const InternetAddress & | address, |
const card8 | trafficClass, | ||
const card64 | sendTime, | ||
const card64 | arrivalTime | ||
) | [private] |
void Coral::RoundTripTimePinger::checkUnreachable | ( | PingerHost & | host | ) | [private] |
Deactivate logger.
double Coral::RoundTripTimePinger::getAlpha | ( | ) | [inline] |
Get constant alpha: RTT = alpha * oldValue + (1 - alpha) * newValue.
cardinal Coral::RoundTripTimePinger::getHosts | ( | ) | [inline] |
Get number of hosts in RoundTripTimePinger.
card64 Coral::RoundTripTimePinger::getMaxPingDelay | ( | ) | [inline] |
Get maximum delay between two pings in microseconds.
cardinal Coral::RoundTripTimePinger::getRoundTripTime | ( | const InternetAddress & | address, |
const card8 | trafficClass = 0x00 |
||
) |
Get round trip time for given host and traffic class.
trafficClass | Traffic class. |
bool Coral::RoundTripTimePinger::isLogging | ( | ) | const [inline] |
Check, if logger is running.
bool Coral::RoundTripTimePinger::ready | ( | ) | const [inline] |
Check, if RoundTripTimePinger is ready.
bool Coral::RoundTripTimePinger::receiveEcho4 | ( | ) | [private] |
bool Coral::RoundTripTimePinger::receiveEcho6 | ( | ) | [private] |
void Coral::RoundTripTimePinger::removeHost | ( | const InternetAddress & | address, |
const card8 | trafficClass = 0x00 |
||
) |
Remove host from RoundTripTimePinger list.
address | Host address. |
trafficClass | Traffic 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.
alpha | Alpha. |
void Coral::RoundTripTimePinger::setMaxPingDelay | ( | const card64 | delay | ) | [inline] |
Set maximum delay between two pings in microseconds.
delay | Delay 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.
void Coral::RoundTripTimePinger::writeGPData | ( | ostream & | os | ) |
Write GNUplot data line.
os | Output 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()!
os | Output stream. |
dataName | Name of data file. |
lineStyle | First GNUplot line style or 0 for using GNUplot's defaults. |
ostream& operator<< | ( | ostream & | os, |
RoundTripTimePinger & | pinger | ||
) | [friend] |
Friend output operator.
multiset<PingerHost> Coral::RoundTripTimePinger::HostSet [private] |
bool Coral::RoundTripTimePinger::Logger [private] |
ostream* Coral::RoundTripTimePinger::LoggerDataStream [private] |
ostream* Coral::RoundTripTimePinger::LoggerScriptStream [private] |
const cardinal Coral::RoundTripTimePinger::MaxRoundTripTime = 180000000 [static] |
Maximum round trip time in microseconds.
const card64 Coral::RoundTripTimePinger::MinUnreachableAsumption = 2500000 [static] |
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).
Socket* Coral::RoundTripTimePinger::Ping4Socket [private] |
Socket* Coral::RoundTripTimePinger::Ping6Socket [private] |
Randomizer Coral::RoundTripTimePinger::Random [private] |
bool Coral::RoundTripTimePinger::Ready [private] |
double Coral::RoundTripTimePinger::RoundTripTimeAlpha [private] |
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).