Dev's NoxDev's Nox
Relay Protocol

Overview

NOX network communication system for managing connections between clients and servers

The Relay Protocol is a network communication system used by NOX to manage connections between clients and servers.

It uses both TCP and UDP to provide connection compatibility for clients.

General Architecture

The NOX Relay works as an intelligent proxy server that:

  • Receives TCP and UDP connections from clients
  • Routes messages between connected clients
  • Handles authentication and sessions

Packet Format

All packets follow a common structure:

Base Structure

For clarity, the base structures are presented in the format below, The explanation of the format is detailed at the bottom of the page.

[length: ushort]
[uid: ushort]
[type: byte]
[payload: byte[]]

Detailed Structure

TypeNameDescription
ushortLengthTotal packet size (includes Length)
ushortUIDUnique identifier (optional)
byteTypeRequest/response type
byte[]PayloadMessage data

Important Constants

  • Protocol version: 1
  • Max packet size: 1024 bytes
  • Default port: 23032
  • Connection timeout: 15 seconds
  • Keep-alive interval: 5 seconds
  • Segmentation timeout: 30 seconds

Unique Identifier (UID)

The UID field allows a callback for a specific request. If the message comes from the server, the client must reply with the same UID. And the UID 0x0000 to indicate that it does not expect a response, or by default.

Timeout and Keep-Alive

The timeout is reset on every received valid packet. When no packets are to be sent, the client must send a packet (e.g. Latency) within a delay shorter than the timeout value to keep the connection active. The client is responsible for sending keep-alive.

Communication Flow Example

  1. Handshake: The client initiates the connection with a Handshake message.
  2. Authentication: The client authenticates with an Authentication message.
  3. Session: To obtain information about an instance.
  4. Enter: To join an instance.
  5. Disconnect: For a clean disconnection, the client is automatically removed from the sessions it is connected to.

Priority System

The protocol uses a priority system to optimize performance:

  • Critical: Handshake, Disconnect
  • High: Authentication, Enter/Quit
  • Normal: Transform, Status
  • Low: Custom messages (these packets may be delayed or lost in case of congestion)

Security

  • Protocol validation during the handshake
  • Authentication required before any action (unless the server is in offline mode)
  • Size limitation of packets (1024 bytes max, or customized by the server)

Message Types (Client → Server)

The protocol supports the following message types that clients can send to the server:

TypeNameDescriptionPriority
0x00DisconnectClean disconnectionCritical
0x01HandshakeConnection initializationCritical
0x02SegmentationFragmentation of large messagesNormal
0x03ReliableReliable messagesNormal
0x04LatencyLatency testNormal
0x05AuthenticationIdentity validationHigh
0x06EnterJoin an instanceHigh
0x07QuitLeave an instanceHigh
0x08CustomCustom messagesNormal
0x09PasswordRequirementPassword requestHigh
0x0ATravelingMovement between instancesNormal
0x0BTransformReal-time position/rotationNormal
0x0CTeleportInstant teleportationHigh
0x0DAvatarChangedAvatar changeNormal
0x0EServerConfigServer configurationHigh
0x0FAvatarParamsAvatar parametersNormal
0x11SessionsProvides session informationNormal

Response Types (Server → Client)

The server uses a different set of types for its responses and notifications:

TypeNameDescriptionOrigin
0x00DisconnectDisconnection confirmation/notificationResponse
0x01HandshakeHandshake confirmationResponse
0x02SegmentationResponse fragmentationResponse
0x03ReliableReliable responsesResponse
0x04LatencyLatency test responseResponse
0x05AuthenticationAuthentication resultResponse
0x06EnterInstance enter resultResponse
0x07QuitLeave confirmationResponse
0x08CustomCustom responsesResponse
0x09PasswordRequirementPassword responseResponse
0x0ATravelingTravel confirmationResponse
0x0BTransformPosition synchronizationResponse/Notification
0x0CTeleportTeleportation confirmationResponse
0x0DAvatarChangedAvatar change notificationResponse/Notification
0x0EServerConfigConfig change notificationResponse/Notification
0x0FAvatarParamsAvatar parameters notificationResponse/Notification
0x10JoinPlayer arrival notificationNotification
0x11LeavePlayer departure notificationNotification
0x12SessionsSession informationResponse

Important information:

  • Responses: Messages sent in direct reaction to a client request (same UID)
  • Notifications: Automatic messages sent by the server (UID = 0x0000)

Each message type has its own detailed documentation page with its specific input and output formats.

Data Types

The protocol uses several data types to structure messages. Here are the supported types:

TypeSize (bytes)Description
byte18-bit unsigned integer
short216-bit signed integer (big-endian)
ushort216-bit unsigned integer (big-endian)
int432-bit signed integer (big-endian)
uint432-bit unsigned integer (big-endian)
long864-bit signed integer (big-endian)
ulong864-bit unsigned integer (big-endian)
float4Single-precision floating point number (big-endian)
double8Double-precision floating point number (big-endian)
string2 + NUTF-8 string with a length prefix (ushort)
DateTime8Unix timestamp in milliseconds
Vector3123 float components (X, Y, Z)
Quaternion164 float components (X, Y, Z, W)
byte[]NByte array
EnumVariableEnumeration/Flags (depending on the underlying type)

Important Notes

  • Byte order: All multi-byte types use big-endian order (most significant byte first)
  • Strings: Encoded in UTF-8 with a ushort prefix indicating the length
  • Timestamps: Stored as Unix timestamps in milliseconds (long)
  • Enumerations: Serialized according to their underlying type (byte, ushort, uint)

In the protocol, reading is done byte by byte. Therefore some data types are not allowed, such as booleans, which must be converted to a byte or to flags with other booleans.

Packet Syntax in the Documentation

Each message in the documentation is presented with a clear syntax for the packet format.

[Length: ushort]
[UID: ushort]
[Type: byte]
[Payload?: byte[]]
(0x01 in Type ? [Reason?: string])
(Latency == Type ? (
    [ClientTimestamp: DateTime]
    [ServerTimestamp: DateTime]
))

Each field is described as an entry between brackets [] with the field name and its type. When a field is optional, a ? is added before the :. When a list of fields is grouped, they are placed between parentheses (). Likewise, when there is a condition, the same syntax is used (Condition ? [Field]) or (Condition1 ? [Field1] : [Field2]). Fields are listed in order of appearance in the packet.

On this page