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
Classes | Public Member Functions | List of all members
SLNet::ReliabilityLayer Class Reference

Datagram reliable, ordered, unordered and sequenced sends. Flow control. Message splitting, reassembly, and coalescence. More...

`#include <slikenet/ReliabilityLayer.h>`

## Public Member Functions

| ReliabilityLayer ()
| ~ReliabilityLayer ()
void | Reset (bool resetVariables, int MTUSize, bool _useSecurity)
| Resets the layer for reuse.
void | SetTimeoutTime (SLNet::TimeMS time)
SLNet::TimeMS | GetTimeoutTime (void)
bool | HandleSocketReceiveFromConnectedPlayer (const char *buffer, unsigned int length, SystemAddress &systemAddress, DataStructures::List< PluginInterface2 * > &messageHandlerList, int MTUSize, RakNetSocket2 *s, RakNetRandom *rnr, CCTimeType timeRead, BitStream &updateBitStream)
BitSize_t | Receive (unsigned char **data)
bool | Send (char *data, BitSize_t numberOfBitsToSend, PacketPriority priority, PacketReliability reliability, unsigned char orderingChannel, bool makeDataCopy, int MTUSize, CCTimeType currentTime, uint32_t receipt)
void | Update (RakNetSocket2 *s, SystemAddress &systemAddress, int MTUSize, CCTimeType time, unsigned bitsPerSecondLimit, DataStructures::List< PluginInterface2 * > &messageHandlerList, RakNetRandom *rnr, BitStream &updateBitStream)
bool | IsDeadConnection (void) const
void | KillConnection (void)
| Causes IsDeadConnection to return true.
RakNetStatistics * | GetStatistics (RakNetStatistics *rns)
bool | IsOutgoingDataWaiting (void)
| Are we waiting for any data to be sent out or be processed by the player?
bool | AreAcksWaiting (void)
void | ApplyNetworkSimulator (double _maxSendBPS, SLNet::TimeMS _minExtraPing, SLNet::TimeMS _extraPingVariance)
bool | IsNetworkSimulatorActive (void)
void | SetSplitMessageProgressInterval (int interval)
void | SetUnreliableTimeout (SLNet::TimeMS timeoutMS)
bool | AckTimeout (SLNet::Time curTime)
| Has a lot of time passed since the last ack.
CCTimeType | GetNextSendTime (void) const
CCTimeType | GetTimeBetweenPackets (void) const
SLNet::TimeMS | GetTimeLastDatagramArrived (void) const

## Detailed Description

Datagram reliable, ordered, unordered and sequenced sends. Flow control. Message splitting, reassembly, and coalescence.

Definition at line 122 of file ReliabilityLayer.h.

## Constructor & Destructor Documentation

ReliabilityLayer::ReliabilityLayer | ( |  | ) |

Definition at line 304 of file ReliabilityLayer.cpp.

References INTERNAL_PACKET_PAGE_SIZE.

ReliabilityLayer::~ReliabilityLayer | ( |  | ) |

Definition at line 337 of file ReliabilityLayer.cpp.

## Member Function Documentation

bool ReliabilityLayer::AckTimeout | ( | SLNet::Time | curTime | ) |

Has a lot of time passed since the last ack.

Definition at line 3441 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::RunUpdateCycle().

void ReliabilityLayer::ApplyNetworkSimulator | ( | double | _maxSendBPS,
|  | SLNet::TimeMS | _minExtraPing,
|  | SLNet::TimeMS | _extraPingVariance
| ) |  |

Definition at line 2380 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::Startup().

bool ReliabilityLayer::AreAcksWaiting | ( | void |  | ) |

Definition at line 2375 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::RunUpdateCycle().

CCTimeType ReliabilityLayer::GetNextSendTime | ( | void |  | ) | const

Definition at line 3448 of file ReliabilityLayer.cpp.

RakNetStatistics * ReliabilityLayer::GetStatistics | ( | RakNetStatistics * | rns | ) |

Get Statistics

Returns
  A pointer to a static struct, filled out with current statistical information.

Definition at line 3391 of file ReliabilityLayer.cpp.

