Dev's NoxDev's Nox
Relay Protocol

Handshake

Mandatory first exchange between client and server to establish protocol compatibility.

The Handshake message is the mandatory first exchange between a client and the Relay server.

It establishes protocol compatibility and exchanges the basic connection information.

Priority

Critical - This message has the highest priority and must be processed immediately.


Client Request → Server

Payload Format

[protocol: ushort]
[engine: string]
[platform: string]

Detailed Structure

TypeNameDescription
ushortProtocolProtocol version (currently 1)
stringEngineEngine name (e.g. "unity", "unreal") in lowercase
stringPlatformPlatform (e.g. "windows", "android") in lowercase

Payload Example

[0x00, 0x01]        // Protocol = 1
[0x05, "unity"]     // Engine = "unity" (5 chars)
[0x07, "windows"]   // Platform = "windows" (7 chars)

Server Response → Client

Packet Format

[protocol: ushort]
[client_id: ushort]
[client_ip: 4 bytes]
[client_port: ushort]
[flags: byte]
(IsOffline in flags ? [master_addr: string])
[ushort] Max Packet Size
[ushort] Connection Timeout
[ushort] Keep Alive Interval
[ushort] Segmentation Timeout

Detailed Structure

TypeNameDescription
ushortProtocolConfirmed protocol version
ushortClientIDUnique ID assigned to the client
byte[4]IPAddressClient IP address as seen by the server
ushortPortClient port
byteFlagsHandshake state flags
stringMasterAddrMaster Server address (conditional)
ushortMaxPacketSizeMaximum packet size (1024)
ushortTimeoutConnection timeout (15 sec)
ushortKeepAliveKeep-alive interval (5 sec)
ushortSegmentationTimeoutTimeout for segmentation sessions (30 sec)

Handshake Flags

ValueNameDescription
0x00NoneNormal operation
0x01IsOfflineServer in offline mode (no Master Server)

Response Example

[0x00, 0x01]                    // Protocol = 1
[0x00, 0x42]                    // ClientID = 66
[0xC0, 0xA8, 0x01, 0x10]        // IP = 192.168.1.16
[0x9C, 0x40]                    // Port = 40000
[0x00]                          // Flags = None
[0x0A, "master.nox"]            // MasterAddr = "master.nox"
[0x04, 0x00]                    // MaxPacketSize = 1024
[0x00, 0x0F]                    // Timeout = 15
[0x00, 0x05]                    // KeepAlive = 5
[0x00, 0x1E]                    // SegmentationTimeout = 30

Processing

Server Side

  1. Protocol validation: Version check
  2. ID assignment: Assignment of a unique ID to the client
  3. IP detection: Extraction of the client address
  4. Flags configuration: According to the server state
  5. Response sending: With all connection parameters

Client Side

  1. Parameter reception: Local configuration according to the response
  2. Network configuration: Adjustment according to MaxPacketSize and timeouts

Error Codes

Protocol Incompatibility

If the protocol version does not match or is incompatible, the server sends a Disconnect packet immediately after the Handshake.

On this page