0
0
Scada-systemsHow-ToBeginner · 4 min read

How IEC 104 Protocol Works in SCADA Systems Explained

The IEC 104 protocol is a communication standard used in SCADA systems to exchange control and monitoring data over TCP/IP networks. It works by establishing a client-server connection where the SCADA master requests data and controls from remote devices (RTUs) using predefined message types and timed sequences.
📐

Syntax

The IEC 104 protocol uses a structured message format over TCP/IP. Each message consists of an Application Protocol Data Unit (APDU) with three parts:

  • Start Frame: Marks the beginning of a message.
  • Length Field: Specifies the size of the message.
  • APCI and ASDU: The control information (APCI) and the actual data (ASDU) like measurements or commands.

Communication follows a client-server model where the SCADA master (client) initiates requests and the RTU (server) responds.

plaintext
Start Frame (1 byte) | Length (1 byte) | APCI (4 bytes) | ASDU (variable length)
💻

Example

This example shows a simplified Python snippet simulating an IEC 104 client sending a start data request to a server and receiving a response.

python
import socket

# IEC 104 server address and port
server_ip = '192.168.1.100'
server_port = 2404

# Create TCP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((server_ip, server_port))

# Example IEC 104 start data request frame (simplified)
start_request = bytes([0x68, 0x04, 0x07, 0x00, 0x00, 0x00])

# Send request
sock.sendall(start_request)

# Receive response
response = sock.recv(1024)
print('Received:', response.hex())

sock.close()
Output
Received: 680407000000
⚠️

Common Pitfalls

Common mistakes when working with IEC 104 in SCADA include:

  • Not handling connection timeouts properly, causing communication failures.
  • Ignoring sequence numbers in APCI, which can lead to message loss or duplication.
  • Misinterpreting ASDU types, resulting in wrong data processing.
  • Using incorrect port numbers; IEC 104 typically uses TCP port 2404.

Always validate message structure and implement retries for robust communication.

python
## Wrong: Ignoring sequence numbers
# Sending messages without incrementing send sequence
send_seq = 0
for _ in range(3):
    frame = bytes([0x68, 0x04, 0x07, 0x00, 0x00, 0x00])  # Same frame sent repeatedly
    sock.sendall(frame)

## Right: Incrementing sequence numbers
send_seq = 0
for _ in range(3):
    send_seq += 1
    frame = bytes([0x68, 0x04, 0x07, send_seq, 0x00, 0x00])
    sock.sendall(frame)
📊

Quick Reference

ConceptDescription
Start Frame (0x68)Marks start of IEC 104 message
Length FieldIndicates message size in bytes
APCIApplication Protocol Control Information, manages connection and sequence
ASDUApplication Service Data Unit, carries actual data or commands
PortDefault TCP port 2404 for IEC 104 communication
Client-ServerSCADA master is client, RTU is server
Sequence NumbersUsed in APCI to track message order and confirm receipt

Key Takeaways

IEC 104 uses TCP/IP to send structured control and monitoring data in SCADA.
Messages have a fixed format with start frame, length, control info, and data.
Sequence numbers in messages ensure reliable communication.
Port 2404 is the standard for IEC 104 connections.
Proper error handling and message validation are essential for stable SCADA operation.