RTP Trace System
1.0
|
Traffic Shaper. More...
#include <trafficshaper.h>
Classes | |
struct | TrafficShaperPacket |
Public Member Functions | |
TrafficShaper () | |
TrafficShaper (Socket *socket) | |
~TrafficShaper () | |
void | init (Socket *socket) |
void | setSocket (Socket *socket) |
card64 | getBandwidth () const |
void | setBandwidth (const card64 bandwidth) |
double | getBufferDelay () const |
void | setBufferDelay (const double bufferDelay) |
void | flush () |
bool | refreshBuffer (const card8 trafficClass, const bool doRemapping) |
cardinal | getLastSeqNum () const |
ssize_t | sendTo (const void *buffer, const size_t length, const cardinal seqNum, const cardinal flags, const InternetFlow &receiver, const card8 trafficClass=0) |
ssize_t | send (const void *buffer, const size_t length, const cardinal seqNum, const cardinal flags=0, const card8 trafficClass=0) |
ssize_t | write (const void *buffer, const size_t length, const cardinal seqNum) |
Private Types | |
enum | TrafficShaperCommand { TSC_Write = 0, TSC_Send = 1, TSC_SendTo = 2 } |
Private Member Functions | |
void | sendAll () |
ssize_t | addPacket (const void *data, const cardinal bytes, const cardinal seqNum, InternetFlow &destination, const cardinal flags, const cardinal command) |
Private Attributes | |
deque< TrafficShaperPacket > | Queue |
Socket * | SenderSocket |
card64 | SendTimeStamp |
card64 | Bandwidth |
double | BufferDelay |
integer | LastError |
cardinal | LastSeqNum |
Static Private Attributes | |
static TrafficShaperSingleton | Singleton |
Friends | |
class | TrafficShaperSingleton |
Traffic Shaper.
This class is a traffic shaper.
enum Coral::TrafficShaper::TrafficShaperCommand [private] |
Constructor.
Coral::TrafficShaper::TrafficShaper | ( | Socket * | socket | ) |
Constructor.
Destructor.
ssize_t Coral::TrafficShaper::addPacket | ( | const void * | data, |
const cardinal | bytes, | ||
const cardinal | seqNum, | ||
InternetFlow & | destination, | ||
const cardinal | flags, | ||
const cardinal | command | ||
) | [private] |
void Coral::TrafficShaper::flush | ( | ) |
Flush buffer.
card64 Coral::TrafficShaper::getBandwidth | ( | ) | const [inline] |
Get bandwidth for following packets.
double Coral::TrafficShaper::getBufferDelay | ( | ) | const [inline] |
Get maximum buffer delay for following packets.
cardinal Coral::TrafficShaper::getLastSeqNum | ( | ) | const [inline] |
Get sequence number of last packet sent.
void Coral::TrafficShaper::init | ( | Socket * | socket | ) |
Initialize.
socket | Socket. |
bool Coral::TrafficShaper::refreshBuffer | ( | const card8 | trafficClass, |
const bool | doRemapping | ||
) |
Adapt buffer's contents to changed bandwidth and delay settings.
trafficClass | Traffic class to remap packets to. |
doRemapping | true, to do traffic class remapping; false otherwise. |
ssize_t Coral::TrafficShaper::send | ( | const void * | buffer, |
const size_t | length, | ||
const cardinal | seqNum, | ||
const cardinal | flags = 0 , |
||
const card8 | trafficClass = 0 |
||
) |
Wrapper for send(). send() will set the packet's traffic class, if trafficClass is not 0. In this case, the packet will be sent by sendto() to the destination address, the socket is connected to!
buffer | Buffer with data to send. |
length | Length of data to send. |
seqNum | Packet's sequence number (-1 for none). |
flags | Flags for sendto(). |
trafficClass | Traffic class for packet. |
void Coral::TrafficShaper::sendAll | ( | ) | [private] |
ssize_t Coral::TrafficShaper::sendTo | ( | const void * | buffer, |
const size_t | length, | ||
const cardinal | seqNum, | ||
const cardinal | flags, | ||
const InternetFlow & | receiver, | ||
const card8 | trafficClass = 0 |
||
) |
Wrapper for sendto(). sendto() will set the packet's traffic class, if trafficClass is not 0.
buffer | Buffer with data to send. |
length | Length of data to send. |
seqNum | Packet's sequence number (-1 for none). |
flags | Flags for sendto(). |
receiver | Address of receiver. |
void Coral::TrafficShaper::setBandwidth | ( | const card64 | bandwidth | ) | [inline] |
Set bandwidth for following packets.
bandwidth | Bandwidth. |
void Coral::TrafficShaper::setBufferDelay | ( | const double | bufferDelay | ) | [inline] |
Set maximum buffer delay for following packets.
bufferDelay | Maximum buffer delay in microseconds. |
void Coral::TrafficShaper::setSocket | ( | Socket * | socket | ) | [inline] |
Set socket to send shaped traffic to.
socket | Socket. |
ssize_t Coral::TrafficShaper::write | ( | const void * | buffer, |
const size_t | length, | ||
const cardinal | seqNum | ||
) |
Wrapper for write().
buffer | Buffer with data to write |
length | Length of data to write |
seqNum | Packet's sequence number (-1 for none). |
friend class TrafficShaperSingleton [friend] |
card64 Coral::TrafficShaper::Bandwidth [private] |
double Coral::TrafficShaper::BufferDelay [private] |
integer Coral::TrafficShaper::LastError [private] |
cardinal Coral::TrafficShaper::LastSeqNum [private] |
deque<TrafficShaperPacket> Coral::TrafficShaper::Queue [private] |
Socket* Coral::TrafficShaper::SenderSocket [private] |
card64 Coral::TrafficShaper::SendTimeStamp [private] |
TrafficShaperSingleton Coral::TrafficShaper::Singleton [static, private] |