IEC 870-5-104 Simulator: Complete Guide to Setup and TestingIEC 870-5-104 (often abbreviated IEC 60870-5-104 or simply IEC 104) is a widely used protocol for telecontrol in electrical power systems. It extends the IEC 60870-5-101 protocol by providing communication over TCP/IP networks, enabling remote control and monitoring between control centers and substations. An IEC 104 simulator is an essential tool for engineers, testers, and integrators who need to develop, validate, and troubleshoot SCADA systems, RTUs (Remote Terminal Units), and protection relays without connecting to live production equipment.
This guide covers what an IEC 104 simulator is, why you need one, required components, installation and configuration steps, test scenarios, interoperability checks, performance considerations, troubleshooting tips, and best practices for secure and reliable testing.
What is an IEC 870-5-104 simulator?
An IEC 104 simulator emulates devices (servers/RTUs) or clients (control centers) that speak the IEC 104 protocol over TCP. It can:
- Emulate an RTU/IED that provides process values, status indications, counters, and time-tagged events.
- Emulate a control center issuing commands (single command, double command, setpoint adjustments) and reading measurements.
- Log, capture, and decode IEC 104 messages for analysis.
- Replay saved communication traces for repeatable tests.
Simulators range from simple command-line tools to full-featured GUI applications and programmable platforms that support scripting, automated test suites, and integration with hardware-in-the-loop setups.
Why use a simulator?
- Safe testing: Validate logic, protection schemes, and HMI behavior without risking live equipment.
- Development acceleration: Developers can implement application logic before hardware is available.
- Interoperability testing: Ensure different vendors’ equipment exchange data as expected.
- Regression and automated testing: Repeatable test cases for firmware or SCADA updates.
- Training: Provide realistic scenarios for operator and engineer training.
Components and prerequisites
- A machine (Windows/Linux/macOS) for running the simulator.
- Network connectivity (physical or virtual) between simulator and target.
- IEC 104 simulator software (open-source or commercial).
- Optional: PCAP/network capture tool (e.g., Wireshark), protocol analyzer that understands IEC 104.
- Optional: Hardware interfaces or protocol converters if testing with serial-to-IP or gatewayed environments.
- Knowledge of IEC 104 basics: ASDU types, Information Object Addresses (IOAs), cause of transmission, sequence vs. single-frame (I-frames vs. S/U-frames), and common ASDU types (M_ME_NA for measured values, M_SP_NA for single-point status, etc.).
Choosing a simulator
Factors to consider:
- Protocol coverage: support for required ASDU types, time tags (CP56Time2a), commands (single/double), scaled and normalized values.
- Roles: server (slave/RTU) vs. client (master/control center) or both.
- Automation: scripting (Python, Lua), CLI, or REST API for integration with CI systems.
- Performance: supported concurrent connections, throughput, and timing accuracy.
- Logging & decoding: human-readable logs, hex dumps, Wireshark integration.
- Licensing, support, and platform compatibility.
Popular choices include open-source tools (lib60870-C, lib60870-CSharp, open-source simulators) and commercial test suites with GUIs and automation features. Select based on feature needs and budget.
Installation and initial setup
- Install simulator software.
- On Linux, follow package or build instructions; many libraries require building from source.
- On Windows, use installer or zip packages; ensure required runtimes (e.g., .NET for C# tools).
- Set up network:
- Determine IP addresses for simulator and target device.
- If testing locally, use loopback or virtual network interfaces; use separate VLANs or isolated lab network to avoid interfering with production.
- Configure basic protocol parameters:
- TCP port (default IEC 104 port is 2404).
- ASDU addressing: common ASDU address (0–65535) and Information Object Address (IOA).
- Message formats: enable/disable time stamps, set qualifier of interrogation (U/I/S frame behavior), and set maximum PDU sizes (T0/T1 parameters where applicable).
- Configure roles:
- Server (RTU) mode: define data points to expose (types, IOAs, initial values, timestamps).
- Client (master) mode: set polling intervals, read/write permissions, and command behavior.
- Firewall and OS settings:
- Open TCP/2404 on testing hosts.
- Disable OS features that may interfere with precise timing for performance testing (power-saving/network offload features).
Creating realistic simulation data
Design a data model that mirrors expected deployments:
- Map real IOAs, names, units, and data types.
- Include a mix of point types: single-point (on/off), double-point, measured values (scaled int or float), counters, and time-tagged events.
- Add realistic change patterns:
- Periodic updates for analog values.
- Sporadic status changes for events/alarms.
- Sequence numbers and cause-of-transmission variations (periodic, spontaneous, interrogation).
- Configure time stamps (CP56Time2a) if your target requires synchronized events.
Example data set:
- IOA 1001: Single-point status “Breaker 1” (initial OFF).
- IOA 2001: Measured voltage (scaled integer) 110.0 kV, updated every 2s.
- IOA 3001: Counter for energy pulses, increment triggered on simulated event.
Basic test procedures
- Connection test
- Start simulator in server mode listening on port 2404.
- From master/control-center, attempt connection; confirm TCP session establishment.
- Verify U-frames (start/stop/reset) and I-frame exchange.
- Interrogation (general interrogation)
- From master, send interrogation command (C_IC_NA_1).
- Ensure simulator replies with all configured points with correct cause-of-transmission and timestamps.
- Polling and spontaneous reporting
- Confirm periodic reporting: master polls or simulator sends spontaneous ASDUs with cause spontaneous (COT=3).
- Test cause-of-transmission variations: periodic (COT=1), spontaneous, initialization (COT=5).
- Command testing
- Issue single commands (C_SC_NA_1) and double commands (C_DC_NA_1); verify simulator acknowledges (C_SC_NA_1 with appropriate COT) and updates point states.
- Test setpoint commands (C_SE_NA_1) for analog outputs and confirm value handling and limits.
- Time synchronization and timestamp tests
- Send and verify CP56Time2a formatted timestamps.
- Test behavior when simulator’s internal time is changed or when timestamps are omitted.
- Sequence and corruption tests
- Introduce intentionally dropped or delayed I-frames, check sequence number handling and retransmission behavior.
- Send malformed ASDUs to verify robustness of target device.
Automation and scripting
- Use built-in scripting or external scripts to run repeatable test suites.
- Typical automated tests:
- Connection stability under repeated connect/disconnect cycles.
- Load tests: increasing number of data points and message rate.
- Regression tests: known bug reproduction and verification after fixes.
- Example automation tasks:
- Start simulator, run a set of predefined scenario files that change values over time, capture logs, and compare against expected outputs.
- Use CI pipelines to run protocol conformance suites when firmware is built.
Performance and load testing
- Define realistic load: number of points, update rate, number of simultaneous masters, and message sizes.
- Measure:
- Latency: time from value change to message receipt at master.
- Throughput: ASDUs per second, TCP sessions, and bandwidth usage.
- CPU/memory usage on simulator host.
- Stress tests:
- Simulate many spontaneous events in bursts.
- Open many simultaneous client connections and poll aggressively.
- Watch for TCP-level issues: retransmissions, congestion, socket exhaustion.
Interoperability considerations
- Information Object Addressing (IOA): different vendors may use different IOA ranges or structures — map carefully.
- ASDU type support: ensure both ends support the same ASDU types and variants (e.g., 1-byte vs. 3-byte IOA).
- Data representation: scaled integers vs. floats; check multipliers and units.
- Cause of transmission semantics: some masters expect specific COT values for events vs. periodic updates.
- Time tags: verify endianness and offset handling; ensure CP56Time2a compatibility.
- Use Wireshark with IEC 104 dissector to inspect message fields and confirm exact bytes exchanged.
Logging, capturing, and analyzing traffic
- Capture TCP traffic using Wireshark or tcpdump and filter on port 2404.
- Use the simulator’s logging features: enable verbose mode for hex dumps and decoded ASDUs.
- Compare actual messages against expected protocol flows: ASDU type, IOA, function codes, qualifiers, and cause-of-transmission.
- For repeatable analysis, save PCAPs alongside test results.
Security considerations
- Run tests in isolated lab networks — IEC 104 has minimal built-in security.
- Use VPNs or secure tunnels (TLS) where supported by vendors or gateways; many legacy devices don’t support TLS.
- Restrict access to simulator hosts and limit network exposure.
- Use mock authentication/authorization layers in the lab to test operator privilege separation without exposing credentials.
- Consider firewall rules and network segmentation to prevent accidental exposure to production systems.
Common problems and troubleshooting
- Connection refused: verify simulator is listening on port 2404, firewall rules, and correct IP address.
- Unexpected ASDU formats: check ASDU type and IOA length settings (1- vs. 3-byte IOA).
- Missing timestamps: confirm CP56Time2a is enabled for relevant data and that the simulator’s clock is set.
- Commands not accepted: check command qualifiers, interlock logic in simulator, and whether the master expects a specific COT acknowledgement.
- High latency or retransmissions: inspect network path, MTU, socket options, and CPU load.
- Mismatched units/scale: verify scaling factors and value encodings between simulator and master.
Example test scenarios
- Basic connectivity and interrogation:
- Start simulator with 200 points.
- Connect master, issue general interrogation, confirm all points returned with correct COT.
- Protection trip sequence:
- Simulate an overcurrent analog value exceeding threshold.
- Verify master receives alarm and sends a trip command; simulate breaker status change.
- Performance ramp:
- Gradually increase update rate from 1s to 50ms for 500 points; measure latency and CPU.
- Fault injection:
- Drop TCP packets or inject malformed frames to verify master resilience.
- Regression suite:
- Run a sequence of 50 scripted actions (value changes + commands) and compare outputs against golden trace.
Best practices
- Mirror production addressing and data types for realistic tests.
- Keep simulator and target clocks synchronized when testing time-tagged events.
- Automate common tests and store expected results for regression tracking.
- Isolate lab networks; never connect test simulators to production SCADA networks.
- Document scenarios, configurations, and any vendor-specific quirks observed.
- Use protocol analyzers to verify low-level message formats rather than only relying on high-level application logs.
Further reading and resources
- IEC 60870-5-104 standard documentation for formal definitions of ASDUs, I-frames/S-frames/U-frames, and CP56Time2a timestamps.
- Library and toolkit documentation (e.g., lib60870-C, lib60870-CSharp) for implementation-specific guidance.
- Wireshark IEC 104 dissector docs for interpreting captures.
- Vendor manuals for device-specific behavior and known interoperability notes.
Running an IEC 870-5-104 simulator effectively lets you validate communications, test protection and control flows, and build repeatable automated tests without risk to live infrastructure. Proper configuration, realistic data models, and careful logging/capture practices turn the simulator into a powerful ally for development, testing, and training in utility SCADA environments.
Leave a Reply