Struct ReliableUtility
Utility methods and types for the reliable pipeline stage.
Inherited Members
Namespace: Unity.Networking.Transport.Utilities
Assembly: Unity.Networking.Transport.dll
Syntax
public struct ReliableUtility
Remarks
Most methods are meant for internal use only. It is recommended not to rely on anything in in structure since it is very likely to change in a future major version of the package.
Fields
DefaultMinimumResendTime
The least amount of time we'll wait until a packet resend is performed.
Declaration
public const int DefaultMinimumResendTime = 64
Field Value
Type | Description |
---|---|
int |
MaximumResendTime
The maximum amount of time we'll wait to resend a packet.
Declaration
public const int MaximumResendTime = 200
Field Value
Type | Description |
---|---|
int |
NullEntry
Internal value. Do not use.
Declaration
public const long NullEntry = -1
Field Value
Type | Description |
---|---|
long |
Methods
CalculateProcessingTime(byte*, long, long)
Declaration
public static ushort CalculateProcessingTime(byte* sharedBuffer, long sequenceId, long timestamp)
Parameters
Returns
Type | Description |
---|---|
ushort |
GetLocalPacketTimer(byte*, long)
Declaration
public static ReliableUtility.PacketTimers* GetLocalPacketTimer(byte* sharedBuffer, long sequenceId)
Parameters
Returns
Type | Description |
---|---|
Packet |
GetPacket(byte*, long)
Declaration
[Obsolete("Internal API that shouldn't be used. Will be removed in Unity Transport 2.0.")]
public static ReliableUtility.Packet* GetPacket(byte* self, long sequence)
Parameters
Returns
Type | Description |
---|---|
Packet* |
GetPacketInformation(byte*, long)
Declaration
public static ReliableUtility.PacketInformation* GetPacketInformation(byte* self, long sequence)
Parameters
Returns
Type | Description |
---|---|
Packet |
GetRemotePacketTimer(byte*, long)
Declaration
public static ReliableUtility.PacketTimers* GetRemotePacketTimer(byte* sharedBuffer, long sequenceId)
Parameters
Returns
Type | Description |
---|---|
Packet |
InitializeContext(byte*, int, byte*, int, byte*, int, Parameters)
Declaration
public static ReliableUtility.SharedContext InitializeContext(byte* sharedBuffer, int sharedBufferLength, byte* sendBuffer, int sendBufferLength, byte* recvBuffer, int recvBufferLength, ReliableUtility.Parameters param)
Parameters
Type | Name | Description |
---|---|---|
byte* | sharedBuffer | |
int | sharedBufferLength | |
byte* | sendBuffer | |
int | sendBufferLength | |
byte* | recvBuffer | |
int | recvBufferLength | |
Reliable |
param |
Returns
Type | Description |
---|---|
Reliable |
InitializeProcessContext(byte*, int, Parameters)
Declaration
public static int InitializeProcessContext(byte* buffer, int bufferLength, ReliableUtility.Parameters param)
Parameters
Type | Name | Description |
---|---|---|
byte* | buffer | |
int | bufferLength | |
Reliable |
param |
Returns
Type | Description |
---|---|
int |
ProcessCapacityNeeded(Parameters)
Declaration
public static int ProcessCapacityNeeded(ReliableUtility.Parameters param)
Parameters
Type | Name | Description |
---|---|---|
Reliable |
param |
Returns
Type | Description |
---|---|
int |
Read(NetworkPipelineContext, PacketHeader)
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
Type | Name | Description |
---|---|---|
Network |
context | Pipeline context, the reliability shared state is used here. |
Reliable |
header | Packet header of a new received packet. |
Returns
Type | Description |
---|---|
int | Sequence ID of the received packet. |
ReadAckPacket(NetworkPipelineContext, PacketHeader)
Declaration
[Obsolete("Will be removed in Unity Transport 2.0.")]
public static void ReadAckPacket(NetworkPipelineContext context, ReliableUtility.PacketHeader header)
Parameters
Type | Name | Description |
---|---|---|
Network |
context | |
Reliable |
header |
Release(byte*, long)
Declaration
public static void Release(byte* self, long sequence)
Parameters
Release(byte*, long, int)
Declaration
public static void Release(byte* self, long 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 |
---|---|---|
Network |
context | Pipeline context, contains the buffer slices this pipeline connection owns. |
Returns
Type | Description |
---|---|
bool | If packets needed to be resumed. |
Remarks
Internal API. Shouldn't be used.
ResumeReceive(NetworkPipelineContext, int, ref bool)
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 |
---|---|---|
Network |
context | Pipeline context, we'll use both the shared reliability context and receive context. |
int | startSequence | Ignored. |
bool | needsResume | Ignored. |
Returns
Type | Description |
---|---|
Inbound |
ResumeSend(NetworkPipelineContext, out PacketHeader, ref bool)
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 |
---|---|---|
Network |
context | Pipeline context, we'll use both the shared reliability context and send context. |
Reliable |
header | Packet header for the packet payload we're resending. |
bool | needsResume | Indicates if a pipeline resume is needed again. Unused. |
Returns
Type | Description |
---|---|
Inbound |
Buffer slice to packet payload. |
SetHeaderAndPacket(byte*, long, PacketHeader, InboundSendBuffer, long)
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, long sequence, ReliableUtility.PacketHeader header, InboundSendBuffer data, long timestamp)
Parameters
Type | Name | Description |
---|---|---|
byte* | self | Buffer space where we can store packets. |
long | sequence | The sequence ID of the packet, this is used to find a slot inside the buffer. |
Reliable |
header | The packet header which we'll store with the packet payload. |
Inbound |
data | The packet data which we're storing. |
long | timestamp |
SetMinimumResendTime(int, NetworkDriver, NetworkPipeline, NetworkConnection)
Declaration
public static void SetMinimumResendTime(int value, NetworkDriver driver, NetworkPipeline pipeline, NetworkConnection con)
Parameters
Type | Name | Description |
---|---|---|
int | value | |
Network |
driver | |
Network |
pipeline | |
Network |
con |
SetPacket(byte*, long, void*, int)
Declaration
public static void SetPacket(byte* self, long sequence, void* data, int length)
Parameters
SetPacket(byte*, long, InboundRecvBuffer)
Declaration
public static void SetPacket(byte* self, long sequence, InboundRecvBuffer data)
Parameters
Type | Name | Description |
---|---|---|
byte* | self | |
long | sequence | |
Inbound |
data |
SharedCapacityNeeded(Parameters)
Declaration
public static int SharedCapacityNeeded(ReliableUtility.Parameters param)
Parameters
Type | Name | Description |
---|---|---|
Reliable |
param |
Returns
Type | Description |
---|---|
int |
ShouldSendAck(NetworkPipelineContext)
Declaration
public static bool ShouldSendAck(NetworkPipelineContext ctx)
Parameters
Type | Name | Description |
---|---|---|
Network |
ctx |
Returns
Type | Description |
---|---|
bool |
StoreReceiveTimestamp(byte*, long, long, ushort)
Declaration
public static void StoreReceiveTimestamp(byte* sharedBuffer, long sequenceId, long timestamp, ushort processingTime)
Parameters
StoreRemoteReceiveTimestamp(byte*, long, long)
Declaration
public static void StoreRemoteReceiveTimestamp(byte* sharedBuffer, long sequenceId, long timestamp)
Parameters
StoreTimestamp(byte*, long, long)
Declaration
public static void StoreTimestamp(byte* sharedBuffer, long sequenceId, long timestamp)
Parameters
TryAquire(byte*, long)
Declaration
public static bool TryAquire(byte* self, long sequence)
Parameters
Returns
Type | Description |
---|---|
bool |
Write(NetworkPipelineContext, InboundSendBuffer, ref PacketHeader)
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
Type | Name | Description |
---|---|---|
Network |
context | Pipeline context, the reliability shared state is used here. |
Inbound |
inboundBuffer | Buffer with packet data. |
Reliable |
header | Packet header which will be populated. |
Returns
Type | Description |
---|---|
int | Sequence ID assigned to this packet. |
WriteAckPacket(NetworkPipelineContext, ref PacketHeader)
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
Type | Name | Description |
---|---|---|
Network |
context | Pipeline context, the reliability shared state is used here. |
Reliable |
header | Packet header which will be populated. |