docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ReliableUtility

    Utility methods and types for the reliable pipeline stage.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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
    Type Name Description
    byte* sharedBuffer
    long sequenceId
    long timestamp
    Returns
    Type Description
    ushort

    GetLocalPacketTimer(byte*, long)

    Declaration
    public static ReliableUtility.PacketTimers* GetLocalPacketTimer(byte* sharedBuffer, long sequenceId)
    Parameters
    Type Name Description
    byte* sharedBuffer
    long sequenceId
    Returns
    Type Description
    PacketTimers*

    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
    Type Name Description
    byte* self
    long sequence
    Returns
    Type Description
    Packet*

    GetPacketInformation(byte*, long)

    Declaration
    public static ReliableUtility.PacketInformation* GetPacketInformation(byte* self, long sequence)
    Parameters
    Type Name Description
    byte* self
    long sequence
    Returns
    Type Description
    PacketInformation*

    GetRemotePacketTimer(byte*, long)

    Declaration
    public static ReliableUtility.PacketTimers* GetRemotePacketTimer(byte* sharedBuffer, long sequenceId)
    Parameters
    Type Name Description
    byte* sharedBuffer
    long sequenceId
    Returns
    Type Description
    PacketTimers*

    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
    ReliableUtility.Parameters param
    Returns
    Type Description
    ReliableUtility.SharedContext

    InitializeProcessContext(byte*, int, Parameters)

    Declaration
    public static int InitializeProcessContext(byte* buffer, int bufferLength, ReliableUtility.Parameters param)
    Parameters
    Type Name Description
    byte* buffer
    int bufferLength
    ReliableUtility.Parameters param
    Returns
    Type Description
    int

    ProcessCapacityNeeded(Parameters)

    Declaration
    public static int ProcessCapacityNeeded(ReliableUtility.Parameters param)
    Parameters
    Type Name Description
    ReliableUtility.Parameters 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
    NetworkPipelineContext context

    Pipeline context, the reliability shared state is used here.

    ReliableUtility.PacketHeader 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
    NetworkPipelineContext context
    ReliableUtility.PacketHeader header

    Release(byte*, long)

    Declaration
    public static void Release(byte* self, long sequence)
    Parameters
    Type Name Description
    byte* self
    long sequence

    Release(byte*, long, int)

    Declaration
    public static void Release(byte* self, long start_sequence, int count)
    Parameters
    Type Name Description
    byte* self
    long start_sequence
    int count

    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
    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
    NetworkPipelineContext context

    Pipeline context, we'll use both the shared reliability context and receive context.

    int startSequence

    Ignored.

    bool needsResume

    Ignored.

    Returns
    Type Description
    InboundRecvBuffer

    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
    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.

    bool needsResume

    Indicates if a pipeline resume is needed again. Unused.

    Returns
    Type Description
    InboundSendBuffer

    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.

    ReliableUtility.PacketHeader header

    The packet header which we'll store with the packet payload.

    InboundSendBuffer 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
    NetworkDriver driver
    NetworkPipeline pipeline
    NetworkConnection con

    SetPacket(byte*, long, void*, int)

    Declaration
    public static void SetPacket(byte* self, long sequence, void* data, int length)
    Parameters
    Type Name Description
    byte* self
    long sequence
    void* data
    int length

    SetPacket(byte*, long, InboundRecvBuffer)

    Declaration
    public static void SetPacket(byte* self, long sequence, InboundRecvBuffer data)
    Parameters
    Type Name Description
    byte* self
    long sequence
    InboundRecvBuffer data

    SharedCapacityNeeded(Parameters)

    Declaration
    public static int SharedCapacityNeeded(ReliableUtility.Parameters param)
    Parameters
    Type Name Description
    ReliableUtility.Parameters param
    Returns
    Type Description
    int

    ShouldSendAck(NetworkPipelineContext)

    Declaration
    public static bool ShouldSendAck(NetworkPipelineContext ctx)
    Parameters
    Type Name Description
    NetworkPipelineContext ctx
    Returns
    Type Description
    bool

    StoreReceiveTimestamp(byte*, long, long, ushort)

    Declaration
    public static void StoreReceiveTimestamp(byte* sharedBuffer, long sequenceId, long timestamp, ushort processingTime)
    Parameters
    Type Name Description
    byte* sharedBuffer
    long sequenceId
    long timestamp
    ushort processingTime

    StoreRemoteReceiveTimestamp(byte*, long, long)

    Declaration
    public static void StoreRemoteReceiveTimestamp(byte* sharedBuffer, long sequenceId, long timestamp)
    Parameters
    Type Name Description
    byte* sharedBuffer
    long sequenceId
    long timestamp

    StoreTimestamp(byte*, long, long)

    Declaration
    public static void StoreTimestamp(byte* sharedBuffer, long sequenceId, long timestamp)
    Parameters
    Type Name Description
    byte* sharedBuffer
    long sequenceId
    long timestamp

    TryAquire(byte*, long)

    Declaration
    public static bool TryAquire(byte* self, long sequence)
    Parameters
    Type Name Description
    byte* self
    long sequence
    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
    NetworkPipelineContext context

    Pipeline context, the reliability shared state is used here.

    InboundSendBuffer inboundBuffer

    Buffer with packet data.

    ReliableUtility.PacketHeader 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
    NetworkPipelineContext context

    Pipeline context, the reliability shared state is used here.

    ReliableUtility.PacketHeader header

    Packet header which will be populated.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)