SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SLNet::CCRakNetSlidingWindow Class Reference

`#include <slikenet/CCRakNetSlidingWindow.h>`

## Public Member Functions

| CCRakNetSlidingWindow ()
| ~CCRakNetSlidingWindow ()
void | Init (CCTimeType curTime, uint32_t maxDatagramPayload)
| Reset all variables to their initial states, for a new connection.
void | Update (CCTimeType curTime, bool hasDataToSendOrResend)
| Update over time.
int | GetRetransmissionBandwidth (CCTimeType curTime, CCTimeType timeSinceLastTick, uint32_t unacknowledgedBytes, bool isContinuousSend)
int | GetTransmissionBandwidth (CCTimeType curTime, CCTimeType timeSinceLastTick, uint32_t unacknowledgedBytes, bool isContinuousSend)
bool | ShouldSendACKs (CCTimeType curTime, CCTimeType estimatedTimeToNextTick)
DatagramSequenceNumberType | GetAndIncrementNextDatagramSequenceNumber (void)
DatagramSequenceNumberType | GetNextDatagramSequenceNumber (void)
void | OnSendBytes (CCTimeType curTime, uint32_t numBytes)
void | OnGotPacketPair (DatagramSequenceNumberType datagramSequenceNumber, uint32_t sizeInBytes, CCTimeType curTime)
| Call this when you get a packet pair.
bool | OnGotPacket (DatagramSequenceNumberType datagramSequenceNumber, bool isContinuousSend, CCTimeType curTime, uint32_t sizeInBytes, uint32_t *skippedMessageCount)
void | OnResend (CCTimeType curTime, SLNet::TimeUS nextActionTime)
void | OnNAK (CCTimeType curTime, DatagramSequenceNumberType nakSequenceNumber)
void | OnAck (CCTimeType curTime, CCTimeType rtt, bool hasBAndAS, BytesPerMicrosecond _B, BytesPerMicrosecond _AS, double totalUserDataBytesAcked, bool isContinuousSend, DatagramSequenceNumberType sequenceNumber)
void | OnDuplicateAck (CCTimeType curTime, DatagramSequenceNumberType sequenceNumber)
void | OnSendAckGetBAndAS (CCTimeType curTime, bool *hasBAndAS, BytesPerMicrosecond *_B, BytesPerMicrosecond *_AS)
void | OnSendAck (CCTimeType curTime, uint32_t numBytes)
void | OnSendNACK (CCTimeType curTime, uint32_t numBytes)
CCTimeType | GetRTOForRetransmission (unsigned char timesSent) const
void | SetMTU (uint32_t bytes)
uint32_t | GetMTU (void) const
| Return what was set by SetMTU()
BytesPerMicrosecond | GetLocalSendRate (void) const
| Query for statistics.
BytesPerMicrosecond | GetLocalReceiveRate (CCTimeType currentTime) const
BytesPerMicrosecond | GetRemoveReceiveRate (void) const
BytesPerMicrosecond | GetEstimatedBandwidth (void) const
double | GetLinkCapacityBytesPerSecond (void) const
double | GetRTT (void) const
| Query for statistics.
bool | GetIsInSlowStart (void) const
uint32_t | GetCWNDLimit (void) const
uint64_t | GetBytesPerSecondLimitByCongestionControl (void) const

## Static Public Member Functions

static bool | GreaterThan (DatagramSequenceNumberType a, DatagramSequenceNumberType b)
| Is a > b, accounting for variable overflow?
static bool | LessThan (DatagramSequenceNumberType a, DatagramSequenceNumberType b)
| Is a < b, accounting for variable overflow?

## Protected Member Functions

CCTimeType | GetSenderRTOForACK (void) const
bool | IsInSlowStart (void) const

## Protected Attributes

