RecordFlux icon indicating copy to clipboard operation
RecordFlux copied to clipboard

Variable-length integer encoding

Open treiher opened this issue 6 years ago • 1 comments

Context and Problem Statement

In some protocols, the length field is encoded using a variable-length encoding scheme. In MQTT, such an encoding is used for the Remaining Length field. There are multiple variants of variable-length encoding of integers.

Examples

Variable-Length Quantity (VLQ)

VLQ is used by:

Little Endian Base 128 (LEB128)

LEB128 is used by:

MQTT

Variable Byte Integer (equivalent to ULEB128)

QUIC

Variable-Length Integer Encoding

Bluetooth L2CAP

Protocol/Service Multiplexer - PSM (2 octets (minimum)) The PSM field is at least two octets in length. All PSM values shall have the least significant bit of the most significant octet equal to 0 and the least significant bit of all other octets equal to 1. Note: This means that all PSMs are odd numbers and that the end of a PSM can be easily found by searching for the first even octet.

(Bluetooth Core Specification v5.2 - Vol 3, Part A, 4.2)

treiher avatar Mar 18 '18 16:03 treiher

It seems not to be possible to specify MQTT with ASN.1 in combination with ACN. ACN only supports the following encodings for integers: pos-int, twos-complement, BCD, ASCII.

treiher avatar Mar 18 '18 16:03 treiher