0
0
Scada-systemsHow-ToBeginner · 4 min read

How to Simulate RTU for SCADA Testing: Simple Guide

To simulate an RTU for SCADA testing, use software tools that mimic RTU behavior by sending and receiving protocol data like Modbus TCP/RTU. Configure the simulator to emulate sensor data and respond to SCADA commands, enabling realistic testing without physical devices.
📐

Syntax

Simulating an RTU involves setting up a software tool that acts like a real RTU device. The basic syntax for a Modbus RTU simulator command line might look like this:

  • modbus_simulator --protocol modbus-rtu --port COM3 --baudrate 9600
  • modbus_simulator --protocol modbus-tcp --ip 192.168.1.100 --port 502

Here’s what each part means:

  • --protocol: Choose the communication protocol (Modbus RTU or TCP)
  • --port: Serial port for RTU or TCP port for network communication
  • --baudrate: Speed of serial communication (only for RTU)
  • --ip: IP address of the simulator (only for TCP)
bash
modbus_simulator --protocol modbus-rtu --port COM3 --baudrate 9600
modbus_simulator --protocol modbus-tcp --ip 192.168.1.100 --port 502
💻

Example

This example shows how to simulate an RTU using a Python library called pymodbus. It creates a Modbus TCP server that acts like an RTU device, responding to SCADA requests with sample data.

python
from pymodbus.server.sync import StartTcpServer
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
from pymodbus.datastore import ModbusSequentialDataBlock

# Create data store with some registers
store = ModbusSlaveContext(
    hr=ModbusSequentialDataBlock(0, [10, 20, 30, 40, 50])
)
context = ModbusServerContext(slaves=store, single=True)

# Device identification
identity = ModbusDeviceIdentification()
identity.VendorName = 'RTU Simulator'
identity.ProductCode = 'RS'
identity.VendorUrl = 'http://example.com'
identity.ProductName = 'Modbus RTU Simulator'
identity.ModelName = 'RTU Sim'
identity.MajorMinorRevision = '1.0'

# Start Modbus TCP server on localhost:5020
StartTcpServer(context, identity=identity, address=('localhost', 5020))
Output
Server running on localhost:5020, responding to Modbus TCP requests with preset register values.
⚠️

Common Pitfalls

When simulating RTUs for SCADA testing, watch out for these common mistakes:

  • Wrong protocol or port: Using TCP settings for RTU serial or vice versa causes connection failures.
  • Incorrect baud rate or serial settings: Mismatched baud rate, parity, or stop bits prevent communication.
  • Not updating simulated data: Static data does not reflect real sensor changes, reducing test realism.
  • Firewall or network issues: Blocking ports can stop SCADA from reaching the simulator.

Example of a wrong command and fix:

Wrong: modbus_simulator --protocol modbus-tcp --port COM3
Right: modbus_simulator --protocol modbus-rtu --port COM3 --baudrate 9600
bash
modbus_simulator --protocol modbus-tcp --port COM3
modbus_simulator --protocol modbus-rtu --port COM3 --baudrate 9600
📊

Quick Reference

Command PartDescriptionExample
--protocolCommunication protocol to simulatemodbus-rtu or modbus-tcp
--portSerial port (RTU) or TCP port (TCP)COM3 for RTU, 502 for TCP
--baudrateSerial communication speed (RTU only)9600
--ipIP address for TCP simulation192.168.1.100

Key Takeaways

Use a Modbus simulator tool or library to mimic RTU behavior for SCADA testing.
Configure protocol, port, and communication settings correctly to avoid connection issues.
Update simulated data dynamically to reflect real sensor changes for realistic tests.
Test network and firewall settings to ensure SCADA can communicate with the simulator.