This page is also available in RU and PL.

Industrial Networks · Ethernet · CNC and PLC Troubleshooting

Modbus TCP: Protocol Fundamentals, Ethernet Connections and Industrial Equipment Diagnostics

A technical guide to Modbus TCP: network architecture, the Client/Server model, register addressing, MBAP message structure, configuring QModMaster, inspecting traffic with Wireshark, integrating TCP↔RTU gateways, and troubleshooting CNC, PLC and industrial automation systems.

Technical Reference · Edition 1.0 · 31 October 2026

1. Purpose and Applications

Modbus TCP is a data exchange protocol for industrial devices that uses the TCP/IP protocol stack. It allows a controller, computer or supervisory system to read measurements, status information and equipment faults and, where supported by the device and permitted by the process, to write commands and setpoints.

Typical devices include PLCs and CNC controllers, variable-frequency drives (VFDs), remote input/output modules, energy meters, network-connected sensors, communication gateways and SCADA systems. The standard TCP port is commonly 502.

Modbus TCP is not a deterministic motion-control network with a guaranteed cycle time. Reading temperatures, VFD diagnostic data and slow-changing process parameters are typical applications; CNC servo-drive synchronization normally relies on other mechanisms, such as EtherCAT or a manufacturer-specific motion bus.

Technology layers. Ethernet handles frame transfer on a local network; IP provides addressing and routing; TCP provides the transport connection; Modbus defines commands and data. An Ethernet connector on a machine does not, by itself, imply support for Modbus TCP.

2. Network Architecture: Client and Server

Modbus TCP documentation uses the Client/Server model. A client initiates a request; a server processes it and returns a response. Older software sometimes retains the terms Master and Slave, which roughly correspond to client and server in this TCP context.

Modbus TCP topology: CNC/PLC client, Ethernet switch, VFD, I/O and TCP–RTU gateway
Fig. 1. Ethernet network with native Modbus TCP servers and a separate RS-485 gateway.

Each network device normally has its own IP address. For example, a PLC at 192.168.10.5 may read a VFD at 192.168.10.21 and an I/O module at 192.168.10.22 in succession. Sharing an Ethernet switch does not turn those devices into a single Modbus server: the client establishes a connection to each specific IP address.

Unlike a conventional single-master Modbus RTU bus, a Modbus TCP server may be accessed by several clients if the server supports this. Connection limits, request queues, processing speed and access permissions are determined by the device. A second client can affect the first even without writing registers.

3. Ethernet Connection: Physical Network, IP and Port

Modbus TCP normally uses standard Ethernet infrastructure: the equipment's network port, a suitable cable, an industrial Ethernet switch or a direct connection, an IP address and a TCP port. Baud rate, parity and stop-bit settings are not needed for Modbus TCP itself; these belong to serial interfaces.

ParameterPurposeWhat to check
IP addressIdentifies a specific deviceNo IP address conflict; address entered correctly
Subnet mask / gatewayDetermines reachability across subnetsSame subnet or properly functioning routing
VLANLogically separates Ethernet segmentsClient and server are allowed to communicate
TCP portModbus TCP service endpointUsually 502; a different port may be configured
Firewall / ACLRestricts network connectionsRequired path and port are permitted
Link LED / cablePhysical Ethernet connectionLink present and port operational

Example: a laptop at 192.168.10.100/24 and a VFD at 192.168.10.21/24 can communicate through one switch without a router. If the computer is on another subnet, suitable routing and access rules are needed. An illuminated LINK LED does not prove that the Modbus service is working.

Network reachability does not guarantee a successful read. A device may respond to ping while not listening on TCP/502; conversely, ping may be blocked even when TCP/502 works. Both layers must be checked, not just ICMP.

4. Message Format: MBAP and PDU

Modbus TCP carries an Application Data Unit (ADU) consisting of a seven-byte MBAP header and a PDU (function code and associated data). Unlike Modbus RTU, Modbus TCP does not append an additional CRC16 field: integrity checking relies on lower-layer network mechanisms, while the Length field defines the boundaries of the Modbus message.

