Bedrock Wiki
  • Discord
  • Contribute
  • bedrock.dev
  • MS Learn
Beginner's Guide
  • Guide
    • 1. Introduction
      guide
    • 2. Add-Ons Explained
    • 3. Software & Preparation
    • 4. Project Setup
    • 5. Create a Custom Item
    • 6. Create a Custom Entity
    • 7. Blockbench: Modeling, Texturing & Animating
    • 8. Adding a Loot Table, Spawn Rule & Crafting Recipe
  • Extra
    • a. Understanding JSON
    • b. Download Example Packs
    • c. Troubleshooting
      help
    • d. Advanced Manifest
    • e. Format Versions
    • f. Project Setup Android
Animation Controllers
  • Intro to Animation Controllers
    guide
  • Entity Commands
  • AFK Detector
  • Death Commands
  • Molang into Scoreboard
  • Respawn Commands
Blocks
  • General
    • Intro to Blocks
      guide
    • Block Components
    • Block Tags
    • Block States
    • Block Traits
    • Block Permutations
    • Block Events
      Scripts
    • Block Event Migration
      help
    • Blocks as Items
    • Troubleshooting Blocks
      help
  • Visuals
    • Block Culling
    • Block Models
      guide
    • Block Texture Animation
    • Block Texture Variation
    • Block Tinting
  • Tutorials
    • Applying Constant Effects
      Scripts
    • Avoiding State Limit
    • Fake Blocks
    • Ore Loot Tables
      Scripts
    • Precise Interaction
      Scripts
    • Precise Rotation
      Scripts
    • Rotatable Blocks
  • Vanilla Re-Creations
    • Custom Crops
      Scripts
    • Custom Glass
    • Custom Glazed Terracotta
    • Custom Trapdoors
      Scripts
  • Documentation
    • Block Format History
    • Block Shapes
    • Block Sounds
    • Vanilla Block Models
Commands
  • General
    • Intro to Command Blocks
    • Functions
    • Block States
    • Coordinate System
    • NBT Commands
    • Scoreboard Operations
    • Understanding Selectors
  • Commands
    • Damage
    • Execute
    • Playanimation
    • Playsound
  • On Event Systems
    • On Player First Join
    • On Player Join
    • On Player Leave
    • On Player Death
    • On Player Respawn
    • On First World Load
  • Scoreboard Systems
    • Entity Counter
    • Scoreboard Timers
    • Comparing And Retrieving Scores
  • Techniques
    • Execute Logic Gates
    • MBE - Max's Block Entity
    • FMBE - A New Way to Create Display Entities
    • Look Detection
    • Movement Detections
    • Orbital Camera
  • Useful Creations
    • Custom Crafter
    • Multiplayer Position Rearrangement
      function
Concepts
  • contents.json
  • Emojis & Symbols
  • Molang
  • Namespaces
  • Overwriting Assets
  • Raw Text
  • Shaders
  • Sounds
  • Subpacks
  • Text and Localization
  • Texture Atlases
  • textures_list.json
Documentation
  • Shared Constructs
  • Advanced Molang
  • File Types
  • Fog IDs
  • Material Configuration Description
  • Menu Categories
  • Molang Queries
  • Pack Folder Structure
  • Sound Definitions
  • Vanilla Materials
Entities
  • General
    • Intro to Entities BP
      guide
    • Intro to Entities RP
      guide
    • Troubleshooting Entities
      help
    • Entity Events
    • Entity Properties
    • NPC Dialogues
    • Render Controllers
    • Spawn Rules
  • Tutorials
    • Convert Points Between Any Space (World, Entity, Bones)
    • Creating Boats
    • Detecting Other Entities
    • Disabling Team Damage
    • Dummy Entities
    • Entity Attacks
    • Entity Holds Item
    • Entity Movement
    • Entity Timers
    • Flying Entities
    • Introduction to AOE Clouds
    • Invulnerable Entities
    • Look at Entity
    • Sleeping Entities
    • Solid Entities
    • Spawning Tamed Entities
      Scripts
    • Village Mechanic
  • Documentation
    • Dummy Components
    • Non-Mob Runtime Identifiers
    • Projectiles
    • Runtime Identifiers
    • Vanilla Usage Components
    • Vanilla Usage Spawn Rules
