Struct ReliableUtility
Utility methods and types for the reliable pipeline stage.
Syntax
public struct ReliableUtility
Fields
DefaultMinimumResendTime
The least amount of time we'll wait until a packet resend is performed.
Declaration
public const int DefaultMinimumResendTime = 64
Field Value
MaximumResendTime
The maximum amount of time we'll wait to resend a packet.
Declaration
public const int MaximumResendTime = 200
Field Value
NullEntry
Internal value. Do not use.
Declaration
public const int NullEntry = -1
Field Value
Methods
CalculateProcessingTime(Byte*, UInt16, Int64)
Declaration
public static ushort CalculateProcessingTime(byte *sharedBuffer, ushort sequenceId, long timestamp)
Parameters
Returns
GetLocalPacketTimer(Byte*, UInt16)
Declaration
public static ReliableUtility.PacketTimers*GetLocalPacketTimer(byte *sharedBuffer, ushort sequenceId)
Parameters
Type |
Name |
Description |
Byte* |
sharedBuffer |
|
UInt16 |
sequenceId |
|
Returns
GetPacket(Byte*, Int32)
Declaration
[Obsolete("Internal API that shouldn't be used. Will be removed in Unity Transport 2.0.")]
public static ReliableUtility.Packet*GetPacket(byte *self, int sequence)
Parameters
Type |
Name |
Description |
Byte* |
self |
|
Int32 |
sequence |
|
Returns
Declaration
public static ReliableUtility.PacketInformation*GetPacketInformation(byte *self, int sequence)
Parameters
Type |
Name |
Description |
Byte* |
self |
|
Int32 |
sequence |
|
Returns
GetRemotePacketTimer(Byte*, UInt16)
Declaration
public static ReliableUtility.PacketTimers*GetRemotePacketTimer(byte *sharedBuffer, ushort sequenceId)
Parameters
Type |
Name |
Description |
Byte* |
sharedBuffer |
|
UInt16 |
sequenceId |
|
Returns
InitializeContext(Byte*, Int32, Byte*, Int32, Byte*, Int32, ReliableUtility.Parameters)
Declaration
public static ReliableUtility.SharedContext InitializeContext(byte *sharedBuffer, int sharedBufferLength, byte *sendBuffer, int sendBufferLength, byte *recvBuffer, int recvBufferLength, ReliableUtility.Parameters param)
Parameters
Returns
InitializeProcessContext(Byte*, Int32, ReliableUtility.Parameters)
Declaration
public static int InitializeProcessContext(byte *buffer, int bufferLength, ReliableUtility.Parameters param)
Parameters
Returns
ProcessCapacityNeeded(ReliableUtility.Parameters)
Declaration
public static int ProcessCapacityNeeded(ReliableUtility.Parameters param)
Parameters
Returns
Read header data and update reliability tracking information in the shared context.
- If the packets sequence ID is lower than the last received ID+1, then it's stale
- If the packets sequence ID is higher, then we'll process it and update tracking info in the shared context
Declaration
[Obsolete("Will be removed in Unity Transport 2.0.")]
public static int Read(NetworkPipelineContext context, ReliableUtility.PacketHeader header)
Parameters
Returns
Type |
Description |
Int32 |
Sequence ID of the received packet.
|
Declaration
[Obsolete("Will be removed in Unity Transport 2.0.")]
public static void ReadAckPacket(NetworkPipelineContext context, ReliableUtility.PacketHeader header)
Parameters
Release(Byte*, Int32)
Declaration
public static void Release(byte *self, int sequence)
Parameters
Type |
Name |
Description |
Byte* |
self |
|
Int32 |
sequence |
|
Release(Byte*, Int32, Int32)
Declaration
public static void Release(byte *self, int start_sequence, int count)
Parameters
ReleaseOrResumePackets(NetworkPipelineContext)
Acknowledge the reception of packets which have been sent. The reliability
shared context/state is updated when packets are received from the other end
of the connection. The other side will update it's ackmask with which packets
have been received (starting from last received sequence ID) each time it sends
a packet back. This checks the resend timers on each non-acknowledged packet
and notifies if it's time to resend yet.
Declaration
[Obsolete("Internal API that shouldn't be used. Will be removed in Unity Transport 2.0.")]
public static bool ReleaseOrResumePackets(NetworkPipelineContext context)
Parameters
Type |
Name |
Description |
NetworkPipelineContext |
context |
Pipeline context, contains the buffer slices this pipeline connection owns.
|
Returns
Type |
Description |
Boolean |
If packets needed to be resumed.
|
ResumeReceive(NetworkPipelineContext, Int32, ref Boolean)
Resume or play back a packet we had received earlier out of order. When an out of order packet is received
it is stored since we need to first return the packet with the next sequence ID. When that packet finally
arrives it is returned but a pipeline resume is requested since we already have the next packet stored
and it can be processed immediately after.
Declaration
public static InboundRecvBuffer ResumeReceive(NetworkPipelineContext context, int startSequence, ref bool needsResume)
Parameters
Type |
Name |
Description |
NetworkPipelineContext |
context |
Pipeline context, we'll use both the shared reliability context and receive context.
|
Int32 |
startSequence |
The first packet which we need to retrieve now, there could be more after that.
|
Boolean |
needsResume |
Indicates if we need the pipeline to resume again.
|
Returns
Resend a packet which we have not received an acknowledgement for in time. Pipeline resume
will be enabled if there are more packets which we need to resend. The send reliability context
will then also be updated to track the next packet we need to resume.
Declaration
[Obsolete("Will be removed in Unity Transport 2.0.")]
public static InboundSendBuffer ResumeSend(NetworkPipelineContext context, out ReliableUtility.PacketHeader header, ref bool needsResume)
Parameters
Type |
Name |
Description |
NetworkPipelineContext |
context |
Pipeline context, we'll use both the shared reliability context and send context.
|
ReliableUtility.PacketHeader |
header |
Packet header for the packet payload we're resending.
|
Boolean |
needsResume |
Indicates if a pipeline resume is needed again. Unused.
|
Returns
SetHeaderAndPacket(Byte*, Int32, ReliableUtility.PacketHeader, InboundSendBuffer, Int64)
Write packet, packet header and tracking information to the given buffer space. This buffer
should contain the reliability Context at the front, that contains the capacity of the buffer
and pointer offsets needed to find the slots we can copy the packet to.
Declaration
[Obsolete("Internal API that shouldn't be used. Will be removed in Unity Transport 2.0.")]
public static void SetHeaderAndPacket(byte *self, int sequence, ReliableUtility.PacketHeader header, InboundSendBuffer data, long timestamp)
Parameters
Type |
Name |
Description |
Byte* |
self |
Buffer space where we can store packets.
|
Int32 |
sequence |
The sequence ID of the packet, this is used to find a slot inside the buffer.
|
ReliableUtility.PacketHeader |
header |
The packet header which we'll store with the packet payload.
|
InboundSendBuffer |
data |
The packet data which we're storing.
|
Int64 |
timestamp |
|
SetMinimumResendTime(Int32, NetworkDriver, NetworkPipeline, NetworkConnection)
Declaration
public static void SetMinimumResendTime(int value, NetworkDriver driver, NetworkPipeline pipeline, NetworkConnection con)
Parameters
SetPacket(Byte*, Int32, Void*, Int32)
Declaration
public static void SetPacket(byte *self, int sequence, void *data, int length)
Parameters
SetPacket(Byte*, Int32, InboundRecvBuffer)
Declaration
public static void SetPacket(byte *self, int sequence, InboundRecvBuffer data)
Parameters
SharedCapacityNeeded(ReliableUtility.Parameters)
Declaration
public static int SharedCapacityNeeded(ReliableUtility.Parameters param)
Parameters
Returns
ShouldSendAck(NetworkPipelineContext)
Declaration
public static bool ShouldSendAck(NetworkPipelineContext ctx)
Parameters
Returns
StoreReceiveTimestamp(Byte*, UInt16, Int64, UInt16)
Declaration
public static void StoreReceiveTimestamp(byte *sharedBuffer, ushort sequenceId, long timestamp, ushort processingTime)
Parameters
StoreRemoteReceiveTimestamp(Byte*, UInt16, Int64)
Declaration
public static void StoreRemoteReceiveTimestamp(byte *sharedBuffer, ushort sequenceId, long timestamp)
Parameters
StoreTimestamp(Byte*, UInt16, Int64)
Declaration
public static void StoreTimestamp(byte *sharedBuffer, ushort sequenceId, long timestamp)
Parameters
TryAquire(Byte*, Int32)
Declaration
public static bool TryAquire(byte *self, int sequence)
Parameters
Type |
Name |
Description |
Byte* |
self |
|
Int32 |
sequence |
|
Returns
Store the packet for possible later resends, and fill in the header we'll use to send it (populate with
sequence ID, last acknowledged ID from remote with ackmask.
Declaration
[Obsolete("Will be removed in Unity Transport 2.0.")]
public static int Write(NetworkPipelineContext context, InboundSendBuffer inboundBuffer, ref ReliableUtility.PacketHeader header)
Parameters
Returns
Type |
Description |
Int32 |
Sequence ID assigned to this packet.
|
Write an ack packet, only the packet header is used and this doesn't advance the sequence ID.
The packet is not stored away for resend routine.
Declaration
[Obsolete("Will be removed in Unity Transport 2.0.")]
public static void WriteAckPacket(NetworkPipelineContext context, ref ReliableUtility.PacketHeader header)
Parameters