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
---