Items
  • General
    • Intro to Items
      guide
    • Item Components
    • Item Tags
    • Item Events
      Scripts
    • Item Event Migration
      help
    • Troubleshooting Items
      help
  • Tutorials
    • Custom Armor
    • Custom Food
      Scripts
    • Custom Pottery Sherds
    • Custom Weapons
    • Equipment-Based Commands
    • High Resolution Items
    • Spawning Items
    • Throwable Items
  • Documentation
    • Enchantments
    • Attachables
    • Item Format History
    • Numerical Item IDs
    • Vanilla Item Identifiers
    • Vanilla Usage Components
JSON UI
  • General
    • Intro to JSON UI
      guide
    • Best Practices
      guide
  • Tutorials
    • Adding HUD Elements
    • Aseprite Animations
    • Buttons and Toggles
    • Modifying Server Forms
    • Preserve Title Texts
    • String to Number
  • Documentation
    • JSON UI Documentation
Loot, Recipes & Trading
  • General
    • Trading Behavior
  • Documentation
    • Loot Tables
    • Trade Tables
    • Recipes
    • Item Functions
  • Tutorials
    • Randomized Structure Loot
Meta
  • Add-On Performance
  • Style Guide
  • Useful Links
  • Using Schemas
  • Version Control
  • Q&A
    • Blocks and Items Q&A 2024/08/30
    • Deferred Technical Preview Q&A 2024/02/23
    • GameTest Q&A 2021/08/06
    • Scripting and Editor Q&A 2023/09/22
    • World Generation Q&A 2024/11/15
NBT
  • General
    • .mcstructure
  • Tutorials
    • Experiments in Education Edition
    • Extending Structure Limits
  • NBT in Depth
    • About NBT (Named Binary Tag)
    • NBT Libraries
    • Reading NBT Example
Particles
  • General
    • Intro to Particles
      guide
  • Tutorials
    • Disabling Particles
  • Documentation
    • Vanilla Particles
Scripting
  • General
    • Intro to Scripting
    • What is Script API?
    • API Modules
  • Tutorials
    • Block Placement Prevention
    • GameTests
    • Script Core Features
    • Script Forms
    • Script Requests API
    • Simple Chat Commands
  • Documentation
    • Engine Environment
    • Script Resources
    • Script Watchdog
    • Troubleshooting JavaScript
    • TypeScript
Servers
  • Software
    • Bedrock Server Software
  • Protocols
    • Bedrock Protocol
    • NetherNet Protocol
    • RakNet Protocol
Visuals
  • General
    • Introduction to Entity Visuals
      guide
    • Bedrock Modeling
    • Custom Death Animations
    • Effects in Animations
    • Material Creations
    • Materials
    • Math-Based Animations
    • Skin Packs
  • Tutorials
    • Entity Texture Animation
    • Glowing Entity Texture
    • Hurt Animations
    • Leash Position
    • Player Geometry
    • Remove Entity Shadows
    • Retexturing Spawn Eggs
  • Ideas
    • Structure Presentation
World Generation
  • General
    • Intro to World Generation
      guide
    • Biomes
      guide
    • Feature Types
  • Tutorials
    • Block Conditions for Features
    • Generating Custom Ores
    • Generating Custom Structures
    • Generating Patches
    • Heightmap Noise
  • Documentation
    • Biome Tags

RakNet Protocol