References SLNet::RakNetStatistics::BPSLimitByCongestionControl, SLNet::RakNetStatistics::BPSLimitByOutgoingBandwidthLimit, SLNet::GetTimeUS(), SLNet::RakNetStatistics::isLimitedByCongestionControl, SLNet::RakNetStatistics::isLimitedByOutgoingBandwidthLimit, SLNet::RakNetStatistics::packetlossLastSecond, SLNet::RakNetStatistics::packetlossTotal, SLNet::RNS_PER_SECOND_METRICS_COUNT, SLNet::RakNetStatistics::runningTotal, SLNet::USER_MESSAGE_BYTES_RESENT, SLNet::USER_MESSAGE_BYTES_SENT, and SLNet::RakNetStatistics::valueOverLastSecond.

Referenced by SLNet::RakPeer::GetStatistics(), and SLNet::RakPeer::RunUpdateCycle().

CCTimeType ReliabilityLayer::GetTimeBetweenPackets | ( | void |  | ) | const

Definition at line 3453 of file ReliabilityLayer.cpp.

SLNet::TimeMS SLNet::ReliabilityLayer::GetTimeLastDatagramArrived | ( | void |  | ) | const

inline

Definition at line 218 of file ReliabilityLayer.h.

SLNet::TimeMS ReliabilityLayer::GetTimeoutTime | ( | void |  | ) |

Returns the value passed to SetTimeoutTime. or the default if it was never called

Parameters

  [out] | the | value passed to SetTimeoutTime

Definition at line 375 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::GetTimeoutTime(), and SLNet::RakPeer::RunUpdateCycle().

bool ReliabilityLayer::HandleSocketReceiveFromConnectedPlayer | ( | const char * | buffer,
|  | unsigned int | length,
|  | SystemAddress & | systemAddress,
|  | DataStructures::List< PluginInterface2 * > & | messageHandlerList,
|  | int | MTUSize,
|  | RakNetSocket2 * | s,
|  | RakNetRandom * | rnr,
|  | CCTimeType | timeRead,
|  | BitStream & | updateBitStream
| ) |  |

Packets are read directly from the socket layer and skip the reliability layer because unconnected players do not use the reliability layer This function takes packet data after a player has been confirmed as connected.

Parameters

  [in] | buffer | The socket data
  [in] | length | The length of the socket data
  [in] | systemAddress | The player that this data is from
  [in] | messageHandlerList | A list of registered plugins
  [in] | MTUSize | maximum datagram size

Return values

  true | Success
  false | Modified packet

Definition at line 631 of file ReliabilityLayer.cpp.

References _FILE_AND_LINE_, SLNet::ACTUAL_BYTES_RECEIVED, BITS_TO_BYTES, BYTES_TO_BITS, SLNet::InternalPacket::data, SLNet::InternalPacketFixedSizeTransmissionHeader::dataBitLength, DEFAULT_HAS_RECEIVED_PACKET_QUEUE_SIZE, DataStructures::RangeList< range_type >::Deserialize(), SLNet::GetTimeMS(), ID_SND_RECEIPT_ACKED, ID_USER_PACKET_ENUM, if(), SLNet::BitStream::IgnoreBits(), SLNet::InternalPacket::nextActionTime, SLNet::InternalPacketFixedSizeTransmissionHeader::orderingChannel, SLNet::InternalPacketFixedSizeTransmissionHeader::orderingIndex, PRINTF_64_BIT_MODIFIER, DataStructures::List< list_type >::Push(), SLNet::BPSTracker::Push1(), RakAssert, DataStructures::RangeList< range_type >::ranges, SLNet::BitStream::Read(), SLNet::InternalPacketFixedSizeTransmissionHeader::reliability, RELIABLE, RELIABLE_ORDERED, RELIABLE_SEQUENCED, SLNet::InternalPacketFixedSizeTransmissionHeader::reliableMessageNumber, RESEND_BUFFER_ARRAY_MASK, SLNet::InternalPacketFixedSizeTransmissionHeader::sequencingIndex, DataStructures::OrderedList< key_type, data_type, default_comparison_function >::Size(), DataStructures::List< list_type >::Size(), SLNet::InternalPacketFixedSizeTransmissionHeader::splitPacketCount, SLNet::InternalPacketFixedSizeTransmissionHeader::splitPacketId, UNRELIABLE_SEQUENCED, SLNet::USER_MESSAGE_BYTES_RECEIVED_IGNORED, SLNet::USER_MESSAGE_BYTES_RECEIVED_PROCESSED, and SLNet::uint24_t::val.

