Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:RakNet

From SAS Gaming Wiki

Template:Exclusive

RakNet is a networking library and protocol for multiplayer games. It runs over UDP and provides connection management, configurable reliability and ordering, sequencing, and fragmentation.

UDP does not guarantee delivery or ordering. RakNet supports different delivery modes, so applications can request reliability or ordering when needed.

The source code for RakNet is available in the archived source repository.

Use in Bedrock Edition

Minecraft:NetherNet became the default transport for Minecraft:Bedrock Dedicated Server in Minecraft:26.50.<ref>Template:Cite</ref> RakNet is deprecated in Minecraft:26.60, which removes client support for it.<ref>Template:Cite</ref>

Libraries

The following libraries implement RakNet. Supported features and protocol versions vary between implementations.

Name Description Language License
go-raknet RakNet implementation written in Go. Go MIT
RakNet Asynchronous RakNet implementation written in Rust. Rust Apache-2.0
PieRakNet RakNet implementation written in Python. Python GPL-3.0
Cloudburst Network Network components used by CloudburstMC projects. Java Apache-2.0
rak-net Python RakNet implementation originally developed for Podrum. Python GPL-2.0
JRakNet Java implementation of the RakNet protocol. Java MIT
netty-raknet RakNet implementation for Netty. Java MIT
JRakLibPlus RakNet server library based on RakLib and JRakLib. Java LGPL-3.0
RakLib Lightweight PHP RakNet server implementation. PHP GPL-3.0
raknet UDP networking library for Node.js that follows the RakNet protocol. JavaScript MIT
PyRakLib Python port of RakLib that follows the RakNet protocol. Python GPL
rust-raknet RakNet implementation written in Rust. Rust MIT
Baltica Bedrock toolkit that includes a RakNet implementation. TypeScript See repository
RakNet.Py RakNet implementation written in Python. Python GPL-2.0
LavishMC RakNet C++ fork of the original RakNet implementation. C++ BSD
RakNet (original) Original C++ RakNet implementation. C++ BSD-2-Clause

Data types

The types below describe the packet layouts on this page. Multi-byte integers are big-endian unless stated otherwise; 24-bit indices are little-endian. Address structures have their own byte order.<ref>RakNet: BitStream go-raknet: Frame encoding</ref>

Type Size Description
Byte 1 byte Unsigned 8-bit value.
Boolean 1 byte Template:Cd is false; Template:Cd is true.
Short 2 bytes Signed 16-bit integer.
Unsigned Short 2 bytes Unsigned 16-bit integer.
Int 4 bytes Signed 32-bit integer.
Unsigned Int 4 bytes Unsigned 32-bit integer.
Long 8 bytes 64-bit integer. Whether it represents a signed value depends on the field.
uint24le 3 bytes Unsigned 24-bit little-endian integer, used for datagram sequence numbers and frame indices.
String Variable An unsigned 16-bit byte length followed by that many string bytes.
Magic 16 bytes The fixed Template:Cd value used in offline packets.<ref>RakNet: RakPeer.cpp</ref>
Address 7 bytes (IPv4);
29 bytes (IPv6)
Encodes the address family, address and port. IPv4 address bytes are inverted; the port is big-endian. IPv6 also includes address-family, flow-info and scope fields.<ref name="address-format">go-raknet: Address encoding</ref>

Handshake sequence

The handshake begins with unconnected UDP packets and continues with connection-control messages carried inside RakNet frames.<ref>RakNet: RakPeer.cpp go-raknet: Connection messages</ref>

  1. C→S: Open Connection Request 1
  2. S→C: Open Connection Reply 1 (or Incompatible Protocol)
  3. C→S: Open Connection Request 2
  4. S→C: Open Connection Reply 2. The peers can now exchange framed connection-control messages.
  5. C→S: Connection Request
  6. S→C: Connection Request Accepted
  7. C→S: New Incoming Connection

After this exchange, the RakNet connection is established. Connection Request, Connection Request Accepted, and New Incoming Connection are themselves carried inside frames. In Minecraft:Bedrock Edition, game packets are carried in RakNet frames as described at Game Packet.

Packets

Offline packet IDs identify UDP datagrams; connected message IDs identify the payload inside a frame. The handshake tables below describe the layout with RakNet security disabled. Optional security handshakes and connection passwords are not included. Field details can vary by implementation.<ref>RakNet: Message identifiers go-raknet: Frame encoding</ref>

Unconnected Ping

The client sends this packet to discover a server. ID Template:Cd is a regular unconnected ping; Template:Cd asks for a response only when the server is accepting new connections. The server replies with Unconnected Pong.

Packet ID Field Name Field Type
0x01, 0x02 Time Long
Magic Magic
Client GUID Long

Unconnected Pong

The server sends this in response to an unconnected ping. It echoes the ping time and includes its GUID and a server ID string. In Minecraft:Bedrock Edition, that string contains server-list information in a semicolon-delimited format; its fields can vary by game version.

Packet ID Field Name Field Type Notes
0x1c Time Long
Server GUID Long
Magic Magic
Server ID String String Carries server-list information.

Connected Ping

This packet measures latency on an established connection. It is commonly sent unreliably.

Packet ID Field Name Field Type
0x00 Time Long

Connected Pong

The receiver replies with the original ping time and its own response time. It is commonly sent unreliably.

Packet ID Field Name Field Type
0x03 Ping Time Long
Pong Time Long

Open Connection Request 1

The first packet in the handshake sequence, sent by the client to the server.

Packet ID Field Name Field Type Notes
0x05 Magic Magic
Protocol version Byte RakNet protocol version used by the client; separate from the Bedrock game protocol version.
Padding Zero bytes Zero padding used to probe the path MTU.

