โ† Back to the chapter

Technical detail ยท Modbus and the Register Contract

Read the seven-byte Modbus TCP header

In Modbus TCP, the Modbus Application Protocol (MBAP) header carries transaction and routing fields. The protocol data unit (PDU) carries the function and its data. Inspect Figure 5 to see which MBAP fields track a TCP exchange and which field still identifies a downstream serial device.

The Modbus TCP application data unit contains a seven-byte MBAP header followed by a PDU. Transaction, protocol, and length fields are each two bytes; the one-byte Unit Identifier may map through a gateway to a serial device.
A Modbus TCP application data unit combines a seven-byte MBAP header with the operation carried in its PDU.

Read Figure 5 by first splitting the application data unit. Its two parts are the MBAP header and the PDU. The header has three two-byte fields: Transaction Identifier, Protocol Identifier, and Length. It also has a one-byte Unit Identifier, so 2 + 2 + 2 + 1 = 7 bytes. The transaction field pairs each request with its response. The protocol field marks Modbus. At a gateway, the unit field selects the serial target. The PDU then states the function and its data. Keep gateway IP, transaction identity, and unit identity apart so one valid TCP exchange is not credited to the wrong field device.

โ† Back to the chapter