This protocol aims to use less bandwidth sending big packets / chunks of smaller packets compressed using DEFLATE. It works encapsulating raw packets into this protocol, without modifying them. It follows a mixed approach, letting normal packets work and handling compressed packet seamlessly. Both parties must support this protocol, so a Handshake system exists.
All numbers are Big-endian
Packet ID | Field Name | Type | Notes |
---|---|---|---|
0x99 | Action | byte | 0 start, 1 stop, 2 send, 3 ACK |
Message ID | short | sent if Action >= 2 | |
Message Index | short | starting from 0, sent if Action >= 2 | |
Message Count | short | sent if Action == 2 | |
Data Length | short | sent if Action == 2 | |
Data | byte array | DEFLATE Data, sent if Action == 2 |
The handshake is needed so servers and proxies are able to know if the other party supports the DEFLATEPacket. The handsake will be sent by the connecting party, the proxy or client. The packet can be sent anytime.
- C = client / proxy
- S = Server
[C-->S] DEFLATEPacket (Action = 0)
- Wait for
[S-->C] DEFLATEPacket (Action = 0)
- If not received, the server does not support DEFLATEPacket, then stop
[S-->C] DEFLATEPacket (Action = 0)
- Handshake completed
The server or the proxy/client can stop DEFLATEPacket support anytime.
[C<-->S] DEFLATEPacket (Action = 1)
- After that, the party replies with
DEFLATEPacket (Action = 1)
- DEFLATEPacket support finished. You can start again using the handshake anytime
Each data packet sent contains 3 additional fields, the Message ID, Message Count and Message Index. These fields are used to reorder the packet, notify receival and request lost packets.
Each time you receive a DEFLATEPacket with data (Action = 2), you've to reply with one that has Action = 3, the same Message ID and the same Message Index. If you don't receive that packet, the other party will resend it.
If a packet with the same Message Index + ID is received, it is a duplicated packet. You can safely drop it.
- After the specified number of packets have been received for a given Message ID, they have to bereordered and joined. The packet with the lower Message Index will be the first, then the next one...
- Then, you join all the data and INFLATE it (gzip DEFLATE). Then, parse it following the DEFLATE Data structure, and send packets back to the party / handle them. You don't have to worry about lost packets, they will be handled seamlessly using the normal protocol.
- Length short: (if length == 0xFFFF, stop)
- sent if length != 0xFFFF:
- RAW Raknet Packet