In this scenario, let's imagine that the client produced (N-1)th and Nth request packets one
after another and sent those to the gateway over the internet. Although the destination IP
address of both packets is the same, these packets may follow different paths to their
destinations(For example, (N-1)th packet may follow the A-B-C-D path and Nth packet may
follow the A-E-D path). As a result, Nth packet may arrive the destination before (N-1)th
packet arrives. If there aren't any numbers which indicate the query order, the gateway will
relay the requests to the serial channel and relay back the responses back to the client in the
order that they arrived in. But the (N-1)th response sent to the client by the gateway is actually
the response for the Nth request.
To prevent this kind of confusion while communicating over the internet, a number to define
the order of the requests is added into the MODBUS/TCP packet. This number is created by
the client and increased for every new request. After the gateway receives and processes the
requests in the order that they arrive in, it sends them back in the same order. This way, the
client detects which response belongs to which request.
Protocol Identifier
It is the 16 bit long number that defines to which protocol the packet belongs. For
MODBUS/TCP, this number is set as “0”.
Packet Length
It is the length of the following data.
Data Address
It is the MODBUS address of the serial connected device to which the request will be sent.
As seen from the packet structures above, MODBUS/TCP packet doesn't have CRC
information. The error control occurs within the TCP protocol itself.
2.1.3.2 Tunnel Mode Packet Structure
In Tunnel Mode Operation mode, the MBAP header isn't added to the packet. The
request/response packets are transmitted embedded in the TCP packet and the CRC
information is transmitted along the data block embedded in the TCP packet.