background image

MANUEL STA46 

Modbus TCP 

JP Viskovic 30/08/2005 OEE-F 

 

1-3 

Modbus TCP frame Format 

 
A dedicated header is used on TCP/IP to identify the MODBUS Application Data Unit. It is called the 
MBAP header (MODBUS Application Protocol header). 
This header provides some differences compared to the MODBUS RTU application data unit used on 
serial line: 

 

The MODBUS ‘ slave address’ field usually used on MODBUS Serial Line is replaced by a single 
byte ‘ Unit Identifier’ within the MBAP Header. The ‘ Unit Identifier’ is used to communicate via 
devices such as bridges, routers and gateways that use a single IP address to support multiple 
independent MODBUS end units. 

 

All MODBUS requests and responses are designed in such a way that the recipient can verify that 
a message is finished. For function codes where the MODBUS PDU has a fixed length, the function 
code alone is sufficient. For function codes carrying a variable amount of data in the request or 
response, the data field includes a byte count. 

 

When MODBUS is carried over TCP, additional length information is carried in the MBAP header to 
allow the recipient to recognize message boundaries even if the message has been split into 
multiple packets for transmission. The existence of explicit and implicit length rules, and use of a 
CRC-32 error check code (on Ethernet) results in an infinitesimal chance of undetected corruption 
to a request or response message. 

 

 

 

1-3-0 

MBAP Header description 

The MBAP Header contains the following fields: 

 

Fields Length 

Description 

Client 

Server 

Transaction 

Identifier 

2 Bytes 

Identification of a 

MODBUS Request / 

Response transaction 

Initialized by the 

client ( request) 

Recopied by the 

server from the 

received request 

Protocol 

Identifier 

2 Bytes 

0 = MODBUS protocol 

Initialized by the 

client ( request) 

Recopied by the 

server from the 

received request 

Length 

2 Bytes 

Number of following 

bytes 

Initialized by the 

client ( request) 

Initialized by the 

server (Response) 

Unit Identifier 

1 Byte 

Identification of a 

remote slave 

connected on a serial 

line or on other buses 

Initialized by the 

client ( request) 

Recopied by the 

server from the 

received request 

 

The header is 7 bytes long: 

 

Transaction Identifier 

- It is used for transaction pairing, the MODBUS server copies in the 

response the transaction identifier of the request. 

 

Protocol Identifier 

– It is used for intra-system multiplexing. The MODBUS protocol is identified 

by the value 0. 

 

Length 

- The length field is a byte count of the following fields, including the Unit Identifier and 

data fields. 

 

Unit Identifier 

– This field is used for intra-system routing purpose. It is typically used to 

communicate to a MODBUS or a  serial line slave through a gateway between an 
Ethernet TCP-IP network and a MODBUS serial line. This field is set by the MODBUS Client in the 
request and must be returned with the same value in the response by the server. 
 

All Modbus/TCP ADU are sent via TCP on registered port 502.

 

Summary of Contents for CS CJ1W-ETN21

Page 1: ...1 SYSMAC CS CJ Serie CS1W ETN21 CJ1W ETN21 MODBUS TCP Quick Start Manual MANUEL STA46...

Page 2: ...ron Certain details are voluntarily occulted not to cause confusion Despite everything the care taken to the realization of this documentation omron could not be held for person in charge for the erro...

Page 3: ...MBAP Header description 5 1 4 FUNCTION CODE 6 1 4 0 I O memory area CIO Read Multiple Coils 6 1 4 1 I O memory area CIO Read Multiple Coils 7 1 4 2 I O memory area DM Read Multiple Registers 8 1 4 3...

Page 4: ...te Multiple Registers 1 2 Memory map 1 2 0 Used by ModbusTCP PLC program Modbus process Type Memory address Descriptions Work Area W480 511 Used for counter and calculation Receive Area CIO 5800 6000...

Page 5: ...rruption to a request or response message 1 3 0 MBAP Header description The MBAP Header contains the following fields Fields Length Description Client Server Transaction Identifier 2 Bytes Identificat...

Page 6: ...001 04 to 0002 06 Request Response Data Data Function Code 0x01 Function Code 0x01 Starting Address H 0x00 Byte Count 0x03 Starting Address L 0x14 Coil Status 27 20 0xCD Quantity of Coils H 0x00 Coil...

Page 7: ...0002 06 Request Response Data Data Function Code 0x02 Function Code 0x02 Starting Address H 0x00 Byte Count 0x03 Starting Address L 0x13 Coil Status 27 20 0xCD Quantity of Coils H 0x00 Coil Status 35...

Page 8: ...Byte 0x03 Byte Count 1 Byte N x 2 Register Value N x 2 Bytes N Quantity of Registers Example read 3 words DM 1000 to DM 1002 Request Response Data Data Function Code 0x03 Function Code 0x03 Starting...

Page 9: ...2 Register Value N x 2 Bytes N Quantity of Registers Example read 3 words CIO 1000 to CIO 1002 Request Response Data Data Function Code 0x04 Function Code 0x04 Starting Address H 0x03 Byte Count 0x06...

Page 10: ...oil CIO 0002 02 ON Request Response Data Data Function Code 0x05 Function Code 0x05 Output Address H 0x00 Output Address H 0x00 Output Address L 0x22 Output Address L 0x22 Output Value H 0xFF Output V...

Page 11: ...nse Length Data Function Code 1 Byte 0x06 Register Address 2 Bytes 0x0000 0x7FFF Register Value 2 Bytes 0x0000 0xFFFF Example write h3AC5 to DM 2000 Request Response Data Data Function Code 0x06 Funct...

Page 12: ...x0000 Data N x 2 Bytes 2 to 125 0x0002 to 0x007D Bytes Response Length Data Function Code 1 Byte 0x08 Sub function Code 2 Bytes 0x0000 Data N x 2 Bytes Same as request data Example sending 0xA537 Requ...

Page 13: ...1 Byte 0x10 Starting Address 2 Bytes 0x0000 0x17FF Quantity of Registers 2 Bytes 1 123 0x7B Example write 2 words into DM1000 1001 Request Response Data Data Function Code 0x10 Function Code 0x10 Sta...

Page 14: ...1 Byte Function Code 0x80 Exception Code 1 Byte 01 02 or 03 Exception Code Name 01 ILLEGAL FUNCTION 02 ILLEGAL DATA ADDRESS 03 ILLEGAL DATA VALUE 1 6 Status counter Counter Channel Descriptions Except...

Reviews: