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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//! Reliability types for packets.
//! Each packet sent on the RakNet protocol has a reliability type, which determines how the packet should be handled.
//!
//! ## Unreliable
//! Unreliable packets are sent without any guarantee that they will be received by the other peer.
//! In other words, the packet is sent and forgotten about, with no expectation of a response.
//! This is the fastest reliability type, as it does not require any acks to be sent
//! back to the sender. Generally used for packets that are not important, such as
//! [`UnconnectedPing`] and [`UnconnectedPong`].
//!
//! ## Sequenced
//! Sequenced packets are sent with a sequence index in each frame (datagram) that is sent.
//! This is a number that is incremented after each packet. This allows us to implement a sliding window
//! ([`ReliableWindow`]), which
//! will discard any packets that are way too old or way too new.
//!
//! ## Ordered
//! Ordered packets are sent with an order index in each frame, as well as an order channel.
//! RakNet will use this information to order the packets in a specific way.
//!
//! The `order_channel` is used to determine which channel the packet should be sent on, in other words,
//! this is a unique channel chosen by the sender to send the packet on, and the receiver will use this
//! channel to re-order the packets in the correct order when they are sent.
//!
//! The `order_index` is used to determine the position of the packet in the order channel, this is
//! incremented after each packet is sent, similar to the sequence index, without the sliding window.
//!
//! ## Reliable
//! Reliable packets are sent with an ack system, meaning that the receiver will send an ack back to the
//! sender, which the sender expects to recieve.
//!
//! If the sender does not receive the ack, it will resend the packet until it receives the ack, or until
//! the connection is closed.
//!
//! [`UnconnectedPing`]: crate::protocol::packet::offline::UnconnectedPing
//! [`UnconnectedPong`]: crate::protocol::packet::offline::UnconnectedPong
//! [`ReliableWindow`]: crate::connection::controller::window::ReliableWindow
//!
/// The [RakNet Reliabilty] of a packet.
///
/// This is a bit flag encoded within each [`Frame`] that determines how the packet should be handled.
/// As of writing the following reliability types are supported:
/// - [`Unreliable`]
/// - [`UnreliableSeq`]
/// - [`Reliable`]
/// - [`ReliableOrd`]
/// - [`ReliableSeq`]
///
/// [RakNet Reliabilty]: https://github.com/facebookarchive/RakNet/blob/1a169895a900c9fc4841c556e16514182b75faf8/Source/PacketPriority.h#L46-L85
/// [`Frame`]: crate::protocol::frame::Frame
/// [`Unreliable`]: crate::protocol::reliability::Reliability::Unreliable
/// [`UnreliableSeq`]: crate::protocol::reliability::Reliability::UnreliableSeq
/// [`Reliable`]: crate::protocol::reliability::Reliability::Reliable
/// [`ReliableOrd`]: crate::protocol::reliability::Reliability::ReliableOrd
/// [`ReliableSeq`]: crate::protocol::reliability::Reliability::ReliableSeq