up: embedded systems - modbus  
embedded systems - modbus - message format - TCPWhat links here?
The TCP port used is: 502.

Request Format:
NameLengthFunction
Transaction IdentifierMBAP2For synchronization between messages of server and client
Protocol identifier20 for Modbus/TCP
Length field2Number of remaining bytes in this frame
Unit identifier1Unit address (255 if not used)
Function codePDU1Function codes as in other variants
Address of first register2Address of the first register
Number of registers2Number of registers


Response:
NameLengthFunction
Transaction IdentifierMBAP2For synchronization between messages of server and client
Protocol identifier20 for Modbus/TCP
Length field2Number of remaining bytes in this frame
Unit identifier1Unit address (255 if not used)
Number of Bytes followingPDU1Number of Bytes following
DataNData


MBAP Header = Modbus Application Header
PDU = Protocol Data Unit

Sample Master to Slave message:
position00 0102 0304 05060708 0910 11
value12 3400 0000 062550300 0100 01


Explanation:
PositionLengthValueMeaning
00 01212 34transaction id
02 03200 00Protocol identifier (high byte first)
04 05200 06Number of bytes following (high byte first)
061255slave address (255 = not used
07103function code
08 09200 01first register to be returned (high byte first)
10 11200 01number of registers to be returned (high byte first)



Simply Modbus: Modbus TCP Protocol
Wikipedia: Modbus TCP
embedded systems - modbus - message format - TCP
tk:tk_menus
programming:c:time
programming - load a bitmap (bmp) file
programming - DDE
programming:windows:WM_SIZE
filename:embedded systems - modbus - message format - TCP
filename:embedded%20systems%20%2D%20modbus%20%2D%20message%20format%20%2D%20TCP
last edit:May 19 2026 14:04:06 (63 days ago)
ct = 1784674807.000000 = July 21 2026 19:00:07
ft = 1779213846.000000 = May 19 2026 14:04:06
dt = 5460961.000000