Referenced by SLNet::ProcessNetworkPacket().

bool ReliabilityLayer::IsDeadConnection | ( | void |  | ) | const

Were you ever unable to deliver a packet despite retries?

Returns
  true means the connection has been lost. Otherwise not.

Definition at line 3374 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::RunUpdateCycle().

bool SLNet::ReliabilityLayer::IsNetworkSimulatorActive | ( | void |  | ) |

Returns if you previously called ApplyNetworkSimulator

Returns
  If you previously called ApplyNetworkSimulator

bool ReliabilityLayer::IsOutgoingDataWaiting | ( | void |  | ) |

Are we waiting for any data to be sent out or be processed by the player?

Definition at line 2358 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::RunUpdateCycle().

void ReliabilityLayer::KillConnection | ( | void |  | ) |

Causes IsDeadConnection to return true.

Definition at line 3382 of file ReliabilityLayer.cpp.

BitSize_t ReliabilityLayer::Receive | ( | unsigned char ** | data | ) |

This allocates bytes and writes a user-level message to those bytes.

Parameters

  [out] | data | The message

Returns
  Returns number of BITS put into the buffer

Definition at line 1523 of file ReliabilityLayer.cpp.

References SLNet::InternalPacket::data, and SLNet::InternalPacketFixedSizeTransmissionHeader::dataBitLength.

Referenced by SLNet::RakPeer::RunUpdateCycle().

void ReliabilityLayer::Reset | ( | bool | resetVariables,
|  | int | MTUSize,
|  | bool | _useSecurity
| ) |  |

Resets the layer for reuse.

Definition at line 344 of file ReliabilityLayer.cpp.

References SLNet::GetTimeUS(), and UDP_HEADER_SIZE.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList(), SLNet::RakPeer::CloseConnectionInternal(), and SLNet::RakPeer::Shutdown().

bool ReliabilityLayer::Send | ( | char * | data,
|  | BitSize_t | numberOfBitsToSend,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | unsigned char | orderingChannel,
|  | bool | makeDataCopy,
|  | int | MTUSize,
|  | CCTimeType | currentTime,
|  | uint32_t | receipt
| ) |  |

Puts data on the send queue

Parameters

  [in] | data | The data to send
  [in] | numberOfBitsToSend | The length of data in bits
  [in] | priority | The priority level for the send
  [in] | reliability | The reliability type for the send
  [in] | orderingChannel | 0 to 31. Specifies what channel to use, for relational ordering and sequencing of packets.
  [in] | makeDataCopy | If true data will be copied. Otherwise, only a pointer will be stored.
  [in] | MTUSize | maximum datagram size
  [in] | currentTime | Current time, as per SLNet::GetTimeMS()
  [in] | receipt | This number will be returned back with ID_SND_RECEIPT_ACKED or ID_SND_RECEIPT_LOSS and is only returned with the reliability types that contain RECEIPT in the name

Returns
  True or false for success or failure.

Definition at line 1555 of file ReliabilityLayer.cpp.

References _FILE_AND_LINE_, BITS_TO_BYTES, BYTES_TO_BITS, SLNet::InternalPacket::creationTime, SLNet::InternalPacket::data, SLNet::InternalPacketFixedSizeTransmissionHeader::dataBitLength, HIGH_PRIORITY, MAXIMUM_MTU_SIZE, SLNet::InternalPacket::messageInternalOrder, SLNet::InternalPacket::messageNumberAssigned, notifyOutOfMemory, NUMBER_OF_RELIABILITIES, SLNet::InternalPacketFixedSizeTransmissionHeader::orderingChannel, SLNet::InternalPacketFixedSizeTransmissionHeader::orderingIndex, SLNet::InternalPacket::priority, SLNet::BPSTracker::Push1(), RakAssert, SLNet::InternalPacketFixedSizeTransmissionHeader::reliability, RELIABLE, RELIABLE_ORDERED, RELIABLE_ORDERED_WITH_ACK_RECEIPT, RELIABLE_SEQUENCED, RELIABLE_WITH_ACK_RECEIPT, SLNet::InternalPacket::sendReceiptSerial, SLNet::InternalPacketFixedSizeTransmissionHeader::sequencingIndex, UNRELIABLE, UNRELIABLE_SEQUENCED, UNRELIABLE_WITH_ACK_RECEIPT, and SLNet::USER_MESSAGE_BYTES_PUSHED.

