Modbus frame codec

Build a Modbus PDU, watch it go out over serial and over TCP, and see which parts of the Ethernet frame are fossils of an RS-485 bus. Every byte here reproduces a worked example published by the Modbus Organization.

Modbus TCP is a serial protocol wearing a TCP header. That is not an opinion, it is two quotes. The PDU is capped at 253 bytes because "the size constraint inherited from the first MODBUS implementation on Serial Line network (max. RS485 ADU = 256 bytes)" (Application Protocol V1.1b3, 4.1, p5), and the MBAP header spends one of its four fields on a Unit Identifier defined as "Identification of a remote slave connected on a serial line or on other buses" (Messaging on TCP/IP V1.0b, 3.1.3, p5). Both documents are free at modbus.org.

The frame

The serial fossils in a TCP frame

Decode the register data

Published example

Transport

The same value fills the RTU slave address and the MBAP unit id, because the TCP guide says the second replaced the first.

What this tool refuses to do

It will not decode a 32 bit float across two registers without a named vendor profile, and no vendor profile ships, because no meter manual has been sourced and read yet.

The specification defines byte order within a register (big endian, 4.2, p5) and defines no data type wider than a register at all, so there is no published word order to follow. Word order is a vendor convention. Filling one in from a tutorial would be a silent overclaim in a decoder someone trusts against real gear.

Sources

MODBUS Application Protocol Specification V1.1b3, April 26 2012.
MODBUS over Serial Line Specification and Implementation Guide V1.02, Dec 20 2006.
MODBUS Messaging on TCP/IP Implementation Guide V1.0b, Oct 24 2006.
All three published by the Modbus Organization, free, no login, read at the publisher.

The specifications are cited and never redistributed. See sources/SOURCES.md for the audit, the licence position, and the gaps.