RTP Trace System  1.0
Coral::TrafficShaper Class Reference

Traffic Shaper. More...

#include <trafficshaper.h>

Inheritance diagram for Coral::TrafficShaper:
Coral::Synchronizable

List of all members.

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< TrafficShaperPacketQueue
SocketSenderSocket
card64 SendTimeStamp
card64 Bandwidth
double BufferDelay
integer LastError
cardinal LastSeqNum

Static Private Attributes

static TrafficShaperSingleton Singleton

Friends

class TrafficShaperSingleton

Detailed Description

Traffic Shaper.

This class is a traffic shaper.

Author:
Thomas Dreibholz
Version:
1.0

Member Enumeration Documentation

Enumerator:
TSC_Write 
TSC_Send 
TSC_SendTo 

Constructor & Destructor Documentation

Constructor.


Member Function Documentation

ssize_t Coral::TrafficShaper::addPacket ( const void *  data,
const cardinal  bytes,
const cardinal  seqNum,
InternetFlow destination,
const cardinal  flags,
const cardinal  command 
) [private]

Flush buffer.

Get bandwidth for following packets.

Returns:
Bandwidth.
double Coral::TrafficShaper::getBufferDelay ( ) const [inline]

Get maximum buffer delay for following packets.

Returns:
Maximum buffer delay in microseconds.

Get sequence number of last packet sent.

Returns:
Sequence number.
void Coral::TrafficShaper::init ( Socket socket)

Initialize.

Parameters:
socketSocket.
bool Coral::TrafficShaper::refreshBuffer ( const card8  trafficClass,
const bool  doRemapping 
)

Adapt buffer's contents to changed bandwidth and delay settings.

Parameters:
trafficClassTraffic class to remap packets to.
doRemappingtrue, to do traffic class remapping; false otherwise.
Returns:
true, if buffer flush has been necessary; 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!

Parameters:
bufferBuffer with data to send.
lengthLength of data to send.
seqNumPacket's sequence number (-1 for none).
flagsFlags for sendto().
trafficClassTraffic class for packet.
Returns:
Bytes sent or error code < 0.
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.

Parameters:
bufferBuffer with data to send.
lengthLength of data to send.
seqNumPacket's sequence number (-1 for none).
flagsFlags for sendto().
receiverAddress of receiver.
Returns:
Bytes sent or error code < 0.
void Coral::TrafficShaper::setBandwidth ( const card64  bandwidth) [inline]

Set bandwidth for following packets.

Parameters:
bandwidthBandwidth.
void Coral::TrafficShaper::setBufferDelay ( const double  bufferDelay) [inline]

Set maximum buffer delay for following packets.

Parameters:
bufferDelayMaximum buffer delay in microseconds.
void Coral::TrafficShaper::setSocket ( Socket socket) [inline]

Set socket to send shaped traffic to.

Parameters:
socketSocket.
ssize_t Coral::TrafficShaper::write ( const void *  buffer,
const size_t  length,
const cardinal  seqNum 
)

Wrapper for write().

Parameters:
bufferBuffer with data to write
lengthLength of data to write
seqNumPacket's sequence number (-1 for none).
Returns:
Bytes sent or error code < 0.

Friends And Related Function Documentation

friend class TrafficShaperSingleton [friend]

Member Data Documentation


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