uint32_t | MAXIMUM_MTU_INCLUDING_UDP_HEADER
double | cwnd
double | ssThresh
CCTimeType | oldestUnsentAck
DatagramSequenceNumberType | nextDatagramSequenceNumber
| Every outgoing datagram is assigned a sequence number, which increments by 1 every assignment.
DatagramSequenceNumberType | nextCongestionControlBlock
bool | backoffThisBlock
bool | speedUpThisBlock
DatagramSequenceNumberType | expectedNextSequenceNumber
bool | _isContinuousSend
double | lastRtt
double | estimatedRTT
double | deviationRtt

## Detailed Description

Definition at line 86 of file CCRakNetSlidingWindow.h.

## Constructor & Destructor Documentation

SLNet::CCRakNetSlidingWindow::CCRakNetSlidingWindow | ( |  | ) |

SLNet::CCRakNetSlidingWindow::~CCRakNetSlidingWindow | ( |  | ) |

## Member Function Documentation

DatagramSequenceNumberType SLNet::CCRakNetSlidingWindow::GetAndIncrementNextDatagramSequenceNumber | ( | void |  | ) |

Every data packet sent must contain a sequence number Call this function to get it. The sequence number is passed into OnGotPacketPair()

uint64_t SLNet::CCRakNetSlidingWindow::GetBytesPerSecondLimitByCongestionControl | ( | void |  | ) | const

uint32_t SLNet::CCRakNetSlidingWindow::GetCWNDLimit | ( | void |  | ) | const

inline

Definition at line 181 of file CCRakNetSlidingWindow.h.

BytesPerMicrosecond SLNet::CCRakNetSlidingWindow::GetEstimatedBandwidth | ( | void |  | ) | const

inline

Definition at line 174 of file CCRakNetSlidingWindow.h.

References GetLinkCapacityBytesPerSecond().

bool SLNet::CCRakNetSlidingWindow::GetIsInSlowStart | ( | void |  | ) | const

inline

Definition at line 180 of file CCRakNetSlidingWindow.h.

References IsInSlowStart().

double SLNet::CCRakNetSlidingWindow::GetLinkCapacityBytesPerSecond | ( | void |  | ) | const

inline

Definition at line 175 of file CCRakNetSlidingWindow.h.

Referenced by GetEstimatedBandwidth().

BytesPerMicrosecond SLNet::CCRakNetSlidingWindow::GetLocalReceiveRate | ( | CCTimeType | currentTime | ) | const

BytesPerMicrosecond SLNet::CCRakNetSlidingWindow::GetLocalSendRate | ( | void |  | ) | const

inline

Query for statistics.

Definition at line 170 of file CCRakNetSlidingWindow.h.

uint32_t SLNet::CCRakNetSlidingWindow::GetMTU | ( | void |  | ) | const

Return what was set by SetMTU()

DatagramSequenceNumberType SLNet::CCRakNetSlidingWindow::GetNextDatagramSequenceNumber | ( | void |  | ) |

BytesPerMicrosecond SLNet::CCRakNetSlidingWindow::GetRemoveReceiveRate | ( | void |  | ) | const

inline

Definition at line 172 of file CCRakNetSlidingWindow.h.

int SLNet::CCRakNetSlidingWindow::GetRetransmissionBandwidth | ( | CCTimeType | curTime,
|  | CCTimeType | timeSinceLastTick,
|  | uint32_t | unacknowledgedBytes,
|  | bool | isContinuousSend
| ) |  |

CCTimeType SLNet::CCRakNetSlidingWindow::GetRTOForRetransmission | ( | unsigned char | timesSent | ) | const

Retransmission time out for the sender If the time difference between when a message was last transmitted, and the current time is greater than RTO then packet is eligible for retransmission, pending congestion control RTO = (RTT + 4 * RTTVar) + SYN If we have been continuously sending for the last RTO, and no ACK or NAK at all, SND*=2; This is per message, which is different from UDT, but RakNet supports packetloss with continuing data where UDT is only RELIABLE_ORDERED Minimum value is 100 milliseconds

double SLNet::CCRakNetSlidingWindow::GetRTT | ( | void |  | ) | const

Query for statistics.

CCTimeType SLNet::CCRakNetSlidingWindow::GetSenderRTOForACK | ( | void |  | ) | const

