ModPackQTModPackQT
TutorialsUnder the Hood
0/4 complete
Sign up free
Under the HoodLesson 1 of 4

Anatomy of a Modbus TCP Frame

Identify every byte in a real Modbus TCP frame.

A Modbus TCP request has two parts: the MBAP header (6 bytes) and the PDU (variable).

MBAP Header (6 bytes): • Bytes 0–1: Transaction ID — the master chooses a number (e.g. 0x0001); the slave echoes it back so responses can be matched to requests. • Bytes 2–3: Protocol ID — always 0x0000 for Modbus. • Bytes 4–5: Length — number of bytes that follow (Unit ID + PDU). • Byte 6: Unit ID — the slave address (same as RTU address).

PDU (Protocol Data Unit): • Byte 0: Function Code (e.g. 0x03 = Read Holding Registers) • Bytes 1–2: Starting address (big-endian) • Bytes 3–4: Quantity of registers (big-endian)

Total for an FC03 request: 6 (MBAP) + 1 (Unit ID) + 1 (FC) + 2 (addr) + 2 (qty) = 12 bytes.

In the sandbox below, click each colored byte chip to see what field it belongs to.

Challenge

Click all 6 byte chips that make up the MBAP header.

Interactive Frame Explorer

Click each byte chip to learn what it carries. The frame below is a real Modbus TCP FC03 request — read 4 holding registers from slave 1.

FC03 Request — Read 4 Holding Registers
00
Transaction
01
Transaction
00
Protocol
00
Protocol
00
Length
06
Length
01
Unit
03
Function
00
Start
00
Start
00
Quantity
04
Quantity
Transaction ID
Protocol ID
Length
Unit ID
Function Code
Start Address
Quantity
← Click a byte chip above to see its explanation here.