RakNet Protocol
  • RakNet Notes
  • Datatypes
  • Contents
    • Unconnected Pings
    • Unconnected Pongs
    • Open Connection Request 1
    • Open Connection Reply 1
    • Open Connection Request 2
    • Open Connection Reply 2
    • Connection Request
    • Connection Request Accepted
    • New Incoming Connection
    • New Incoming Connection
    • Connected Ping
    • Connected Pong
  • Implementations
  • Sources

Minecraft Bedrock uses multiple different protocols under the hood, one of them is RakNet. RakNet is the main protocol used for external servers, aka the server you are likely playing on... maybe it is a featured server or the server run by your friend.

One of the most important aspects is that RakNet is based on Udp. Bedrock uses the port 19132 (Ipv4, use 19133 for ipv6) as its default RakNet port for MCBE servers, you can still change the port as you wish.

RakNet Notes ​

  • The offline message id will always be: 0x00ffff00fefefefefdfdfdfd12345678 - this series of bytes will be referred to as Magic.
  • The offline message id is sent with unconnected messages such as unconnected pings and pongs.
  • The first byte is used to identify the type of the packet.

Datatypes ​

TypeSizeRangeNotes
u8 (byte)10-255A single Byte
i16 (short)2-32768 - 32767Signed 16-bit integer
u16 (unsigned short)20 - 65535Unsigned 16-bit integer
u24 (unsigned int24)30 - 2^24-1Unsigned 21-bit integer
i64 (long)8-2^63 to 2^63-1Signed 64-bit integer
bool (boolean)10 - 10 is false, while 1 is true
StringN/AA String prefixed by an u16 (encoded as Big Endian), which depicts the length
Guid8A Globally Unique Identifier that is stored as an i64
Socket Address71 byte for the ip version 4/6, 4 for the IP and 2 for the port
Magic16Special constant byte sequence 0x00ffff00fefefefefdfdfdfd12345678

Contents ​

  • Unconnected Pings
  • Unconnected Pongs
  • Open Connection Request 1
  • Open Connection Reply 1
  • Open Connection Request 2
  • Open Connection Reply 2 (From here on, the RakNet connection is established, and all RakNet messages are contained in a Frame Set Packet)
  • Connection Request
  • Connection Request Accepted
  • New Incoming Connection

Unconnected Pings ​

Minecraft Bedrock will send out a message to all listed servers (and the local network) to check if any games are available and retrieve the MOTD from the game. These messages are known as unconnected pings and are structured in this format:

0x01 | client alive time in ms (unsigned long long) | magic | client GUID

Unconnected Pongs ​

After this message, the server will respond with something called an unconnected pong. The reason these messages are unconnected is that the client has not established a connection to the server. This is the format of an unconnected pong:

0x1c | client alive time in ms (recorded from previous ping) | server GUID | Magic | string length | Edition (MCPE or MCEE for Education Edition);MOTD line 1;Protocol Version;Version Name;Player Count;Max Player Count;Server Unique ID;MOTD line 2;Game mode;Game mode (numeric);Port (IPv4);Port (IPv6);

Example:

MCPE;Dedicated Server;527;1.19.1;0;10;13253860892328930865;Bedrock level;Survival;1;19132;19133;

The client doesn't seem to use the gamemode or the numeric value for the gamemode.

Open Connection Request 1 ​

(Client -> Server)

The client sends this when attempting to join the server

0x05 | Magic | Protocol version (currently 11 or 0x0b) | RakNet Null Padding

The null padding seems to be used to discover the maximum packet size the network can handle.

The client will send this to the server with decreasing null padding, until the server responds with a Open Connection Reply 1

Open Connection Reply 1 ​

(Server -> Client)

The server responds with this once the client attempts to join

0x06 | magic | server GUID | ServerHasSecurity (boolean) | Cookie (uint32, if server has security) | MTU Size (Unsigned short)

This is the first half of the handshake between the client and the server.

Open Connection Request 2 ​

(Client -> Server)

The client responds with this after they receive the open connection reply 1 packet.

