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.
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.
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.

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.
| Parameter | Purpose | What to check |
|---|---|---|
| IP address | Identifies a specific device | No IP address conflict; address entered correctly |
| Subnet mask / gateway | Determines reachability across subnets | Same subnet or properly functioning routing |
| VLAN | Logically separates Ethernet segments | Client and server are allowed to communicate |
| TCP port | Modbus TCP service endpoint | Usually 502; a different port may be configured |
| Firewall / ACL | Restricts network connections | Required path and port are permitted |
| Link LED / cable | Physical Ethernet connection | Link 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.
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.

| Field | Size | Function |
|---|---|---|
| Transaction Identifier | 2 bytes | Request identifier echoed by the server to match transactions |
| Protocol Identifier | 2 bytes | Set to 0 for standard Modbus |
| Length | 2 bytes | Number of following bytes: Unit ID plus PDU |
| Unit Identifier | 1 byte | Target device or remote node behind a gateway |
| Function Code | 1 byte | Data operation: read, write, etc. |
| Data | Depends on the FC | Address, 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 area | Size | Read | Write | Example |
|---|---|---|---|---|
| Coils (0x) | 1 bit | FC01 | FC05, FC15* | Actuator enable |
| Discrete Inputs (1x) | 1 bit | FC02 | No | Sensor status |
| Input Registers (3x) | 16 bits | FC04 | No | Measured temperature |
| Holding Registers (4x) | 16 bits | FC03 | FC06, 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 address | Data area | FC | PDU address for one-based references |
|---|---|---|---|
| 00001 | Coil | 01 | 0 |
| 10001 | Discrete Input | 02 | 0 |
| 30001 | Input Register | 04 | 0 |
| 40001 | Holding Register | 03 | 0 |
| 40010 | Holding Register | 03 | 9 |
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.
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).

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.
| Code | Name | Practical meaning |
|---|---|---|
| 01 | Illegal Function | Function unsupported or prohibited by the server |
| 02 | Illegal Data Address | Address or requested range unavailable |
| 03 | Illegal Data Value | Invalid request field value, such as the quantity |
| 04 | Server Device Failure | Internal 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.
| Representation | Registers | Example | Notes |
|---|---|---|---|
| UINT16 | 1 | 1250 | Range 0–65535 |
| INT16 | 1 | −20752 | The same 16 bits can represent a negative number |
| UINT32 / INT32 | 2 | 100000 / −100000 | Two adjacent registers must be combined |
| FLOAT32 | 2 | 12.5 | IEEE 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.
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
- Verify that a permitted Modbus TCP server is available and obtain its IP address, port and register map.
- Open the connection settings in QModMaster and select Modbus Mode: TCP.
- Enter the server IP address and TCP Port: 502 (unless the documentation specifies otherwise).
- Set the Unit ID according to the device documentation; use 1 for the pyModSlave training example.
- Check Base Addr = 0 if the starting address is to be transmitted as a zero-based offset.
- Select Read Holding Registers (0x03), Start Address = 0, Number of Registers = 10 and Dec display format.
- Click Connect, then perform a single Read/Write operation or enable Scan with a 1000 ms interval.
| QModMaster field | Training example | Purpose |
|---|---|---|
| Modbus Mode | TCP | Communication over TCP/IP |
| IP / Port | 127.0.0.1 / 502 | Local training server |
| Unit ID | 1 | Device identifier in the MBAP header |
| Function Code | 03 | Read Holding Registers |
| Base / Start Address | 0 / 0 | Starting address of register zero |
| Number of Registers | 10 | Read quantity |
| Scan Rate | 1000 ms | Request 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
| Filter | What it shows |
|---|---|
| tcp.port == 502 | TCP packets with port 502 on either side, including connection establishment |
| mbtcp | Recognized Modbus TCP messages |
| modbus.func_code == 3 | FC03 requests and responses |
| mbtcp.trans_id == 97 | Modbus transaction with identifier 97 |
| modbus.exception_code | Packets containing a Modbus exception-code field |
| tcp.analysis.retransmission | Packets classified as TCP retransmissions |
| tcp.flags.reset == 1 | TCP RST — connection reset |
| ip.addr == 192.168.10.21 && tcp.port == 502 | Traffic 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.
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.

