Home

lengthfollowed

Lengthfollowed is a design convention in data encoding and communication protocols in which each variable-length field is preceded by a length indicator that specifies the number of bytes that follow. This arrangement allows parsers to determine field boundaries without relying on delimiters or external separators, improving robustness and memory safety in both binary and text formats.

In practice, lengthfollowed overlaps with and is often part of length-prefixed schemes such as TLV (Type-Length-Value).

Examples: An 8-bit length prefix followed by payload where length indicates number of payload bytes. A protocol

Advantages include deterministic parsing, improved validation, and support for streaming parsing. Limitations include potential overhead, endianness

See also: length-prefixed encoding, TLV, framing, streaming parser.

A
length
field
may
be
fixed-size
(8,
16,
32
bits)
or
use
a
variable-length
encoding.
The
essential
aspect
is
the
immediate,
unambiguous
coupling
of
length
and
payload
data.
using
a
4-byte
big-endian
length
prefix
before
a
message
body.
A
string
encoding
that
stores
length
then
UTF-8
bytes.
If
the
declared
length
exceeds
a
negotiated
maximum,
or
the
payload
cannot
be
delivered,
the
parser
must
reject
to
prevent
resource
exhaustion.
handling,
and
the
need
for
strict
length
validation
to
avoid
vulnerabilities
such
as
integer
overflow
or
denial
of
service.
Implementation
details
vary
by
protocol,
but
the
core
principle
remains
a
length
indicator
that
directly
governs
the
size
of
the
following
data
block.