0x07 | magic | Cookie (uint32, if server has security) | Client supports security (Boolean(false), always false for the vanilla client, if server has security) | server Address | MTU Size (Unsigned short) | client GUID (Long)

Open Connection Reply 2 ​

(Server -> Client)

This is the last part of the handshake between the client and the server.

0x08 | magic | server GUID (Long) | client Address | MTU Size | security(Boolean)

From here on, all RakNet messages are contained in a Frame Set Packet.

Connection Request ​

(Client -> Server)

This is the part where the client sends the connection request.

0x09 | client GUID (Long) | Request timestamp (Long) | Secure (Boolean)

Connection Request Accepted ​

(Server -> Client)

The server sends this packet in response to the incoming connection request.

0x10 | client Address | System index (Short, unknown what this does. 0 works as a value (Minecraft client sends 47)) | System adresses ([]Address) | Ping time (Long) | Pong Time (Long)

New Incoming Connection ​

(Client -> Server)

Our RakNet connection is now fully successful.

0x13 | server Address | internal Adress ([20(maybe 10)]Address) (i use 255.255.255.255:0) | Ping time (Long) | Pong Time (Long)

TIP

The next two packets (and the first Minecraft Protocol packet) are all sent together as one by the vanilla client. The RakNetProtocol allows for them to be sent separately too, however, servers with a custom raknet implementation might not always handle this case because this never occurs within the vanilla client.

New Incoming Connection ​

The client sends this packet in response to Connection Request Accepted.

0x13 | serverAddress (uint8) | clientMachineAddresses (address[10], Minecraft sends only one ipv6 together with a placeholder (see below) instead of the other 9) | clientSendTime (uint64) | serverSendTime (uint64)

placeholder for the other clientMachineAddresses (a.k.a. Internal Addresses):

0xd4 0x0b 0xa7 0x86 0xdd 0x98 0x33 0x00 0x00 each byte replaces one of the 9 missing clientMachineAddresses

After having sent this packet, you must periodically send a Connected Ping to keep the connection alive. The server also sometimes sends a Connected Ping, respond with a Connected Pong.

Connected Ping ​

The client sends this packet immediately after/with New Incoming Connection. This packet should be sent as unreliable. The client/server will respond to this with a Connected Pong.

0x00 | Time since start (uint64)

Connected Pong ​

The client or server sends this packet after having received a Connected Ping. This packet should be sent as unreliable.

0x00 | Time since start client (uint64) | Time since start server (uint64)

Implementations ​

Not everything can be explained in great detail via documentation, that's why looking at existing implementations is very helpful. Here is list of RakNet Protocol implementations

NameDescriptionLanguage
RakNet (Official)RakNet is a cross platform, open source, C++ networking engine for game programmersC++
bedrock-crustaceans/raknetRakNet implementation in RustRust
NetrexMC/RakNetRakNet implementation in RustRust
rust-raknetRakNet Protocol implementation by RustRust
transport-raknetnetty-transport-raknetJava
RakLibRakNet server implementation written in PHPPHP
go-raknetGo library implementing a basic version of the RakNet protocolGo
raknet-pythonPython bindings for RakNet, a cross-platform networking engine for game programmersPython
PieRakNetRakNet implementation, written in Python. Created for PieMCPython
JSPrismarine/raknetJavascript, Typescript

Sources ​

TIP

If you are interested and want to read more about RakNet here is the documentation for the Bedrock Protocol and RakNet:

RakNet Protocol DocumentationOther RakNet Protocol Documentation

This page is a WIP, feel free to contribute as it is still being worked on.

Contributors

Edit RakNet Protocol on GitHub

Bedrock Wiki by Bedrock OSS

"Minecraft" is a trademark of Mojang AB.

Bedrock OSS, Bedrock Wiki and bedrock.dev are not affiliated in any way with Microsoft or Mojang AB.

  • Privacy Policy
  • Join our Discord
  • Learn how to Contribute
  • Visit our Repository