Prerequisites

The IEC 60870-5-104 transport handler is located in the IEC60870 Wrapper Feature.

To use the IEC60870 Wrapper Feature, one has to install the j60870 Feature that is licensed under the GPLv3. The j60870 Feature contains the j60870 library that is originally developed by Stefan Feuerhahn (Frauenhofer ISE) and provided by openMUC under the GPLv3. It is modified by the University of Oldenburg. 

The protocol itself

The source of this section is Wikipedia.

IEC 60870 part 5 is one of the IEC 60870 set of standards which define systems used for telecontrol (supervisory control and data acquisition) in electrical engineering and power system automation applications. Part 5 provides a communication profile for sending basic telecontrol messages between two systems, which uses permanent directly connected data circuits between the systems. The IEC Technical Committee 57 (Working Group 03) have developed a protocol standard for telecontrol, teleprotection, and associated telecommunications for electric power systems. The result of this work is IEC 60870-5. Five documents specify the base IEC 60870-5:

The IEC Technical Committee 57 has also generated companion standards:

IEC 60870-5-101/102/103/104 are companion standards generated for basic telecontrol tasks, transmission of integrated totals, data exchange from protection equipment & network access of IEC101 respectively. IEC 60870-5-101 is a standard for power system monitoring, control & associated communications for telecontrol, teleprotection, and associated telecommunications for electric power systems. This is completely compatible with IEC 60870-5-1 to IEC 60870-5-5 standards and uses standard asynchronous serial tele-control channel interface between DTE and DCE. The standard is suitable for multiple configurations like point-to-point, star, mutidropped etc.

Features

The source of this section is Wikipedia.

Frame format

The source of this section is Wikipedia.

Character format of IEC 101 uses 1 start bit, 1 stop bit, 1 parity bit & 8 data bits. FT1.2 (defined in IEC 60870-5-1) is used for frame format of IEC 101 which is suitable for asynchronous communication with hamming distance of 4. This uses 3 types of frame formats - Frame with variable length ASDUFrame with fixed length & single character. Single character is used for acknowledgments, fixed length frames are used for commands & variable lengths are used for sending data. The details of variable length frame is given below

IEC 101 Frame Format, Variable length

Data unitNameFunction
Start FrameStart CharacterIndicates start of Frame
Length Field (*2)Total length of Frame
Start Character (repeat)Repeat provided for reliability
Control FieldIndicates control functions like message direction
Link Address (0,1 or 2)Normally used as the device / station address
Data Unit IdentifierType IdentifierDefines the data type which contains specific format of information objects
Variable Structure QualifierIndicates whether type contains multiple information objects or not
COT (1 or 2)Indicates causes of data transmissions like spontaneous or cyclic
ASDU Address (1 or 2)Denotes separate segments and its address inside a device
Information ObjectInformation Object Address (1 or 2 or 3)Provides address of the information object element
Information Elements (n)Contains details of the information element depending on the type
Information Object-2-----
----------
Information Object-m

Stop FrameChecksumUsed for Error checks
Stop CharIndicates end of a frame

Types supported

The source of this section is Wikipedia.

IEC 60870-5-104 (IEC 104) protocol is an extension of IEC 101 protocol with the changes in transport, network, link & physical layer services to suit the complete network access. The standard uses an open TCP/IP interface to network to have connectivity to the LAN (Local Area Network) and routers with different facility (ISDNX.25Frame relay etc.) can be used to connect to the WAN (Wide Area Network). Application layer of IEC 104 is preserved same as that of IEC 101 with some of the data types and facilities not used. There are two separate link layers defined in the standard, which is suitable for data transfer over Ethernet & serial line (PPP - Point-to-Point Protocol). The control field data of IEC104 contains various types of mechanisms for effective handling of network data synchronization.

The security of IEC 104, by design has been proven to be problematic, as many of the other SCADA protocols developed around the same time. Though the IEC technical committee (TC) 57 have published a security standard IEC 62351, which implements end-to-end encryption which would prevent such attacks as replay, man-in-the-middle and packet injection. Unfortunately due to the increase in complexity vendors are reluctant to roll this out on their networks.


IEC 60870-5-104 transport handler

In Odysseus, both protocol stacks, client and server, are implemented as transport handler. A "104 server" represents a field station and a "104" client a grid control system. Important is that both transport handler do also the work of protocol handlers. Therefore, they must always be combined with the "None" protocol handler. See the examples below for the usage of the transport handler.

#PARSER PQL
#RUNQUERY
input := ACCESS({
          transport = 'iec60870-5-104_client',
          wrapper = 'GENERICPUSH',
          source = '104server',
          datahandler = 'tuple',
          options = [['host', '192.168.1.38'], ['port', '2404']],      
          schema = [
            ['typeId', 'object'],
            ['isSequenceOfElements', 'boolean'],
            ['causeOfTransmission', 'object'],
            ['test', 'boolean'],
            ['negativeConfirm', 'boolean'],
            ['originatorAddress', 'integer'],
            ['commonAddress', 'integer'],
            ['sequenceLength', 'integer'],
            ['informationObjects', 'list'],
            ['areInfosPrivate', 'boolean']
          ]                
        }            
      )
#PARSER PQL
#RUNQUERY
out = SENDER({
          protocol = 'None',
          transport = 'iec60870-5-104_client',
          sink = '104server',
          wrapper = 'GenericPush',
          datahandler = 'tuple',
          options = [['host', '192.168.1.38'], ['port', '2404']]                
        },
        input
      )
#PARSER PQL
#RUNQUERY
input := ACCESS({
          transport = 'iec60870-5-104_server',
          wrapper = 'GENERICPUSH',
          source = '104client',
          datahandler = 'tuple',
          options = [['host', '192.168.1.38'], ['port', '2404']],      
          schema = [
            ['typeId', 'object'],
            ['isSequenceOfElements', 'boolean'],
            ['causeOfTransmission', 'object'],
            ['test', 'boolean'],
            ['negativeConfirm', 'boolean'],
            ['originatorAddress', 'integer'],
            ['commonAddress', 'integer'],
            ['sequenceLength', 'integer'],
            ['informationObjects', 'list'],
            ['areInfosPrivate', 'boolean']
          ]                
        }            
      )
#PARSER PQL
#RUNQUERY
out = SENDER({
          protocol = 'None',
          transport = 'iec60870-5-104_server',
          sink = '104client',
          wrapper = 'GenericPush',
          datahandler = 'tuple',
          options = [['host', '192.168.1.38'], ['port', '2404']]                
        },
        input
      )