Confused: Modbus TCP vs. Modbus RTU Over TCP

D

Thread Starter

db

After much reading, I have nwo gotten myself confused as to the differences between 'Modbus TCP' and 'Modbus RTU over TCP'

I am building up a Modbus message to transmit over ethernet (PC as Master, PLC as Slave). Using http://www.simplymodbus.ca/TCP.htm as an easy to understand guide I have built up a request:
<pre>
-- MBAP Header ----------------------------
[Transaction ID] (2 bytes)
[Protocol ID] (2 bytes)
[Message Length] (2 bytes)
[Unit ID] (1 byte)
-- PDU ------------------------------------
[Function Code] (1 byte)
[1st Register Address] (2 bytes)
[Total Number of Registers] (2 bytes)
-------------------------------------------
</pre>
(The message has been built up as an array of bytes using hex values).

The array of bytes is send on an open socket connection using CAsyncsocket::Send (C++, MFC).

I believed that this is Modbus RTU over TCP. Is that correct? It's just the page I linked to above seems to refer to this structure as Modbus TCP.

I understand that there are protocol specifications available but after reading them, I am confused. Which is why I am hoping someone here could give me a simple explanation :)

Also, are there any advantages to using one version rather than the other? I am interfacing to the standard ethernet port on the front of an M340 PLC Processor.

Thanks
 
> differences between 'Modbus TCP' and 'Modbus RTU over TCP'

Within the specification you can only read about Modbus TCP.

The Modbus TCP telegrams are the same as Modbus RTU except the checksum is omitted in Modbus TCP.

Modbus RTU over TCP might be something not standard. E.g. there the checksum may also been send.
 
MBAP is the "normal" Modbus TCP specification. Notice the MBAP doesn't contain a CRC, where Modbus RTU over TCP/IP does contain the CRC.

Modbus RTU over TCP/IP is typically used by serial servers where you can have an Modbus Ethernet client communicating with multiple Modbus RTU-RS485 slaves, by way of a serial server. The serial server strips off the Ethernet section, and forwards the Modbus RTU message on to the serial port/s.
 
Hello,

MODBUS TCP is a protocol that has a specification.

MODBUS RTU and MODBUS ASCII are protocols that have specifications.

TCP/IP is a protocol that has a specification.

MODBUS over TCP means a MODBUS RTU packet wrapped in a TCP packet. (A)

MODBUS TCP means a MODBUS TCP packet wrapped in a TCP packet. (B)

A and B are not compatible. They transfer like data but have different structures.

I have never seen a MODBUS ASCII packet wrapped in a TCP packet but nothing says it cannot be done.

Good luck,

Mark
http://www.peakhmi.com/
 
Standard Modbus RTU is meant for transmission over serial lines (RS232 or RS485 are the most common). The message starts with a one byte Slave ID and ends with a two byte CRC. Sometimes the RTU message is run through a gateway onto ethernet without actually changing any of the bytes in the message. This is commonly called "RTU over TCP".

There is a different specification for Modbus TCP where the message bytes are modified to add the 6 byte MBAP header and remove the two byte CRC.

The message in your example is Modbus TCP since it has the 6 byte header and no CRC at the end.

There is no significant advantage to using on or the other. Most slave devices (called servers in Modbus TCP) only support one or the other. It's typically based on the type of connector. Since the M340 PLC has an ethernet port on it, I suspect it supports Modbus TCP.

Modbus RTU is typically sent out a serial port connector and can then be converted to "RTU over TCP" using an ethernet gateway.

Some gateways will also change the message bytes to convert the Modbus RTU message into a Modbus TCP message.
 
Top