pmmp / RakLib

RakNet server implementation written in PHP
Other
86 stars 38 forks source link

Wrong max encapsulated packet header size. #225

Closed loudblow closed 9 months ago

loudblow commented 10 months ago

Why is it counted as 20 when the correct size is 23? https://github.com/pmmp/RakLib/blob/dc035a7b62e2594dd2b351bd8ec219c9a9595587/src/generic/SendReliabilityLayer.php#L135

You can calculate this using these lines: https://github.com/pmmp/RakLib/blob/dc035a7b62e2594dd2b351bd8ec219c9a9595587/src/protocol/EncapsulatedPacket.php#L80

1 byte (flags) + 2 bytes (payload length) + 3 bytes (reliable index) + 3 bytes (sequence index) + 3 bytes (order index) + 1 byte (order channel) + 4 bytes (compound size) + 2 bytes (compound id) + 4 bytes (compound index) = 23

dktapps commented 10 months ago

Interesting catch, thanks.

That being said, this will never normally show up in Minecraft usage, as it would require the usage of RELIABLE_SEQUENCED.

loudblow commented 10 months ago

Anyways it would be nice to fix this. I'm implementing my own RakNet library and have found that all the unofficial libraries and documentation have a maximum encapsulated packet (also known as a frame or message) header size of 20, but my calculations don't match that number.