Modbus TCP MBAP header and PDU fields: Transaction ID, Protocol ID, Length, Unit ID and FC03
Fig. 2. Modbus TCP message format for reading two Holding Registers with FC03.
FieldSizeFunction
Transaction Identifier2 bytesRequest identifier echoed by the server to match transactions
Protocol Identifier2 bytesSet to 0 for standard Modbus
Length2 bytesNumber of following bytes: Unit ID plus PDU
Unit Identifier1 byteTarget device or remote node behind a gateway
Function Code1 byteData operation: read, write, etc.
DataDepends on the FCAddress, quantity, register values or server response

The Transaction ID is needed to match requests with responses because TCP is a byte stream rather than a sequence of separate Modbus messages. One Modbus message may be split across multiple TCP segments, or several messages may travel in one network stream. Therefore, Modbus message boundaries are determined from MBAP/Length, not from a single Wireshark packet.

5. Four Data Areas and Function Codes

Modbus TCP uses the same logical data model as Modbus RTU: Coils, Discrete Inputs, Input Registers and Holding Registers. These are protocol data areas and do not necessarily map directly to the equipment's physical terminals.

Data areaSizeReadWriteExample
Coils (0x)1 bitFC01FC05, FC15*Actuator enable
Discrete Inputs (1x)1 bitFC02NoSensor status
Input Registers (3x)16 bitsFC04NoMeasured temperature
Holding Registers (4x)16 bitsFC03FC06, FC16*Setpoint or diagnostic parameter

* Write availability depends on device implementation, access permissions and the purpose of the particular address. A Holding Register is not necessarily writable even when FC06/FC16 are supported.

Codes 01, 02, 03 and 04 are read functions; 05, 06, 15 and 16 are write functions. Supported functions are listed in the manufacturer's register map. For example, a server may support FC03 but return an exception for FC04.

The Modbus specification limits one FC03 operation to a maximum of 125 consecutive Holding Registers. This is the protocol upper limit; an individual device may impose a smaller limit.

6. Register Addressing, Base Address and Unit ID

Within a Modbus request, the register address is transmitted as a zero-based offset. Equipment documentation often uses human-readable references such as 40001, 40002 and so on. The leading 4 denotes the Holding Register area but is not transmitted in the address field.

Documented addressData areaFCPDU address for one-based references
00001Coil010
10001Discrete Input020
30001Input Register040
40001Holding Register030
40010Holding Register039

Some register maps already use zero-based addresses or a six-digit form such as 400001. Before calculating the offset, establish the numbering convention used by the specific manual. In QModMaster, check the Base Addr setting: it affects how the starting address is entered in the interface.

IP Address and Unit ID Are Different Things

The IP address determines which Modbus TCP server the client connects to. The Unit ID is carried inside the MBAP header. A native TCP device may ignore the Unit ID or validate it according to the manufacturer's rules; through a TCP↔RTU gateway it often selects the RTU slave address behind that gateway.

Do not assume that Unit ID = 1 is mandatory for every Modbus TCP server, or that Unit ID = 0 has a universal broadcast meaning in TCP. Accepted values depend on the device and the gateway.

7. Byte-by-Byte Analysis of an FC03 Request

The client reads two Holding Registers at addresses 0 and 1; Unit ID = 1 and Transaction ID = 1. The hexadecimal request is:

00 01 | 00 00 | 00 06 | 01 | 03 00 00 00 02
 TxID   ProtID   Length   Unit  FC  Addr  Qty

Here, 00 01 is the Transaction ID, 00 06 is the length of the following content (one Unit ID byte plus five PDU bytes), 03 is Read Holding Registers, 00 00 is the starting address, and 00 02 is the number of registers.

If the server stores the values 1250 and 0, its normal response is:

00 01 00 00 00 07 01 03 04 04 E2 00 00
|  MBAP (7 B)    | FC  N  | Reg0 | Reg1 |

