Home

MBAP

MBAP stands for Modbus Application Protocol header, a data framing header used in Modbus communications over TCP/IP. It forms the first part of every Modbus TCP message and precedes the Modbus Protocol Data Unit (PDU). The header is seven bytes long and provides a lightweight mechanism to multiplex multiple transactions on a single TCP connection.

The MBAP header contains four fields:

- Transaction Identifier (2 bytes): a value used to match requests with their corresponding responses, enabling proper

- Protocol Identifier (2 bytes): reserved for future use and typically set to 0 for Modbus; some

- Length (2 bytes): the number of bytes that follow the Length field, including the Unit Identifier

- Unit Identifier (1 byte): identifies a remote slave or device. In Modbus TCP, this is often set

The PDU that follows begins with a function code byte, which defines the operation to perform, followed

Endianness for the fields is in network byte order (big-endian). The maximum practical MBAP length is constrained

Overall, the MBAP header enables reliable, multiplexed Modbus communications over TCP/IP and is a key component

---

request-response
pairing
in
asynchronous
communication.
implementations
may
repurpose
it
for
protocol
multiplexing.
and
the
PDU.
to
1
or
used
to
route
messages
to
a
specific
device
behind
a
gateway
or
bridge.
by
data.
The
MBAP
header
itself
does
not
contain
the
function
code;
it
only
frames
the
message
and
provides
addressing
and
length
information.
MBAP-enabled
communication
distinguishes
Modbus
TCP
from
Modbus
RTU
or
Modbus
ASCII,
which
use
different
framing
and
do
not
employ
the
MBAP
header.
by
the
Modbus
PDU
size,
typically
limiting
the
total
message
to
a
few
hundred
bytes.
of
the
Modbus
TCP
protocol.