-
Notifications
You must be signed in to change notification settings - Fork 0
/
RFC_02.txt
179 lines (146 loc) · 6.92 KB
/
RFC_02.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
Exodia
Request for comments: 1
27 december 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
Content: [Id]
0x03 - Reject client connection
0x0b - Send system to load MUST get an acknowledge
Content: [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]
0x0e - Send deleted entities MUST get an acknowledge
Content: [Entity]
0x0f - Send deleted components on entities MUST get an acknowledge
Content: [Entity][Component][Content_of_a_component]
0x10 - 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]
ClientCommand
0x81 - Connect MUST get an acknowledge
Content: [Timestamp][Id]
0x82 - Disconnect
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]
Details
0x00 - Packet info
This command is used to send the number of packets received and send since
last call of this command. This command is used to calculate the packet loss
It's content is [Int][Int] the first int is the number of packets received
and the second int is the number of packets send.
0x01 - Acknowledge
This command is used to acknowledge a command. It's content is [Id] the id
of the command to acknowledge.
0x02 - Accept client connection
This command is used to accept a client connection.
It's content is [Id] the id of the client.
0x03 - Reject client connection
This command is used to reject a client connection. It's content is empty.
0x0b - Send system to load
This command is used to send the systems to load. It's content is
[System] the system to load.
0x0c - Send entities with their components
This command is used to send the entities with one components. It's
content is [Entity][Component][Content_of_a_component] the entity to load
the component to load and the content of the component.
0x0d - Send GameEvent
This command is used to send the GameEvents. It's content is
[GameEvents] the GameEvents to load.
0x0e - Send deleted entities
This command is used to send the deleted entities. It's content is
[Entity] the entity to delete.
0x10 - Send deleted components on entities
This command is used to send the deleted components on entities. It's
content is [Entity][Component] the entity to delete
the component to delete and the content of the component to delete.
0x11 - Send events
This command is used to send the events. It's content is [Event] the event
to send.
0x81 - Connect
This command is used to connect to the server. It's content is
[Timestamp][Id] the timestamp of the client and the id of the server to
connect to.
0x82 - Disconnect
This command is used to disconnect from the server. It's content is empty.
0x8b - Send events
This command is used to send the events. It's content is [Event][Bool] the event
to send and a bool representing if the event is a key press or a key release.
0x8c - Send important events
This command is used to send the important events. It's content is
[Event][Bool] the event to send and a bool representing if the event is a
key press or a key release.
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]