Reg0 = 0x04E2 = 1250
Reg1 = 0x0000 = 0

The byte 04 following FC03 specifies the data byte count: two registers × two bytes = four bytes. The response retains Transaction ID 0001. The Length field equals 7 (Unit ID 1 + FC 1 + Byte Count 1 + Data 4).

TCP handshake and two Modbus FC03 transactions with transaction IDs 97 and 98
Fig. 3. TCP connection setup followed by successive FC03 requests. The diagram is illustrative; no specific timing intervals are implied.

Exception Response and Timeout

If the server receives a valid request but cannot perform it, it may return a Modbus Exception. For FC03, the exception response contains function code 0x83 (high bit set) and a reason code.

CodeNamePractical meaning
01Illegal FunctionFunction unsupported or prohibited by the server
02Illegal Data AddressAddress or requested range unavailable
03Illegal Data ValueInvalid request field value, such as the quantity
04Server Device FailureInternal device failure while handling the operation

A timeout is not the same as an exception: the client did not receive the expected response within the allotted time. Possible reasons include packet loss, a blocked TCP connection, unavailable server, delays behind a gateway or an unresponsive application.

8. Interpreting Values: Data Types, Scaling and Word Order

A Modbus register contains 16 bits. The protocol itself does not indicate whether a value represents temperature, current, a signed integer or part of a floating-point number. Its meaning is defined by the manufacturer's documentation.

RepresentationRegistersExampleNotes
UINT1611250Range 0–65535
INT161−20752The same 16 bits can represent a negative number
UINT32 / INT322100000 / −100000Two adjacent registers must be combined
FLOAT32212.5IEEE 754 and word order

For example, a raw value of 1250 may represent 12.50 bar if the register map specifies a scaling factor of 0.01 bar per register unit. Without the register map, a numeric value cannot be reliably converted into physical units.

Within a 16-bit Modbus register, the most significant byte is transmitted first. However, 32-bit values may use different word orders, such as ABCD or CDAB. Some devices also swap the bytes within words. Troubleshooting incorrect readings requires separate checks of data type, scaling and word order.

9. Cyclic Polling, Delays and Multiple Clients

Most Modbus TCP clients read parameters periodically (polling). For example, a QModMaster scan interval of 1000 ms sends another request approximately once per second. Actual response time depends on server-side processing, network load, gateways and configured timeouts.

The polling interval is not a guaranteed data transfer period and is not the same as server response time. Polling many addresses too frequently can overload a low-performance device, clog a request queue or increase delays for the PLC's normal process communication.

Modbus TCP uses Transaction IDs to correlate requests with responses. However, parallel processing capabilities and the number of permitted TCP connections depend on the individual server implementation. When diagnosing operating machinery, monitor the connection count and request rate.

Practical setup. On a separate training server, reading 10 registers once every 1000 ms is a useful starting point. On an industrial network, the polling rate must be chosen according to equipment documentation and process constraints; there is no universally safe value.

10. QModMaster: Configuring Modbus TCP and Reading Registers

QModMaster is a free graphical Modbus RTU/TCP client for Windows and Linux. It can establish a connection, select the function code, address and number of registers, perform periodic reads and show the traffic generated by the program itself.

Connection Setup

  1. Verify that a permitted Modbus TCP server is available and obtain its IP address, port and register map.
  2. Open the connection settings in QModMaster and select Modbus Mode: TCP.
  3. Enter the server IP address and TCP Port: 502 (unless the documentation specifies otherwise).
  4. Set the Unit ID according to the device documentation; use 1 for the pyModSlave training example.
  5. Check Base Addr = 0 if the starting address is to be transmitted as a zero-based offset.
  6. Select Read Holding Registers (0x03), Start Address = 0, Number of Registers = 10 and Dec display format.
  7. Click Connect, then perform a single Read/Write operation or enable Scan with a 1000 ms interval.
