What is Modbus TCP/IP ? | Modbus Tcp/ip vs Ethernet ip

Today we’ll discuss about Modbus TCP/IP, also known as Modbus-TCP is simply the Modbus RTU protocol with a TCP interface that runs on Ethernet.

Modbus protocol is one of the oldest and the most popular communication protocol used in the field of industrial automation.

Modbus is the communication protocol first published by Modicon in 1979, incorporated for the industrial automation systems and to use with its Modicon Programmable Logic Controllers (PLCs).

Modbus uses a common language for devices and equipment to communicate with one and another. Modbus communication protocol exist for serial port as well as Ethernet port.

The most commonly used Modbus communication protocols are :-

Modbus TCP/IP


Today we’ll discuss about Modbus TCP/IP, also known as Modbus-TCP is simply the Modbus RTU protocol with a TCP interface that runs on Ethernet.

TCP/IP that is called as Transmission Control Protocol and Internet Protocol, which provides the transmission medium for Modbus TCP/IP messaging.

TCP/IP facilitates large number of simultaneous connections, so it’s the initiator choice whether to reconnect a connection or to re-use a lived connection.

As we already know that TCP/IP are used to exchange blocks of data between computers and the primary function of TCP is to ensure that all the packets of the data are received which are been send whereas the IP will ensure whether messages are correctly been addressed and routed.

The combination of TCP/IP can simply be called as a transport protocol which does not define what the data means or how the data can be interpreted, but Modbus along with TCP/IP as an application protocol can be used to interpret the data.

Must Read : Modbus ASCII Vs Modbus RTU Vs Modbus TCP/IP

Must Read : OPC-UA vs DA

Modbus TCP/IP vs Ethernet IP


Ethernet/IP uses the Ethernet architecture to establish connection between automation devices like PLCs,DCS, sensors,industrial machines.

Ethernet/IP managed by the Open DeviceNet Vendors Association (ODVA) and is based on the Common Industrial Protocol (CIP). Ethernet/ip is very Powerfull, but it is also complex

Modbus TCP/IP simply combines a physical layer named Ethernet, with a networking standard named TCP/IP, and a standard method of representing data that is Modbus, all of which combines to carry data of the Modbus message structure between compatible devices. So in simple words we can say Modbus TCP/IP message is a Modbus communication encapsulated in an Ethernet TCP/IP wrapper.

Modbus TCP/IP

Modbus TCP/IP works on clients and servers model. Modbus masters referred as clients and Modbus slave as servers.Modbus TCP/IP clients and servers sends and receive Modbus data via port 502.

Now if we talk about the messaging structure of Modbus TCP/IP it has a 7-byte header called as MBAP header (Modbus Application Header) is added to the start of the message with a PDU (Protocol Data Unit).

Must Read : What is Profibus ? How Profibus Work ?

Must Read : Profibus vs Profinet

MBAP header


The MBAP header has following data:

  • Transaction/invocation Identifier (2 Bytes): This identification field is used for pairing the transactions when multiple messages are sent along the same TCP connection by a client without waiting for a prior response.
  • Protocol Identifier (2 bytes): For Modbus services protocol identifier field is always 0 and other values are reserved for future extensions.
  • Length (2 bytes): It includes the unit identifier byte, function code byte, and the data fields and byte counts of the remaining fields.
  • Unit Identifier (1 byte): Unit identifier is used to identify a server located on a non TCP/IP network (for serial bridging) at remote location. The unit ID is set to 00 or FFin most of the typical Modbus TCP/IP server application, ignored by the server, and simply echoed back in the response.

Thus, MBAP and PDU merges to form a Modbus TCP/IP Application Data Unit shown in the figure below.

First 4 is Part of MBAP(Modbus Application Protocol) and Remaining 2 is Part of PDU(Protocol data Unit)

Transaction/invocation Identifier Protocol

Identifier

Length

Field

Unit ID Function Code Data

The PDU includes the function code of 1 byte and the data with no fix size. The function code and their functions are defined below:-

Sr No. Function Code Modbus Function Address
1. 01 Read Coil Status 0xxxx
2. 02 Read Input Status 1xxxx
3. 03 Read Holding Registers 4xxxx
4. 04 Read Input Registers 3xxxx
5. 05 Force Single Coil 0xxxx
6. 06 Preset Single Register 4xxxx
7. 15 Force Multiple Coils 0xxxx
8. 16 Preset Multiple Registers 4xxxx

 

In Modbus TCP/IP error checking field also known as checksum(LRC or CRC) is not considered, as the standard Ethernet TCP/IP link layer checksum methods instead used to guaranty data integrity.

Modbus TCP/IP has a unit identifier instead address field for Modbus devices which means that the original device address is not needed as the Ethernet devices already contains their own unique MAC addresses.

In the case of serial Modbus, client can send one request at a time and has to wait for a reply before sending a second reply whereas Modbus TCP/IP devices can send several requests to the same server without waiting for the reply/response.

The maximum number of client and server transactions varies from device to device, generally the client transaction are from 1 to 16.

Must Read : Devicenet Protocol and Network

Must Read : IEC61850 Protocol and Standard

Best Things about Modbus TCP/IP :


  • Unlike Modbus serial Modbus TCP/IP runs on Ethernet physical layer. It can be said that Modbus TCP/IP is a Modbus RTU with TCP interface that runs on Ethernet.
  • Modbus TCP/IP come up with a good speed compared to serial Modbus devices.
  • In Modbus TCP/IP we need to set only IP address, rather than baud rate, parity, data bits. Modbus TCP/IP uses unit identifier instead of Slave ID which is in the case of Modbus RTU.
  • Modbus TCP/IP communication stack comprises of 5 layers out of 7 layers of the OSI models namely Application, Transport, Network, Data Link, Physical layer.
  • TCP connections can only be established by clients whereas the server can’t initiate the TCP transactions. The server should have open TCP connection and close it with each Modbus message. The client can close a connection when required, and also process a message from server.
  • Some of the Modbus devices can act as both servers and clients, in this case two way communication is possible with separate connections for client and server data flow.
  • Modbus TCP/IP uses 502 port as a local or a remote port to send and receive the messages from client and server. That is port 502 is always reserved as a listening or receiving port.
  • Modbus TCP/IP devices can send several requests to the same server without waiting for the reply/response in this case the transaction identifier can be used to match the requests to corresponding responses.

Must Read : Protocol Overview

Must Read : Communication Overview

Must Read : Protocol in Computer Network

 

 

Leave a Comment