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