QModMaster fieldTraining examplePurpose
Modbus ModeTCPCommunication over TCP/IP
IP / Port127.0.0.1 / 502Local training server
Unit ID1Device identifier in the MBAP header
Function Code03Read Holding Registers
Base / Start Address0 / 0Starting address of register zero
Number of Registers10Read quantity
Scan Rate1000 msRequest interval

Training Setup: QModMaster + pyModSlave

In pyModSlave, select TCP, Unit ID = 1, the Holding Registers area and addresses 0–9 (10 registers), then set the first register to a value such as 1250. When connected to 127.0.0.1:502, QModMaster should read 1250 in the first element and the remaining values as configured in the simulator.

Changing a value in pyModSlave demonstrates that the client receives updates. To compare FC02/FC04, select the appropriate data areas and function codes. If the client requests 10 registers starting at address 1 while the server exposes only addresses 0–9, Exception 02 — Illegal Data Address may occur.

QModMaster write controls and functions must only be used on a training setup or where specifically authorized. On industrial equipment, changing parameters, setpoints or control bits can affect motors, contactors, valves and the CNC machine.

11. Wireshark: Packet-Level Modbus TCP Analysis

Unlike QModMaster, which displays its own operations, Wireshark analyzes packets captured on a selected network interface. It is useful for checking the TCP handshake, retransmissions, response time and the content of Modbus requests.

Selecting the Capture Interface

  • For two applications communicating on one Windows computer over 127.0.0.1, use the Npcap Loopback capture interface.
  • For communication with an external VFD or PLC, select the Ethernet/Wi-Fi interface that actually carries the connection.
  • To observe traffic between two other devices connected through a switch, you normally need SPAN/Mirror port monitoring or a network TAP. An ordinary port on a modern Ethernet switch does not show all other devices' unicast traffic.

Useful Wireshark Filters

FilterWhat it shows
tcp.port == 502TCP packets with port 502 on either side, including connection establishment
mbtcpRecognized Modbus TCP messages
modbus.func_code == 3FC03 requests and responses
mbtcp.trans_id == 97Modbus transaction with identifier 97
modbus.exception_codePackets containing a Modbus exception-code field
tcp.analysis.retransmissionPackets classified as TCP retransmissions
tcp.flags.reset == 1TCP RST — connection reset
ip.addr == 192.168.10.21 && tcp.port == 502Traffic involving the specified server on port 502

In Wireshark's packet tree, expand Modbus/TCP and Modbus to inspect Transaction ID, Protocol ID, Length, Unit ID, Function Code, register address and quantity, returned values and exception code. Follow → TCP Stream is useful for analyzing one TCP connection.

Matching Transaction IDs in a request and response confirm their correlation at the Modbus layer. TCP Seq and Ack fields, by contrast, track byte delivery at the transport layer and are not Modbus register numbers or transaction identifiers.

Limits of passive analysis. Wireshark cannot independently read a register that nobody is requesting. It can only display traffic actually passing through the capture point. Proprietary protocols may also use TCP ports and must not be incorrectly interpreted as Modbus.

12. Active and Passive Diagnostics

In active mode, the diagnostic computer establishes its own TCP connection to the server and sends Modbus requests (for example, FC03). In passive mode, the analyzer receives copies of existing network traffic without initiating its own Modbus operations.

Active QModMaster polling compared with passive Wireshark monitoring via SPAN/TAP
Fig. 4. The fundamental difference between active reads and passive packet capture.
CharacteristicActive QModMasterPassive Wireshark
Generates FC03/FC04 requestsYesNo
Can read registers that the PLC does not pollYes, if the server permitsNo
Adds load to the serverYesDoes not generate Modbus requests
Can observe other clients' trafficNot through its own Bus MonitorYes, with a correctly configured capture point
Can affect the process through writesYes, if write FCs are usedDoes not transmit Modbus commands

