class TrafficShaper

Traffic Shaper. More...

Full nameCoral::TrafficShaper
Definition#include <trafficshaper.h>
InheritsCoral::Synchronizable
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members


Detailed Description

This class is a traffic shaper.

TrafficShaper ()

Constructor.

TrafficShaper (Socket* socket)

Constructor.

~TrafficShaper ()

Destructor.

void init (Socket* socket)

Initialize.

Parameters:
socketSocket.

inline void setSocket (Socket* socket)

Set socket to send shaped traffic to.

Parameters:
socketSocket.

inline card64 getBandwidth ()
[const]

Get bandwidth for following packets.

Returns: Bandwidth.

inline void setBandwidth (const card64 bandwidth)

Set bandwidth for following packets.

Parameters:
bandwidthBandwidth.

inline double getBufferDelay ()
[const]

Get maximum buffer delay for following packets.

Returns: Maximum buffer delay in microseconds.

inline void setBufferDelay (const double bufferDelay)

Set maximum buffer delay for following packets.

Parameters:
bufferDelayMaximum buffer delay in microseconds.

void flush ()

Flush buffer.

bool 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.

inline cardinal getLastSeqNum ()
[const]

Get sequence number of last packet sent.

Returns: Sequence number.

ssize_t 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.

ssize_t 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.

ssize_t 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.