Referenced by SLNet::RakPeer::SendImmediate().

void ReliabilityLayer::SetSplitMessageProgressInterval | ( | int | interval | ) |

Definition at line 2391 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList().

void ReliabilityLayer::SetTimeoutTime | ( | SLNet::TimeMS | time | ) |

Set the time, in MS, to use before considering ourselves disconnected after not being able to deliver a reliable packet Default time is 10,000 or 10 seconds in release and 30,000 or 30 seconds in debug.

Parameters

  [in] | time | Time, in MS

Definition at line 367 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList(), SLNet::ProcessOfflineNetworkPacket(), and SLNet::RakPeer::SetTimeoutTime().

void ReliabilityLayer::SetUnreliableTimeout | ( | SLNet::TimeMS | timeoutMS | ) |

Definition at line 2396 of file ReliabilityLayer.cpp.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList().

void ReliabilityLayer::Update | ( | RakNetSocket2 * | s,
|  | SystemAddress & | systemAddress,
|  | int | MTUSize,
|  | CCTimeType | time,
|  | unsigned | bitsPerSecondLimit,
|  | DataStructures::List< PluginInterface2 * > & | messageHandlerList,
|  | RakNetRandom * | rnr,
|  | BitStream & | updateBitStream
| ) |  |

Call once per game cycle. Handles internal lists and actually does the send.

Parameters

  [in] | s | the communication end point
  [in] | systemAddress | The Unique Player Identifier who shouldhave sent some packets
  [in] | MTUSize | maximum datagram size
  [in] | time | current system time
  [in] | maxBitsPerSecond | if non-zero, enforces that outgoing bandwidth does not exceed this amount
  [in] | messageHandlerList | A list of registered plugins

Definition at line 1703 of file ReliabilityLayer.cpp.

References _FILE_AND_LINE_, BITS_TO_BYTES, BYTES_TO_BITS, CC_DEBUG_PRINTF_2, CC_TIME_TYPE_BYTES, SLNet::InternalPacket::creationTime, SLNet::RNS2_SendParameters::data, SLNet::InternalPacket::data, SLNet::InternalPacketFixedSizeTransmissionHeader::dataBitLength, SLNet::BitStream::GetNumberOfBytesUsed(), SLNet::GetTimeUS(), SLNet::InternalPacket::headerLength, ID_SND_RECEIPT_LOSS, SLNet::RNS2_SendParameters::length, MAXIMUM_MTU_SIZE, SLNet::InternalPacket::messageNumberAssigned, SLNet::InternalPacket::nextActionTime, SLNet::OP_DELETE(), SLNet::BitStream::PadWithZeroToByteLength(), SLNet::InternalPacket::priority, SLNet::BPSTracker::Push1(), RakAssert, SLNet::InternalPacketFixedSizeTransmissionHeader::reliability, RELIABLE, RELIABLE_ORDERED, RELIABLE_ORDERED_WITH_ACK_RECEIPT, RELIABLE_SEQUENCED, RELIABLE_WITH_ACK_RECEIPT, SLNet::InternalPacketFixedSizeTransmissionHeader::reliableMessageNumber, RESEND_BUFFER_ARRAY_MASK, SLNet::BitStream::Reset(), SLNet::InternalPacket::retransmissionTime, SLNet::RNS_PER_SECOND_METRICS_COUNT, SLNet::InternalPacket::sendReceiptSerial, DataStructures::List< list_type >::Size(), SLNet::RNS2_SendParameters::systemAddress, SLNet::InternalPacket::timesSent, UDP_HEADER_SIZE, UNRELIABLE, UNRELIABLE_SEQUENCED, UNRELIABLE_WITH_ACK_RECEIPT, SLNet::InternalPacket::unreliableNext, SLNet::InternalPacket::unreliablePrev, SLNet::USER_MESSAGE_BYTES_RESENT, SLNet::USER_MESSAGE_BYTES_SENT, and SLNet::uint24_t::val.

Referenced by SLNet::RakPeer::RunUpdateCycle().

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

- Source/include/slikenet/ReliabilityLayer.h
- Source/src/ReliabilityLayer.cpp