On a running CNC machine, connecting a second TCP client may exceed the server's connection limit or increase delays for its regular PLC. Even read-only active monitoring should therefore be coordinated. Passive capture through SPAN/TAP is preferable for initial inspection; the suitability of the capture point and the impact of network changes must also be assessed.

13. Modbus TCP ↔ Modbus RTU Gateway

Some devices support only Modbus RTU over RS-485. A dedicated Modbus TCP ↔ RTU gateway is used to integrate them into an Ethernet system by converting protocol messages and controlling serial polling. An ordinary USB-to-RS-485 adapter (such as the Moxa UPort 1150I) is not, by itself, such a network gateway.

Modbus TCP gateway IP address and Unit IDs for multiple RTU slave devices
Fig. 5. One gateway IP address can provide access to several Modbus RTU devices.

For example, to reach a sensor with RTU Slave ID 2, the client connects to 192.168.10.30:502 and sets Unit ID = 2. The gateway generates a serial RTU request addressed to slave 2, adds the RTU CRC and waits for the RS-485 response. It then returns the result through Modbus TCP with the corresponding Transaction ID.

RTU line speed, the number of slaves and queued requests affect latency: fast Ethernet does not accelerate the underlying serial RS-485 bus. A longer timeout may be necessary through a gateway to account for serial communication. Also, not every interface converter is automatically a Modbus gateway: some devices merely tunnel raw serial data over TCP (Serial-over-TCP).

14. Troubleshooting: A Step-by-Step Check

Effective troubleshooting starts by identifying the layer at which communication fails rather than repeatedly changing equipment addresses and settings by trial and error.

Layered Ethernet, IP, TCP, Modbus and data-interpretation troubleshooting workflow
Fig. 6. Modbus TCP troubleshooting layers — from physical connectivity to register meaning.

Basic Windows Commands

ipconfig /all
ping 192.168.10.21
arp -a
Test-NetConnection 192.168.10.21 -Port 502

The Test-NetConnection command is run in PowerShell. A result of TcpTestSucceeded : True confirms that a TCP connection to the port was possible when tested; it does not establish that Modbus functions or register addressing are correct.

SymptomPossible causesWhat to investigate
No Ethernet linkCable, device power, port or physical faultLEDs, cable, switch port and power supply
No IP connectivityNetwork configuration, VLAN, subnet mask, route or access rulesIP configuration, routes, ARP and ICMP with appropriate caveats
TCP/502 cannot be openedService disabled, wrong port, ACL/firewall or session limitTCP SYN/SYN-ACK/RST and device logs
TCP open but no Modbus responseInvalid Unit ID, unresponsive application, gateway or delaysMBAP, actual FC, timeout and server logs
Exception 01Unsupported Function CodeFunction map
Exception 02Address, read quantity or Base Address mismatchRegister map and requested range
Incorrect values without errorsWrong units, sign, scaling or word/byte orderManufacturer's data type and representation
Intermittent timeoutsPacket loss, overload, reconnects or gateway delaysWireshark TCP Analysis, load and client count

A TCP Retransmission does not automatically indicate a defective Ethernet cable. Retransmissions may result from device overload, routing, Wi-Fi or transient packet loss; the cause must be established from the combined evidence.

15. Software and Tools

ToolRoleMain use
QModMasterModbus TCP/RTU clientReading registers and viewing its own requests and responses
pyModSlaveTraining Modbus TCP/RTU serverSimulating registers and states without a real CNC machine
WiresharkPassive network packet analyzerTCP connections, Modbus MBAP, FC, exceptions and delays
Modbus PollCommercial Modbus clientRegister polling, testing and logging
mbpollCommand-line clientScriptable reads when configured with least privilege
PowerShellWindows network diagnosticsIP configuration, ping and TCP port reachability

QModMaster is convenient for manual diagnostics, while Wireshark verifies what actually traverses the network. The Bus Monitor display in QModMaster shows only that application's own communication and does not replace mirroring traffic between the PLC and VFD.

16. Applications in CNC and Industrial Automation