protected

int SLNet::CCRakNetSlidingWindow::GetTransmissionBandwidth | ( | CCTimeType | curTime,
|  | CCTimeType | timeSinceLastTick,
|  | uint32_t | unacknowledgedBytes,
|  | bool | isContinuousSend
| ) |  |

static bool SLNet::CCRakNetSlidingWindow::GreaterThan | ( | DatagramSequenceNumberType | a,
|  | DatagramSequenceNumberType | b
| ) |  |

static

Is a > b, accounting for variable overflow?

void SLNet::CCRakNetSlidingWindow::Init | ( | CCTimeType | curTime,
|  | uint32_t | maxDatagramPayload
| ) |  |

Reset all variables to their initial states, for a new connection.

bool SLNet::CCRakNetSlidingWindow::IsInSlowStart | ( | void |  | ) | const

protected

Referenced by GetIsInSlowStart().

static bool SLNet::CCRakNetSlidingWindow::LessThan | ( | DatagramSequenceNumberType | a,
|  | DatagramSequenceNumberType | b
| ) |  |

static

Is a < b, accounting for variable overflow?

void SLNet::CCRakNetSlidingWindow::OnAck | ( | CCTimeType | curTime,
|  | CCTimeType | rtt,
|  | bool | hasBAndAS,
|  | BytesPerMicrosecond | _B,
|  | BytesPerMicrosecond | _AS,
|  | double | totalUserDataBytesAcked,
|  | bool | isContinuousSend,
|  | DatagramSequenceNumberType | sequenceNumber
| ) |  |

Call this when an ACK arrives. hasBAndAS are possibly written with the ack, see OnSendAck() B and AS are used in the calculations in UpdateWindowSizeAndAckOnAckPerSyn B and AS are updated at most once per SYN

void SLNet::CCRakNetSlidingWindow::OnDuplicateAck | ( | CCTimeType | curTime,
|  | DatagramSequenceNumberType | sequenceNumber
| ) |  |

bool SLNet::CCRakNetSlidingWindow::OnGotPacket | ( | DatagramSequenceNumberType | datagramSequenceNumber,
|  | bool | isContinuousSend,
|  | CCTimeType | curTime,
|  | uint32_t | sizeInBytes,
|  | uint32_t * | skippedMessageCount
| ) |  |

Call this when you get a packet (including packet pairs) If the DatagramSequenceNumberType is out of order, skippedMessageCount will be non-zero In that case, send a NAK for every sequence number up to that count

void SLNet::CCRakNetSlidingWindow::OnGotPacketPair | ( | DatagramSequenceNumberType | datagramSequenceNumber,
|  | uint32_t | sizeInBytes,
|  | CCTimeType | curTime
| ) |  |

Call this when you get a packet pair.

void SLNet::CCRakNetSlidingWindow::OnNAK | ( | CCTimeType | curTime,
|  | DatagramSequenceNumberType | nakSequenceNumber
| ) |  |

void SLNet::CCRakNetSlidingWindow::OnResend | ( | CCTimeType | curTime,
|  | SLNet::TimeUS | nextActionTime
| ) |  |

Call when you get a NAK, with the sequence number of the lost message Affects the congestion control

void SLNet::CCRakNetSlidingWindow::OnSendAck | ( | CCTimeType | curTime,
|  | uint32_t | numBytes
| ) |  |

Call when we send an ack, to write B and AS if needed B and AS are only written once per SYN, to prevent slow calculations Also updates SND, the period between sends, since data is written out Be sure to call OnSendAckGetBAndAS() before calling OnSendAck(), since whether you write it or not affects numBytes

void SLNet::CCRakNetSlidingWindow::OnSendAckGetBAndAS | ( | CCTimeType | curTime,
|  | bool * | hasBAndAS,
|  | BytesPerMicrosecond * | _B,
|  | BytesPerMicrosecond * | _AS
| ) |  |

Call when you send an ack, to see if the ack should have the B and AS parameters transmitted Call before calling OnSendAck()

