-
Notifications
You must be signed in to change notification settings - Fork 0
/
RFC_01.txt
119 lines (101 loc) · 4.66 KB
/
RFC_01.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Exodia
Request for comments: 1
29 november 2023
Author: Axel Rohee
(EOUDP) - Exodia On UDP
Introduction
------------
Abstract
EOUDP (Exodia On UDP)is a simple protocol for sending and receiving data over UDP.
It is designed to be simple and easy to use. It is also designed to be fast and efficient.
It is designed to be used to transmit ECS data over UDP. It take in account the
unreliability of UDP and the fact that UDP packet can be lost, duplicated or arrive
out of order. It also take in account the (MTU) Maximum Transmission Unit of the
network (1500 bytes).
Terminology
World - A world is a collection of entities and systems.
Entity - An entity is a unique identifier
Component - A component is a piece of data that is attached to an entity.
System - A system is a updater of entities with certain components.
Timestamp - A float representing the time in seconds.
Event - An event is a message that is sent to the server generaly to
represent a key press or a key release.
Representation
EOUDP is designed to be fast and efficient as so it will use binary data.
In this section we will define the binary representation of the data.
Command - 8 bits (1 byte) bitfield representing the command.
Int - 32 bits (4 bytes) signed integer.
Entity - 64 bits (8 bytes) unsigned integer.
Component - Null terminated string prefixed with a 32 bit (4 bytes) unsigned
integer representing the length of the string.
Content_of_a_component - 32 bit (4 bytes) unsigned integer representing the
length of the content followed by the content.
System - Null terminated string prefixed with a 32 bit (4 bytes) unsigned
integer representing the length of the string.
Timestamp - 32 bit (4 bytes) float representing the time in seconds.
Event - 32 bit (4 bytes) unsigned integer representing the event type.
Id - 64 bit (8 bytes) unsigned integer representing the id of the command
use for implementing acknoledgement.
GameEvents - - Null terminated string prefixed with a 32 bit (4 bytes) unsigned
integer representing the length of the string.
Size - 64 bit (8 bytes) unsigned integer representing the size of the content
of the packet.
Commands
Each command is prefixed with a header define below representing the command. There are the
following commands command inferior to 0x80 are server commands and superior
to 0x80 are client commands.
Header
Content: [Command][Timestamp][Id][Size]
Special commands
0x00 - Send number of packets received and send since last second
Content: [Int][Int]
0x01 - Acknowledge
Content: [Id]
ServerCommand
0x02 - Accept client connection
0x03 - Reject client connection
0x0b - Send system to load MUST get an acknowledge
Content: [System][System]...
0x0c - Send entities with their components MUST get an acknowledge
Content: [Entity][Component][Content_of_a_component]
0x0d - Send GameEvents MUST get an acknowledge
Content: [GameEvents][GameEvents]...
0x0e - Send deleted entities MUST get an acknowledge
Content: [Entity]
0x10 - Send deleted components on entities MUST get an acknowledge
Content: [Entity][Component][Content_of_a_component]
0x11 - Send events
Content: [Event]
ClientCommand
0x81 - Connect MUST get an acknowledge
0x82 - Disconnect
0x8a - Send events
Content: [Event]
0x8b - Send events release the bool is true if the event is a key press false if it is a key release
Content: [Event][Bool]
0x8c - Send important events the bool is true if the event is a key press false if it is a key release MUST get an acknowledge
Content: [Event][Bool]
Usage
The protocol is designed to be used in a certain way.
this section will show an example of how to use the protocol.
Initiation:events
Client -> [0x81][Timestamp][Id]
Server -> [0x02][Timestamp][Id]
Server -> [0x0b][Timestamp][Id][System][System]...
Client -> [0x01][Timestamp][Id][Id]
Server -> [0x0c][Timestamp][Id][GameEvents][GameEvents]...
Client -> [0x01][Timestamp][Id][Id]
Server -> [0x0c][Timestamp][Id][Entity][Component][Content_of_a_component]...
Client -> [0x01][Timestamp][Id][Id]
loop:
Client -> [0x8a][Timestamp][Id][KeyEvent]
Server -> [0x0c][Timestamp][Id][Id][Entity][Component][Content_of_a_component]...
Client -> [0x01][Timestamp][Id][Id]
Server -> [0x0e][Timestamp][Id][Id][Entity]...
Client -> [0x01][Timestamp][Id][Id]
Server -> [0x0c][Timestamp][Id][Entity][Component][Content_of_a_component]...
Client -> [0x01][Timestamp][Id][Id]
End:
one or the other:
Client -> [0x82][Timestamp][Id][Id] and Server -> [0x11][Timestamp][Id][Id]
Server -> [0x03][Timestamp][Id]