Show / Hide Table of Contents

Class NetConstants

Network constants. Can be tuned from sources for your purposes.

Inheritance
object
NetConstants
Namespace: LiteNetLib
Assembly: LiteNetLib.dll
Syntax
public static class NetConstants

Fields

ChanneledHeaderSize

Size of the header for sequenced or reliable messages in bytes.
Includes HeaderSize, Sequence, and ChannelId.

Declaration
public const int ChanneledHeaderSize = 4
Field Value
Type Description
int

DefaultWindowSize

Default window size for reliable channels (number of packets).

Declaration
public const int DefaultWindowSize = 64
Field Value
Type Description
int

FragmentHeaderSize

Additional header size required for fragmented packets in bytes.
Includes FragmentId, FragmentPart, and FragmentsTotal.

Declaration
public const int FragmentHeaderSize = 6
Field Value
Type Description
int

FragmentedHeaderTotalSize

Total header size for a fragmented channeled packet in bytes.
Combines ChanneledHeaderSize and FragmentHeaderSize.

Declaration
public const int FragmentedHeaderTotalSize = 10
Field Value
Type Description
int

HalfMaxSequence

Half of the MaxSequence, used for sequence comparison and wrap-around logic.

Declaration
public const ushort HalfMaxSequence = 16384
Field Value
Type Description
ushort

HeaderSize

Size of the base packet header (PacketProperty) in bytes.

Declaration
public const int HeaderSize = 1
Field Value
Type Description
int

InitialMtu

The starting Maximum Transmission Unit (MTU) used for new connections before path MTU discovery.

Declaration
public static readonly int InitialMtu
Field Value
Type Description
int

MaxConnectionNumber

Maximum possible value for LiteNetLib.NetPacket.ConnectionNumber.

Declaration
public const byte MaxConnectionNumber = 4
Field Value
Type Description
byte
Remarks

This value is used to distinguish between different connection instances from the same IPEndPoint.
It allows the receiver to identify and discard packets belonging to previous connection attempts that may arrive late due to network jitter, even if they originate from the same address and port.

MaxPacketSize

Maximum possible packet size allowed by the library based on the largest supported MTU.

Declaration
public static readonly int MaxPacketSize
Field Value
Type Description
int

MaxSequence

Maximum possible sequence number before wrapping back to zero.

Declaration
public const ushort MaxSequence = 32768
Field Value
Type Description
ushort

MaxUnreliableDataSize

Maximum payload size for a single unreliable packet in bytes.
Calculated as MaxPacketSize - HeaderSize.

Declaration
public static readonly int MaxUnreliableDataSize
Field Value
Type Description
int

SocketBufferSize

Size of the underlying UDP socket receive and send buffers in bytes.
Default is 1MB.

Declaration
public const int SocketBufferSize = 1048576
Field Value
Type Description
int

SocketTTL

Time To Live (TTL) for the UDP packets.

Declaration
public const int SocketTTL = 255
Field Value
Type Description
int
In this article
Back to top Generated by DocFX