void SLNet::CCRakNetSlidingWindow::OnSendBytes | ( | CCTimeType | curTime,
|  | uint32_t | numBytes
| ) |  |

Call this when you send packets Every 15th and 16th packets should be sent as a packet pair if possible When packets marked as a packet pair arrive, pass to OnGotPacketPair() When any packets arrive, (additionally) pass to OnGotPacket Packets should contain our system time, so we can pass rtt to OnNonDuplicateAck()

void SLNet::CCRakNetSlidingWindow::OnSendNACK | ( | CCTimeType | curTime,
|  | uint32_t | numBytes
| ) |  |

Call when we send a NACK Also updates SND, the period between sends, since data is written out

void SLNet::CCRakNetSlidingWindow::SetMTU | ( | uint32_t | bytes | ) |

Set the maximum amount of data that can be sent in one datagram Default to MAXIMUM_MTU_SIZE-UDP_HEADER_SIZE

bool SLNet::CCRakNetSlidingWindow::ShouldSendACKs | ( | CCTimeType | curTime,
|  | CCTimeType | estimatedTimeToNextTick
| ) |  |

Acks do not have to be sent immediately. Instead, they can be buffered up such that groups of acks are sent at a time This reduces overall bandwidth usage How long they can be buffered depends on the retransmit time of the sender Should call once per update tick, and send if needed

void SLNet::CCRakNetSlidingWindow::Update | ( | CCTimeType | curTime,
|  | bool | hasDataToSendOrResend
| ) |  |

Update over time.

## Member Data Documentation

bool SLNet::CCRakNetSlidingWindow::_isContinuousSend

protected

Definition at line 213 of file CCRakNetSlidingWindow.h.

bool SLNet::CCRakNetSlidingWindow::backoffThisBlock

protected

Definition at line 208 of file CCRakNetSlidingWindow.h.

double SLNet::CCRakNetSlidingWindow::cwnd

protected

Definition at line 196 of file CCRakNetSlidingWindow.h.

double SLNet::CCRakNetSlidingWindow::deviationRtt

protected

Definition at line 217 of file CCRakNetSlidingWindow.h.

double SLNet::CCRakNetSlidingWindow::estimatedRTT

protected

Definition at line 217 of file CCRakNetSlidingWindow.h.

DatagramSequenceNumberType SLNet::CCRakNetSlidingWindow::expectedNextSequenceNumber

protected

Track which datagram sequence numbers have arrived. If a sequence number is skipped, send a NAK for all skipped messages

Definition at line 211 of file CCRakNetSlidingWindow.h.

double SLNet::CCRakNetSlidingWindow::lastRtt

protected

Definition at line 217 of file CCRakNetSlidingWindow.h.

uint32_t SLNet::CCRakNetSlidingWindow::MAXIMUM_MTU_INCLUDING_UDP_HEADER

protected

Definition at line 194 of file CCRakNetSlidingWindow.h.

DatagramSequenceNumberType SLNet::CCRakNetSlidingWindow::nextCongestionControlBlock

protected

Definition at line 207 of file CCRakNetSlidingWindow.h.

DatagramSequenceNumberType SLNet::CCRakNetSlidingWindow::nextDatagramSequenceNumber

protected

Every outgoing datagram is assigned a sequence number, which increments by 1 every assignment.

Definition at line 206 of file CCRakNetSlidingWindow.h.

CCTimeType SLNet::CCRakNetSlidingWindow::oldestUnsentAck

protected

When we get an ack, if oldestUnsentAck==0, set it to the current time When we send out acks, set oldestUnsentAck to 0

Definition at line 201 of file CCRakNetSlidingWindow.h.

bool SLNet::CCRakNetSlidingWindow::speedUpThisBlock

protected

Definition at line 208 of file CCRakNetSlidingWindow.h.

double SLNet::CCRakNetSlidingWindow::ssThresh

protected

Definition at line 197 of file CCRakNetSlidingWindow.h.

The documentation for this class was generated from the following file:

- Source/include/slikenet/CCRakNetSlidingWindow.h