Developing automation systems, SCADA supervisory dashboards, and industrial IoT data pipelines requires rigorous end-to-end communication testing long before plant hardware arrives on-site. When physical PLCs, RTUs, power meters, and variable frequency drives (VFDs) are unavailable, a reliable Modbus Server Simulator bridges the gap. By standing up virtual Modbus TCP servers on port 502 and emulating serial RTU slaves across virtual COM ports, control engineers can validate register maps, test multi-client connection scaling, and simulate dynamic process variables from their workstation.
1. Modbus Terminology: Server vs. Client, Slave vs. Master
In modern industrial Ethernet protocols, standard terminology can occasionally cause confusion for engineers transitioning from serial communication to TCP/IP. The official Modbus Application Protocol Specification explicitly correlates the terminology:
- Modbus Server (= Modbus Slave): The passive device that maintains the data tables (registers, coils) and listens for incoming requests. In Modbus TCP, the server binds to TCP port 502 and accepts socket connections from one or more clients. Examples include smart energy meters, PLC server ports, and temperature controllers.
- Modbus Client (= Modbus Master): The active device that initiates TCP socket handshakes, generates poll queries, and issues command writes. Examples include SCADA supervisory software (such as Ignition, WinCC, or SCADA Platform), DCS controllers, and edge IIoT gateways.
| Architecture Aspect | Modbus Server (Slave) | Modbus Client (Master) |
|---|---|---|
| Network Role | Listens passively (TCP Port 502 or Serial COM RX) | Initiates connections and polls cyclically |
| Data Ownership | Stores Coils (0x), Discrete Inputs (1x), Input Regs (3x), Holding Regs (4x) | Reads from or writes to server memory tables |
| Connection Handling | Multi-socket server daemon; serves multiple simultaneous clients | Maintains socket connection pools to target servers |
| Message Framing | Receives request frame, validates CRC/MBAP, returns response frame | Constructs request frame, tracks transaction IDs, handles timeouts |
2. Modbus TCP Protocol Architecture & MBAP Header
Unlike Modbus RTU which appends a 2-byte Cyclic Redundancy Check (CRC-16) at the end of the frame, Modbus TCP encapsulates the standard Modbus PDU (Protocol Data Unit) inside a 7-byte MBAP Header (Modbus Application Protocol Header). The underlying Ethernet/IP and TCP layers ensure transmission integrity, eliminating the need for application-layer CRC checksums.
+---------------------------------------------------------------------------------+
| Modbus TCP ADU |
+----------------------------------------------------------------+----------------+
| MBAP Header (7 Bytes) | Modbus PDU |
| Transaction ID (2B) | Protocol ID (2B) | Length (2B) | Unit ID | FC (1B) | Data |
+----------------------------------------------------------------+----------------+
A compliant Modbus TCP server simulator must correctly parse and validate every field in the MBAP header:
- Transaction Identifier (2 Bytes): Used by the client to pair asynchronous request and response frames. The server simulator must echo the exact Transaction ID back to the client.
- Protocol Identifier (2 Bytes): Always
0x0000for standard Modbus protocol communications. - Length Field (2 Bytes): Specifies the number of following bytes in the message, including the Unit Identifier and PDU payload.
- Unit Identifier (1 Byte): Represents the Slave ID (1–247). In routed architectures with serial gateways, the simulator uses this byte to direct requests to the appropriate virtual slave instance.
3. Core Memory Tables in Modbus Server Simulation
A Modbus server maintains four distinct memory tables. Each table addresses specific types of industrial I/O signals:
- Discrete Outputs (Coils — 00001 to 09999): 1-bit read/write flags representing relay states, motor contactor triggers, valve solenoids, or digital alarms. Function codes: FC 01 (Read), FC 05 (Write Single), FC 15 (Write Multiple).
- Discrete Inputs (Contacts — 10001 to 19999): 1-bit read-only flags representing limit switches, proximity sensors, pushbuttons, or digital circuit breaker trip statuses. Function code: FC 02 (Read).
- Input Registers (30001 to 39999): 16-bit read-only words representing analog sensor inputs, such as 4-20mA current loop readings, thermocouples, or raw ADC counts. Function code: FC 04 (Read).
- Holding Registers (40001 to 49999): 16-bit read/write registers used for PID setpoints, configuration parameters, recipe values, and multi-word IEEE 754 floating-point process variables (temperatures, flow rates, pressure). Function codes: FC 03 (Read), FC 06 (Write Single), FC 16 (Write Multiple).
4. Setting Up a Virtual Modbus Server in Modbus Simulator Desktop
Modbus Simulator Desktop provides a modern 64-bit simulation environment that replaces dated 32-bit legacy tools like ModSim32. Follow these steps to configure a virtual server on your PC:
- Launch Modbus Simulator: Select New Server Configuration from the main toolbar.
- Select Protocol Mode: Choose Modbus TCP Server to listen on Ethernet, or Modbus RTU Server to bind to a virtual serial COM port (using tools like com0com or Virtual Serial Port Driver).
- Bind Network Interface & Port: By default, the TCP server binds to
0.0.0.0:502(listening across all network adapters). For local-only loopback testing, bind to127.0.0.1:502. If port 502 requires administrative rights or conflicts with existing services, you can designate an alternate port (such as5020). - Define Slave ID & Memory Allocation: Configure the active Unit ID (e.g., Slave ID 1) and allocate register blocks (e.g., Holding Registers 40001 to 40100).
- Configure Data Simulation Profiles: Rather than serving static numbers, enable dynamic automation profiles:
- Sine Wave Generator: Simulates fluctuating analog temperature or vibration values.
- Incremental Ramp / Counter: Generates automated heartbeat watchdog signals or production part counters.
- Random Noise Generator: Injects realistic sensor jitter to verify filter algorithms in your SCADA platform.
- Start Listening: Click Start Server. The status bar immediately confirms active socket listening and ready state.
Download Native 64-Bit Modbus Simulator Desktop
Run multiple virtual Modbus TCP and RTU servers on Windows 10 & 11. Built-in script engine, floating point registers, traffic logger, and zero lag.
Download Free Trial →5. Testing Modbus Server Simulator with Python (PyModbus)
You can verify your virtual Modbus TCP server simulator using a lightweight Python script with pymodbus. The following script connects as a Modbus client, writes setpoints to holding registers, and reads back simulated sensor variables:
from pymodbus.client import ModbusTcpClient
import struct
import time
def test_modbus_server():
# Connect to local Modbus TCP Server Simulator
SERVER_IP = "127.0.0.1"
SERVER_PORT = 502
UNIT_ID = 1
client = ModbusTcpClient(SERVER_IP, port=SERVER_PORT)
if not client.connect():
print(f"[-] Connection to Modbus server at {SERVER_IP}:{SERVER_PORT} failed.")
return
print(f"[+] Successfully connected to Modbus Server Simulator ({SERVER_IP}:{SERVER_PORT})")
try:
# 1. Write single holding register (FC 06)
# Register 40001 (Address 0) = Setpoint 1500
client.write_register(0, 1500, slave=UNIT_ID)
print("[+] Written Setpoint: 1500 to Register 40001")
# 2. Write 32-bit Float to Registers 40002-40003 (FC 16)
# Temperature = 78.45 °C (IEEE 754 Big-Endian)
temp_val = 78.45
float_bytes = struct.pack(">f", temp_val)
reg_high, reg_low = struct.unpack(">HH", float_bytes)
client.write_registers(1, [reg_high, reg_low], slave=UNIT_ID)
print(f"[+] Written Float: {temp_val} to Registers 40002-40003")
# 3. Read back holding registers (FC 03)
rr = client.read_holding_registers(0, 4, slave=UNIT_ID)
if not rr.isError():
print(f"[+] Raw Read Registers: {rr.registers}")
# Unpack float
read_bytes = struct.pack(">HH", rr.registers[1], rr.registers[2])
read_float = struct.unpack(">f", read_bytes)[0]
print(f"[+] Decoded Temperature Float: {read_float:.2f} °C")
else:
print(f"[-] Read error: {rr}")
finally:
client.close()
print("[+] Connection closed.")
if __name__ == "__main__":
test_modbus_server()
6. Advanced Simulation: Multi-Slave Routing & Floating Point Endianness
In production plant environments, complex architectures present subtle edge cases that a robust server simulator must replicate:
Multi-Slave Emulation on a Single Port
When testing supervisory SCADA drivers designed to poll solar farms or submetering panels behind an Ethernet gateway, you may need a single server to respond to 32 different Unit IDs. Modbus Simulator Desktop allows you to assign unique register tables to each Unit ID, enabling realistic gateway simulation without creating multiple TCP sockets.
32-Bit and 64-Bit Word Byte Order (Endianness)
Because the standard Modbus specification only defines 16-bit register registers, storing 32-bit integers or IEEE 754 floating-point values requires spanning two consecutive registers. Manufacturers handle word and byte ordering differently:
- Big-Endian (ABCD): Most significant word first, most significant byte first (standard Schneider Electric, Siemens).
- Little-Endian (DCBA): Least significant word first, least significant byte first.
- Word Swap / Mid-Little (CDAB): Most significant word swapped with least significant word (common in ABB, Honeywell, and Advantech devices).
Modbus Simulator Desktop provides real-time byte ordering toggles, ensuring your SCADA driver displays accurate process engineering values rather than garbage numeric overflow errors.
7. Troubleshooting Modbus Server Connections
When testing communication between a client and a virtual Modbus server, control engineers frequently encounter standard network hurdles:
- Socket Connection Refused (TCP Port 502): On Windows workstations, port 502 is within the privileged port range. Ensure Modbus Simulator has administrative privileges, or verify whether Windows Defender Firewall is blocking inbound connections on TCP 502.
- Modbus Poll Timeout Error: If the client reports a timeout error, verify that the configured Unit Identifier (Slave ID) in the client request matches an enabled virtual slave in the server simulator.
- Illegal Data Address Exception (0x02): The client requested register addresses outside the configured memory range. Verify whether the client uses 0-based addressing (PLC address 40001 = protocol address 0) or 1-based offset addressing.
8. Frequently Asked Questions (FAQs)
What is the difference between a Modbus Server and a Modbus Client?
In Modbus TCP terminology, a Modbus Server is equivalent to a traditional Modbus Slave: it listens on TCP port 502, holds data tables, and responds to queries. A Modbus Client is equivalent to a Modbus Master: it initiates TCP connections and queries data.
Why use a Modbus server simulator instead of physical hardware?
A server simulator allows developers and engineers to test SCADA screens, PLC drivers, and IoT pipelines without buying physical hardware, enabling stress testing, error injection, and edge-case validation.
Can a Modbus server simulator simulate multiple slave IDs simultaneously?
Yes. Modbus Simulator Desktop can run multi-slave simulations where a single Modbus TCP server responds to multiple Unit IDs (Slave IDs 1 to 247) on port 502.
How does Modbus TCP handle Unit ID (Slave ID) addressing?
In direct Modbus TCP devices, the IP address uniquely identifies the unit. However, when passing through an Ethernet-to-serial gateway, the Unit ID is used to address the downstream RS-485 serial slave device.
How do I test a Modbus TCP server simulator with Python?
Use Python's pymodbus library to instantiate ModbusTcpClient with server IP ('127.0.0.1') and port (502), connect, and call read_holding_registers() or write_register() to verify live communication.
Can Modbus Simulator Desktop run offline without an internet connection?
Yes. Modbus Simulator Desktop is a native 64-bit Windows executable that runs 100% locally and offline without requiring internet connectivity once activated.