The MTU is inferred from the datagram length, including IP and UDP overhead; it is not a numeric field in this request. The server replies with the selected MTU, or sends Incompatible Protocol if it does not support the client's RakNet protocol version.

Open Connection Reply 1

The second packet in the handshake sequence, sent by the server to the client.

Packet ID Field Name Field Type Notes
0x06 Magic Magic
Server GUID Long
Use security Boolean False for the layout shown here.
MTU Unsigned Short Selected MTU for the connection.

Open Connection Request 2

The third packet in the handshake sequence, sent by the client to the server.

Packet ID Field Name Field Type
0x07 Magic Magic
Server Address Address
MTU Unsigned Short
Client GUID Long

Open Connection Reply 2

The fourth packet in the handshake sequence, sent by the server to the client.

Packet ID Field Name Field Type Notes
0x08 Magic Magic
Server GUID Long
Client Address Address
MTU Unsigned Short
Encryption enabled Boolean False for the layout shown here.

Connection Request

The client sends this framed message after Open Connection Reply 2 to continue the RakNet handshake.

Packet ID Field Name Field Type
0x09 GUID Long
Time Long
Use security Boolean

Connection Request Accepted

The server sends this packet to accept the client's connection request.

Packet ID Field Name Field Type Notes
0x10 Client address Address
System index Unsigned Short System index assigned by the server.
Internal addresses Address array Internal server addresses; the count varies by implementation, commonly 10 or 20.<ref name="accepted-addresses">go-raknet: Connection Request Accepted</ref>
Request time Long Timestamp from the corresponding Connection Request.
Time Long Server acceptance time.

New Incoming Connection

The client sends this packet to confirm that it received the server's acceptance.

Packet ID Field Name Field Type Notes
0x13 Server address Address
Internal addresses Address array Internal client addresses; the count varies by implementation, commonly 10 or 20.<ref>go-raknet: New Incoming Connection</ref>
Ping time Long Server acceptance timestamp echoed by the client.
Pong time Long Time at which the client sends this message.

Disconnection Notification

This packet notifies the other peer that the sender is disconnecting.

Packet ID Field Name Field Type Notes
0x15 No payload Signals that the sender is disconnecting.

Incompatible Protocol

The server sends this packet when it does not support the RakNet protocol version used by the client.

Packet ID Field Name Field Type
0x19 Protocol Byte
Magic Magic
Server GUID Long

Frame Set Packet

This packet carries one or more frames between connected peers.

Packet ID Field Name Field Type Notes
0x80–0x9f Sequence number uint24le Used for building ACK and NACK ranges
Frames Flags Byte Top 3 bits give the reliability type, fourth bit is 1 when the frame is fragmented and part of a compound.
Body bit length Unsigned Short Length of this frame's body in bits.
Reliable frame index uint24le Only if reliable, used for detecting frame level duplication
Sequenced frame index uint24le Only if sequenced, used for discarding out-of-date packets
Order
(if ordered or sequenced)
Ordered frame index uint24le Tells the receiver the correct order in which to deliver frames to the application
Order channel Byte Maximum of 32 channels
Fragment
(only if fragmented)
Compound size Unsigned Int Number of fragments in the split message.
Compound ID Unsigned Short Identifies which compound this fragment is part of
Index Unsigned Int Zero-based index of this fragment in the split message.
Body ceil(length/8) bytes

A frame-set header has bit Template:Cd set and ACK/NACK bits Template:Cd clear. The remaining bits are flags, so the header is not a fixed message ID. A frame set can contain multiple frames.<ref name="frames">go-raknet: Frame encoding</ref>

The reliability values transmitted in the frame header are as follows:

ID Name Reliable Sequenced Ordered
0 unreliable
1 unreliable sequenced x
2 reliable x
3 reliable ordered x x
4 reliable sequenced x x

The original RakNet API also defines receipt modes 5, 6, and 7. These are encoded as wire values 0, 2, and 3 respectively; receipt notification is handled locally.<ref>RakNet: Reliability layer</ref>

Sequenced delivery discards older packets when a newer packet has arrived. Ordered delivery preserves the order of reliable packets within a channel.

Game Packet

This Bedrock-specific message carries a batch of game packets inside a RakNet frame.

Packet ID Field Name Field Type Notes
0xfe Body bytes In Minecraft:Bedrock Edition, the body contains a batch of game packets. Framing and compression are described in Bedrock Edition protocol.

Packet definitions are listed at Minecraft:Bedrock Edition protocol/Packets.

NACK

This packet reports datagrams that were not received so the sender can retransmit them when required.

Packet ID Field Name Field Type Notes
0xa0 Record count Unsigned Short Number of records in the packet
Records Is Single? boolean False for range, True for no range
No Range, if is_single == true Sequence number uint24le Datagram sequence number in this record.
Range, if is_single == false Start Sequence number uint24le First datagram sequence number in the inclusive range.
End Sequence number uint24le Last datagram sequence number in the inclusive range.

A NACK reports frame-set sequence numbers that were not received, prompting retransmission where required.

ACK

This packet acknowledges datagrams received from the other peer.

Packet ID Field Name Field Type Notes
0xc0 Record count Unsigned Short Number of records in the packet
Records Is Single? boolean False for range, True for no range
No Range, if is_single == true Sequence number uint24le Datagram sequence number in this record.
Range, if is_single == false Start Sequence number uint24le First datagram sequence number in the inclusive range.
End Sequence number uint24le Last datagram sequence number in the inclusive range.

An ACK reports frame-set sequence numbers that were received. Both ACK and NACK packets can contain multiple records.

References

Template:Reflist

Navigation

Template:Navbox Bedrock Edition