-
Notifications
You must be signed in to change notification settings - Fork 2
Network Protocol Guide
This document defines the binary communication protocol used between the R-Type Client and Server. It is designed to be lightweight, low-latency, and suitable for real-time UDP communication.
- Transport Layer: UDP (User Datagram Protocol).
- Encoding: Strict Binary format (Little-Endian byte order).
- Architecture: Client-Server (Authoritative Server).
-
Port: Default is
4242.
Note: Unlike text-based protocols (HTTP/JSON), this protocol sends raw bytes directly from memory structures to minimize bandwidth usage and parsing overhead.
Every packet sent over the network shares a common Header, followed by a variable-length Body.
| Offset | Field Name | Type | Description |
|---|---|---|---|
0x00 |
OpCode | uint16_t |
Identifies the type of command (see Section 3). |
0x02 |
Length | uint16_t |
The size (in bytes) of the following Payload. |
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| OpCode | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Variable Payload... |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The protocol distinguishes between commands sent by the Client (C->S) and updates sent by the Server (S->C).
| OpCode | Name | Direction | Payload Size | Description |
|---|---|---|---|---|
| 0x01 | C_Login |
C -> S | 0 bytes | Request to join the game session. |
| 0x02 | S_LoginSuccess |
S -> C | 4 bytes | Acknowledge connection & assign Player ID. |
| 0x03 | C_Input |
C -> S | 2 bytes | Player movement/action inputs. |
| 0x04 | S_EntitySpawn |
S -> C | 14 bytes | Create a new entity (Player, Mob, Bullet). |
| 0x05 | S_EntityDestroy |
S -> C | 4 bytes | Remove an entity from the world. |
| 0x06 | S_EntityPosition |
S -> C | 12 bytes | Update position of a dynamic entity. |
| 0x07 | C_Shoot |
C -> S | 0 bytes | Player request to fire weapon. |
This section details the byte layout for the body of each command type.
Sent by the client every tick to update input state.
| Offset | Type | Name | Description |
|---|---|---|---|
0x00 |
int8_t |
DirX | Horizontal axis (-1: Left, 1: Right, 0: None). |
0x01 |
int8_t |
DirY | Vertical axis (-1: Up, 1: Down, 0: None). |
Sent by the server when a new object enters the visual field.
| Offset | Type | Name | Description |
|---|---|---|---|
0x00 |
uint32_t |
EntityID | Unique Network ID. |
0x04 |
uint8_t |
Type | 0=Player, 1=Mob_Basic, 2=Bullet, 3=PowerUp. |
0x05 |
float |
PosX | Initial X Coordinate. |
0x09 |
float |
PosY | Initial Y Coordinate. |
0x0D |
uint8_t |
Team | 0=Ally, 1=Enemy (for collision logic). |
High-frequency update to sync movements.
| Offset | Type | Name | Description |
|---|---|---|---|
0x00 |
uint32_t |
EntityID | Unique Network ID. |
0x04 |
float |
X | New X Coordinate. |
0x08 |
float |
Y | New Y Coordinate. |
Epitech Paris
- Raphaël Chanliongco
- Hubert Touraine
- Jean-Baptiste Boshra
- Gabin Rudigoz
- Ylan Cuvier
- Swann Grandin