Skip to content

RyuLdn Protocol

This page documents the RyuLdn network protocol used to communicate with the server.

RyuLdn is a binary protocol over TCP. All multi-byte integers are little-endian.

┌─────────────────────────────────────────┐
│ Header (4 bytes) │
├─────────────────────────────────────────┤
│ Magic (2 bytes): 0x524C ("RL") │
│ Type (1 byte): PacketType enum │
│ Reserved (1 byte): 0x00 │
├─────────────────────────────────────────┤
│ Payload (variable) │
│ Structure depends on packet type │
└─────────────────────────────────────────┘
ValueNameDirectionDescription
0x01PassphraseC→SAuthentication
0x02ConnectedS→CConnection confirmed
0x03SyncNetworkS→CNetwork state sync
0x04DisconnectBothDisconnection notice
0x10ScanC→SRequest network scan
0x11ScanResponseS→CScan results
0x20CreateAccessPointC→SCreate network
0x21CreateAccessPointResponseS→CCreate result
0x30ConnectC→SJoin network
0x31ConnectResponseS→CJoin result
0x40SetAcceptPolicyC→SSet join policy
0x50SetAdvertiseDataC→SUpdate advertisement
0x60RejectC→SReject a connection
0x70ProxyDataBothGame data relay
0x80ProxyDataBroadcastBothBroadcast data
Client Server
│ │
│──── Passphrase ─────────────────────▶│
│ (game_id, ssid, etc.) │
│ │
│◀──── Connected ──────────────────────│
│ (assigned node_id) │

Sent by client after TCP connection.

struct PassphrasePacket {
u32 magic; // "RL" + type + reserved
u64 game_id; // Title ID
u8 ssid[32]; // Network SSID
u8 passphrase[32]; // Network passphrase
};

Sent by server to confirm connection.

struct ConnectedPacket {
u32 magic;
u8 node_id; // Assigned node ID (0-7)
};

Sent by server when network state changes.

struct SyncNetworkPacket {
u32 magic;
NetworkInfo network_info; // Full network state
};

Request to scan for available networks.

struct ScanPacket {
u32 magic;
ScanFilter filter; // Optional filter criteria
};

Contains discovered networks.

struct ScanResponsePacket {
u32 magic;
u16 network_count;
NetworkInfo networks[]; // Variable length
};

Request to create a new network (host).

struct CreateAccessPointPacket {
u32 magic;
SecurityConfig security;
UserConfig user;
NetworkConfig network;
};

Request to join an existing network.

struct ConnectPacket {
u32 magic;
u8 network_id[16]; // Network to join
ConnectData data; // Connection data
};

Game data relay between nodes.

struct ProxyDataPacket {
u32 magic;
u8 source_node; // Sender node ID
u8 dest_node; // Destination node ID (0xFF for all)
u16 data_size; // Payload size
u8 data[]; // Game data
};

Broadcast game data to all nodes.

struct ProxyDataBroadcastPacket {
u32 magic;
u8 source_node;
u16 data_size;
u8 data[];
};
struct NetworkInfo {
u8 network_id[16]; // Unique network ID
Ssid ssid; // Network SSID
SecurityConfig security; // Security settings
UserConfig host_user; // Host information
u8 node_count; // Current players
u8 node_count_max; // Maximum players
NodeInfo nodes[8]; // Player information
u16 advertise_data_size; // Advertisement size
u8 advertise_data[384]; // Game advertisement
};

If a malformed packet is received:

  1. Server may send Disconnect packet with reason
  2. Server closes TCP connection
  3. Client should attempt reconnection

Disconnect reasons:

  • 0x01: Protocol error
  • 0x02: Authentication failed
  • 0x03: Network full
  • 0x04: Kicked by host
  • 0x05: Network closed