Difference between revisions of "Raknet Protocol"
m (It's on the main page now) |
(Start documenting data types) |
||
Line 1: | Line 1: | ||
:: '''Remember that this page is a WIP.''' Come back later to see a more complete page. | :: '''Remember that this page is a WIP.''' Come back later to see a more complete page. | ||
---- | ---- | ||
− | |||
− | |||
This is based on the old [https://wiki.vg/Pocket_Edition_Protocol_Documentation#RakNet_protocol Pocket Edition Protocol Documentation] and may be incomplete or outdated. | This is based on the old [https://wiki.vg/Pocket_Edition_Protocol_Documentation#RakNet_protocol Pocket Edition Protocol Documentation] and may be incomplete or outdated. | ||
Line 9: | Line 7: | ||
Other implementations exist, such as [https://github.com/jython234/JRakLibPlus JRakLibPlus] and [https://github.com/PocketMine/RakLib RakLib]. | Other implementations exist, such as [https://github.com/jython234/JRakLibPlus JRakLibPlus] and [https://github.com/PocketMine/RakLib RakLib]. | ||
+ | |||
+ | == Data types == | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! | ||
+ | ! Size (Bytes) | ||
+ | ! Range | ||
+ | ! Notes | ||
+ | |- | ||
+ | ! Byte | ||
+ | | 1 | ||
+ | | 0 to 255 | ||
+ | | | ||
+ | |- | ||
+ | ! Long | ||
+ | | 8 | ||
+ | | -2^63 to 2^63-1 | ||
+ | | Signed 64-bit Integer | ||
+ | |- | ||
+ | ! Magic | ||
+ | | 16 | ||
+ | | <code>00ffff00fefefefefdfdfdfd12345678</code> | ||
+ | | Always those hex bytes, corresponding to RakNet's default OFFLINE_MESSAGE_DATA_ID | ||
+ | |} | ||
+ | |||
+ | |||
+ | == Packets == | ||
=== Connected Ping === | === Connected Ping === | ||
Line 20: | Line 46: | ||
| 0x00 | | 0x00 | ||
| Time | | Time | ||
− | | | + | | Long |
| | | | ||
|} | |} | ||
Line 33: | Line 59: | ||
|rowspan="2"| 0x01, 0x02 | |rowspan="2"| 0x01, 0x02 | ||
| Time | | Time | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
Line 52: | Line 78: | ||
|rowspan="2"| 0x03 | |rowspan="2"| 0x03 | ||
| Ping Time | | Ping Time | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
| Pong Time | | Pong Time | ||
− | | | + | | Long |
| | | | ||
|} | |} | ||
Line 96: | Line 122: | ||
|- | |- | ||
| Server GUID | | Server GUID | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
Line 130: | Line 156: | ||
|- | |- | ||
| Client GUID | | Client GUID | ||
− | | | + | | Long |
| | | | ||
|} | |} | ||
Line 147: | Line 173: | ||
|- | |- | ||
| Server GUID | | Server GUID | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
Line 172: | Line 198: | ||
|rowspan="2"| 0x09 | |rowspan="2"| 0x09 | ||
| GUID | | GUID | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
| Time | | Time | ||
− | | | + | | Long |
| | | | ||
|} | |} | ||
Line 201: | Line 227: | ||
|- | |- | ||
| Request time | | Request time | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
| Time | | Time | ||
− | | | + | | Long |
| | | | ||
|} | |} | ||
Line 226: | Line 252: | ||
|- | |- | ||
| Server GUID | | Server GUID | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
Line 240: | Line 266: | ||
|rowspan="2"| 0x01, 0x02 | |rowspan="2"| 0x01, 0x02 | ||
| Time | | Time | ||
− | | | + | | Long |
| | | | ||
|- | |- | ||
| GUID | | GUID | ||
− | | | + | | Long |
| | | | ||
|} | |} |
Revision as of 11:27, 8 June 2020
- Remember that this page is a WIP. Come back later to see a more complete page.
This is based on the old Pocket Edition Protocol Documentation and may be incomplete or outdated.
The source code for the RakNet Library can be found here.
Other implementations exist, such as JRakLibPlus and RakLib.
Contents
- 1 Data types
- 2 Packets
- 2.1 Connected Ping
- 2.2 Unconnected Ping
- 2.3 Connected Pong
- 2.4 Offline Connection Request 1
- 2.5 Offline Connection Response 1
- 2.6 Offline Connection Request 2
- 2.7 Offline Connection Response 2
- 2.8 Online Connection Request
- 2.9 Online Connection Request Accepted
- 2.10 Incompatible protocol
- 2.11 Unconnected Ping
- 2.12 Frame Set Packet
- 2.13 Game Packet
- 2.14 NACK
- 2.15 ACK
Data types
Size (Bytes) | Range | Notes | |
---|---|---|---|
Byte | 1 | 0 to 255 | |
Long | 8 | -2^63 to 2^63-1 | Signed 64-bit Integer |
Magic | 16 | 00ffff00fefefefefdfdfdfd12345678
|
Always those hex bytes, corresponding to RakNet's default OFFLINE_MESSAGE_DATA_ID |
Packets
Connected Ping
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x00 | Time | Long |
Unconnected Ping
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x01, 0x02 | Time | Long | |
MAGIC | magic |
0x02
is only replied to if there are open connections to the server. Note: as of 0.15.6 it seems that the game refreshes it's LAN world list every 4-5 seconds, however it seems the game will still ping in 1 second intervals.
Connected Pong
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x03 | Ping Time | Long | |
Pong Time | Long |
Offline Connection Request 1
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x05 | Magic | MAGIC | |
Protocol version | byte | Currently 7 | |
MTU | mtu-46 zero bytes | The MTU sent in the response appears to be somewhere around the size of this padding + 46 (28 udp overhead, 1 packet id, 16 magic, 1 protocol version) |
The client sends these to the target server with ever decreasing MTU until the server responds. This is used to discover the MTU size for the connection. If the RakNet protocol does not match your own, respond with the Incompatible protocol packet
Offline Connection Response 1
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x06 | Magic | MAGIC | |
Server GUID | Long | ||
Use security | boolean | Make sure this is false, it is vital for the login sequence to continue! | |
MTU | short | see Offline Connection Request 1 |
Offline Connection Request 2
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x07 | Magic | MAGIC | |
Server Address | address | ||
MTU | short | ||
Client GUID | Long |
Offline Connection Response 2
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x08 | Magic | MAGIC | |
Server GUID | Long | ||
Client Address | address | ||
MTU | short | ||
Encryption enabled? | byte | 0 for disabled. |
Online Connection Request
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x09 | GUID | Long | |
Time | Long |
Online Connection Request Accepted
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x10 | Client address | address | |
System index | short | Unknown what this does. 0 works as a value. | |
Internal IDs | 10x address | Unknown what these do. 255.255.255.255:19132 for all of them seems to work, any other address will probably work as well. | |
Request time | Long | ||
Time | Long |
Incompatible protocol
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x19 | Protocol | byte | |
Magic | MAGIC | ||
Server GUID | Long |
Unconnected Ping
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x01, 0x02 | Time | Long | |
GUID | Long |
Frame Set Packet
Packet ID | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|
0x80..0x8d | Frame Set index | uint24le | |||
Frames | Flags | byte | Top 3 bits are reliability type, fourth bit is 1 when the frame is fragmented and part of a compound. | ||
Length IN BITS | short | Length of the body in bits. | |||
Reliable frame index | uint24le | only if reliable | |||
Sequenced frame index | uint24le | only if sequenced | |||
Order | Ordered frame index | uint24le | only if ordered | ||
Order channel | byte | ||||
Fragment | Compound size | int | only if fragmented | ||
Compound ID | short | ||||
Index | int | ||||
Body | ceil(length/8) bytes |
The reliability types are as follows:
ID | Name | Reliable | Ordered | Sequenced |
---|---|---|---|---|
0 | unreliable | |||
1 | unreliable sequenced | x | x | |
2 | reliable | x | ||
3 | reliable ordered | x | x | |
4 | reliable sequenced | x | x | x |
5 | unreliable (+ ACK receipt) | |||
6 | reliable (+ ACK receipt) | x | ||
7 | reliable ordered (+ ACK receipt) | x | x |
Sequenced implies ordered.
Game Packet
Packet ID | Field Name | Field Type | Notes |
---|---|---|---|
0x8e | Body | bytes | Single packet of the GAME protocol. |
NACK
Packet ID | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|
0xa0 | Record count | short | |||
Record | Is Range? | byte | 0 for range, 1 for no range | ||
No Range | Index | uint24le | |||
Range | Start Index | uint24le | |||
End Index | uint24le |
ACK
Packet ID | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|
0xc0 | Record count | short | |||
Record | Is Range? | byte | 0 for range, 1 for no range | ||
No Range | Index | uint24le | |||
Range | Start Index | uint24le | |||
End Index | uint24le |