In CNC machines, Modbus TCP may connect the controller or external diagnostic software to auxiliary devices. Typical parameters include VFD output frequency and current, lubrication and vacuum status, temperature, pressure, remote I/O states, energy counters and fault codes.

DeviceExample dataTypical diagnostic use
Variable-frequency driveSetpoint/output frequency, current, status and fault codeCompare commands, actual operation and alarms
Remote I/OInput and output statesTrace sensor → module → PLC
Energy meterVoltage, current and powerAssess load and measurement discrepancies
Temperature controllerTemperature, setpoint and alarmDistinguish sensor faults from communication faults
TCP↔RTU gatewayData from several slavesSeparate Ethernet problems from RS-485 problems

The interfaces supported by SYNTEC equipment depend on controller model, expansion modules and machine configuration. Do not assume that every SYNTEC Ethernet port or servo-drive EtherCAT port supports Modbus TCP. Likewise, Modbus TCP support in a VFD does not mean the CNC uses it for spindle control: commands may travel through separate digital and analog circuits.

17. Cybersecurity and Industrial Network Restrictions

Classic Modbus TCP on port 502 does not provide mandatory client authentication or encryption. Depending on server capabilities, access to the port can allow not only data reads but also write commands.

Industrial networks should use separate process VLANs, restrictions on permitted IP addresses and ports, connection monitoring, configuration backups, controlled remote access through secure mechanisms and no direct exposure of TCP/502 to the public Internet.

There is also a separate Modbus Security profile that uses TLS and port 802. Both endpoints must support it; selecting ordinary TCP/502 does not automatically enable this security profile.

Safety when working on an operating CNC machine. Before connecting diagnostic equipment, verify the port function, whether an additional connection is permitted and the allowable communication load. Initially, prefer the controller’s built-in diagnostics and passive packet capture. Write commands, stop tests and fault resets must follow an approved procedure that accounts for axis and spindle motion.

18. Practical Workflow

  1. Identify the device model and confirm Modbus TCP support in its documentation.
  2. Obtain the network diagram, IP address/subnet mask, TCP port and permitted connection parameters.
  3. Check the Ethernet link, IP route and TCP service reachability.
  4. Consult the register map to determine the data area, Function Code, address and quantity.
  5. Determine the correct Unit ID, especially if a gateway sits between client and device.
  6. Test reads in QModMaster on a prepared training bench; coordinate active connections before testing an operational network.
  7. If an error occurs, save the client's status and a timestamped Wireshark capture.
  8. Distinguish network failure, TCP problems, Modbus exceptions and incorrect value interpretation.
  9. Confirm scaling, signedness and word order against the manufacturer's documentation.
  10. Record settings, addresses, transaction identifiers, returned values and conclusions in the service report.

Modbus TCP enables standardized diagnostics of industrial equipment over Ethernet. Reliable results require more than a successful register read: they depend on correct device identification, network checks, correlating requests and responses, understanding the register map and respecting the limitations of the operating control system.

Technical Documentation and References

  1. Modbus Organization — Modbus Messaging on TCP/IP Implementation Guide V1.0b (PDF) — MBAP, Client/Server, Unit ID, connections and message exchange.
  2. Modbus Organization — Modbus Application Protocol Specification V1.1b3 (PDF) — functions, addressing, registers and exceptions.
  3. Modbus Organization — official specifications — Modbus protocols and Modbus Security.
  4. Wireshark — Modbus/TCP display filter reference — MBAP and display fields.
  5. Wireshark — Modbus display filter reference — Function Codes, exceptions and other fields.
  6. QModMaster — source code and documentation — Modbus TCP/RTU client.
  7. QModMaster — download.
  8. pyModSlave — training Modbus TCP/RTU server.
  9. Modbus Organization — Modbus/TCP Security (PDF) — TLS and port 802.

The example IP addresses, register values, network topologies and timing diagrams are intended for training. On actual equipment, the machine wiring diagram and manufacturer's documentation take precedence.