A
A
ADKX2021-11-20 00:18:48
Java
ADKX, 2021-11-20 00:18:48

How to understand the size of a packet sent using NETTY?

Hello, I am writing a server (not in java) for a java application using NETTY and I came across the fact that NETTY adds its size to the beginning of the package. And everything would be fine, but it is not quite logical, if it is usually indicated in int16, then here 206 will be like 0xCE01. Help me understand how to parse it, because if I just take 0xCE, I will have an extra byte, and one byte is not enough to indicate the size

Sorry if I formulated the question crookedly, it’s already night and my head doesn’t cook at all

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2021-11-20
@ADKX

I guessed. This is indeed LEB128 :

LEB128 Read-Eval-Print-Loop!

Converts numbers to signed and unsigned LEB128 and displays the results in
base-10, hex, and binary.

> 206
# unsigned LEB128
[206, 1]
[ce, 1]
[11001110, 00000001]

# signed LEB128
[206, 1]
[ce, 1]
[11001110, 00000001]

It's not for nothing that I tried to implement the minecraft protocol on my own.

M
Mikhail Osher, 2015-03-16
@totalcount

And they say that mathematics is not needed for programmers.
// UPD
Refresh the page. The side diagonal changes patterns. And these numbers always turn out. It's obvious. Grade 5 :)

A
Alexey Nikolaev, 2015-03-16
@Heian

This algorithm is still very simple and transparent, indeed, the diagonal is striking. You can even stupidly substitute the generated symbol into the code without looking, and that's it.
In my question , everything is incomparably more complicated - no one has yet been able to solve the mystery of this Japanese genius.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question