| Characteristic | Active QModMaster | Passive Wireshark |
|---|---|---|
| Generates FC03/FC04 requests | Yes | No |
| Can read registers that the PLC does not poll | Yes, if the server permits | No |
| Adds load to the server | Yes | Does not generate Modbus requests |
| Can observe other clients' traffic | Not through its own Bus Monitor | Yes, with a correctly configured capture point |
| Can affect the process through writes | Yes, if write FCs are used | Does 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.

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.

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.
| Symptom | Possible causes | What to investigate |
|---|---|---|
| No Ethernet link | Cable, device power, port or physical fault | LEDs, cable, switch port and power supply |
| No IP connectivity | Network configuration, VLAN, subnet mask, route or access rules | IP configuration, routes, ARP and ICMP with appropriate caveats |
| TCP/502 cannot be opened | Service disabled, wrong port, ACL/firewall or session limit | TCP SYN/SYN-ACK/RST and device logs |
| TCP open but no Modbus response | Invalid Unit ID, unresponsive application, gateway or delays | MBAP, actual FC, timeout and server logs |
| Exception 01 | Unsupported Function Code | Function map |
| Exception 02 | Address, read quantity or Base Address mismatch | Register map and requested range |
| Incorrect values without errors | Wrong units, sign, scaling or word/byte order | Manufacturer's data type and representation |
| Intermittent timeouts | Packet loss, overload, reconnects or gateway delays | Wireshark 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
| Tool | Role | Main use |
|---|---|---|
| QModMaster | Modbus TCP/RTU client | Reading registers and viewing its own requests and responses |
| pyModSlave | Training Modbus TCP/RTU server | Simulating registers and states without a real CNC machine |
| Wireshark | Passive network packet analyzer | TCP connections, Modbus MBAP, FC, exceptions and delays |
| Modbus Poll | Commercial Modbus client | Register polling, testing and logging |
| mbpoll | Command-line client | Scriptable reads when configured with least privilege |
| PowerShell | Windows network diagnostics | IP 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.
| Device | Example data | Typical diagnostic use |
|---|---|---|
| Variable-frequency drive | Setpoint/output frequency, current, status and fault code | Compare commands, actual operation and alarms |
| Remote I/O | Input and output states | Trace sensor → module → PLC |
| Energy meter | Voltage, current and power | Assess load and measurement discrepancies |
| Temperature controller | Temperature, setpoint and alarm | Distinguish sensor faults from communication faults |
| TCP↔RTU gateway | Data from several slaves | Separate 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.
18. Practical Workflow
- Identify the device model and confirm Modbus TCP support in its documentation.
- Obtain the network diagram, IP address/subnet mask, TCP port and permitted connection parameters.
- Check the Ethernet link, IP route and TCP service reachability.
- Consult the register map to determine the data area, Function Code, address and quantity.
- Determine the correct Unit ID, especially if a gateway sits between client and device.
- Test reads in QModMaster on a prepared training bench; coordinate active connections before testing an operational network.
- If an error occurs, save the client's status and a timestamped Wireshark capture.
- Distinguish network failure, TCP problems, Modbus exceptions and incorrect value interpretation.
- Confirm scaling, signedness and word order against the manufacturer's documentation.
- 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
- Modbus Organization — Modbus Messaging on TCP/IP Implementation Guide V1.0b (PDF) — MBAP, Client/Server, Unit ID, connections and message exchange.
- Modbus Organization — Modbus Application Protocol Specification V1.1b3 (PDF) — functions, addressing, registers and exceptions.
- Modbus Organization — official specifications — Modbus protocols and Modbus Security.
- Wireshark — Modbus/TCP display filter reference — MBAP and display fields.
- Wireshark — Modbus display filter reference — Function Codes, exceptions and other fields.
- QModMaster — source code and documentation — Modbus TCP/RTU client.
- QModMaster — download.
- pyModSlave — training Modbus TCP/RTU server.
- 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.