|
|
This class is a traffic shaper.
TrafficShaper () |
Constructor.
TrafficShaper (Socket* socket) |
Constructor.
~TrafficShaper () |
Destructor.
void init (Socket* socket) |
Initialize.
Parameters:
socket | Socket. |
inline void setSocket (Socket* socket) |
Set socket to send shaped traffic to.
Parameters:
socket | Socket. |
inline card64 getBandwidth () |
Get bandwidth for following packets.
Returns: Bandwidth.
inline void setBandwidth (const card64 bandwidth) |
Set bandwidth for following packets.
Parameters:
bandwidth | Bandwidth. |
inline double getBufferDelay () |
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:
bufferDelay | Maximum 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:
trafficClass | Traffic class to remap packets to. |
doRemapping | true, to do traffic class remapping; false otherwise. |
Returns: true, if buffer flush has been necessary; false otherwise.
inline cardinal getLastSeqNum () |
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:
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. |
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:
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. |
Returns: Bytes sent or error code < 0.
ssize_t write (const void* buffer, const size_t length, const cardinal seqNum) |
Wrapper for write().
Parameters:
buffer | Buffer with data to write |
length | Length of data to write |
seqNum | Packet's sequence number (-1 for none). |
Returns: Bytes sent or error code < 0.