IEC 60870-5 Source Code Libraries

For almost 30 years, Triangle has provided the diagnostic tools and protocol expertise to  our customers to support all their conformance  & certification needs. We will work with you to ensure that your implementation of our source code libraries will pass all industry related certification and conformance testing.

Related Products

What's New

Current Release: v3.32
Release Date:March 2024

Newest Features in this Release

  • Added TCP channel callback functions to retrieve IP addresses when the server is connected or disconnected.
  • Channels are no longer closed automatically when the last session on the channel is closed.
  • In WinIoTarg improvements to UDP/TCP receiving will avoid errors if the UDP broadcast message received in middle of the TCP octets.

  • In WinIoTarg, added a channel diagnostic mask bit to control whether diagnostics messages are generated.

  • In LinIoTarg improvements to use linked list instead of array for keep channels listening on a particular port. That improvement will allow unlimited channels be configured to one specific TCP port.
  • In WinIoTarg, if the TCP listening thread is not started due to the port being occupied, the channel is now closed more quickly (previously could take up to 5 seconds).


Key Additions to Recent Releases


  • “Slave” has been replaced by “Outstation”, “Controlled Station”, or “Server” depending on protocol in documentation, filenames, variable names, and function names. An effort has been made to maintain interface backward compatibility where possible.
  • Minor changes to allow SCL to build with VS2019 and VS2022 without modification related to std::string and .NET Framework version.
  • Added support for OpenSSL Version 3.x.x. OpenSSL Version 1.1.1 is still supported, however according to the End Of Life date for the 1.1.1 series is September 11 2023. Support for Version 1.0.2 has been removed.
  • In WinIoTarg and LinIoTarg add clientSourceIpPort to allow TCP Client Channels to specify the IP Port to use for originating TCP Connections.
  • Add support for TMWDIAG_ID_OCTETS bit to determine whether the actual Hex Octets from a transmitted or received message are formatted and/or displayed in a diagnostic message.
  • In S14 Simulated Database include MIT Sequence and Quality when a Freeze Command causes an event to be generated.


  • In LinIoTarg speed up processing during TCP Channel closing.

  • Add support for multiple Polled Timers and disabling the Windows Target Layer multiple timers to allow application to run SCL in the context of its own threads.

  • Secure Authentication. Improve tmwcrypto.c support for multiple sessions when Simulated Crypto Database is being used during initial portation.

  • .NET Secure Authentication. Improve TMWCRYPTO_ASYMTESTING if compiled in so that sample asymmetric key files can be found.

  • M104 Improve diagnostics to display the time when a time sync is sent.

  • S101/104 Add feature to allow disabling of Type IDs at run time.

  • S104 Close TCP connection and Listen again when CRPNA command is received.

  • S104 When a StopDT is received do not queue any more spontaneous responses containing events until a StartDT is received. This allows better enforcing of event queue sizes and removing duplicate events from the queue if configured to do so.

  • .NET SCL. Add associated control point functionality ControlIOA Property to S14SimPoints. This allows more flexibility than sector database property ControlPointOffset. Points which do not have ControlIOA set still use the common offset. This per point functionality must be enabled per sector by setting ControlIOAEnabled to prevent unnecessary processing.


  • In WinIoTarg added define to allow channel thread code to be compiled out.

  • Improved TLS example code and included sample TLS Certificates for ANSI C and
    .NET SCLs.

  • In .NET SCL when CRPNA (Reset Process) is received reset the sector to cause
    MEINA to be sent even when .NET event S14Database::UseSimControlDatabase
    is set to false.

  • Reduced default compiled in functionality for ANSI C and .NET IEC 60870-5 SCL. All
    functionality, must be carefully chosen, tested and then documented in the CIGuide
    (and PICS for Secure Authentication) specific to your device. The .NET SCL
    will now have the same default functionality compiled in as the ANSI C SCL. The
    file tmwprvt.h will no longer be provided to turn on additional .NET functionality.


  • In WinIoTarg potentially speed up waiting for a channel thread to exit when a
    channel with polledMode=false is closed.
  • In LinIoTarg replaced deprecated stime() with clock_settime()
  • In LinIoTarg speed up new connection indication to protocol library when running
    with polledMode=true.
  • Support .NET txPhysCallbackEvent, rxPhysCallbackEvent, txApplCallbackEvent,
    and rxLinkCallbackEvent callback events in TMWChannel class for all protocols.
    Move .NET rxLinkHdrCallbackEvent and rxTransportCallbackEvent callback events
    out of TMWChannel class to DNPChannel since those two events only apply to
    DNP channels and were misleading.
  • Add M104 and M101 C Sample code and .NET Application sample to demonstrate how to use File Transfer in the libraries.


  • Separate 104 and 101 file transfer .NET database event interface from rest of the database, so that the decision to implement these can be independent from implementing the rest of 104 and 101 database.
  • In LinIoTarg use localIpAddress when a TCP Client binds to the connect socket. 
  • When S104 and S101 is configured to send clock sync events when the timestamp in an event has an hour different from the previous event sent, only do this if the timestamp being sent in this new event is 24bit timestamp, not when no timestamp or 56 bit timestamp (which already has the hour in it) is sent.
  • Add balancedRetryTimeout configuration parameter to allow delayed command
    responses sent faster when in balanced mode.
  • Add class1DataForClass2Poll configuration to enable/disable sending class 1 data
    in response to a class 2 poll if there is no class 2 data to send. That behavior is
    specified in 101 but some masters do not support the 101 spec completely.
  • Separate 101 file transfer .NET database event interface from rest of the database,
    so that the decision to implement these can be independent from implementing the
    rest of 101 database.


  • Simplified Secure Authentication (SA) CSQ algorithm removing aggressiveModeTxSequence.
  • Removed compiled out and unfinished SA Remote Key Update code. 


  • Created an implementation guide for SCLs.
  • In addition, Smaplelo Targ has been created. This Sample target layer is a target layer example that can be complied and linked with the wintoolkit C example programs that has no OS dependencies. It can be used as a baseline target layer to port the library to another OS or RTOS. It can be built by specifying build = sample from the Linux command line.
  • Return the intermediate response statuses during command processing when ActTerm is ON. 

  • Added configuration to M104 to resolve an issue with the Secure Authentication Specification where M104SA sends a CTSTA (Test With Time) as the first message before beginning aggressive mode. If the time on the master and slave is out of sync this command may fail. In m104 - initTestCTSNA allows CTSNA (Test Without Time) to be sent if supported instead. 

  • The SCL has been updated to work with OpenSSL 1.1.x while retaining backward compatibility with version 1.0.x. For Windows builds a new define has been added, TMWCNFG_USE_OPENSSL_1_0_2 that must be defined when running with the legacy version. 

  • The wintooltkit samples now include TLS support. The samples include certificates that are compatible with those used by the test harness and the default configurations for both Linux and Windows are set to use them. Only a single define USE_TLS which defaults to false needs to be updated to configure the sample to use TLS for both DNP and 101/4 Secure Authentication builds. 

  • WinIoTarg now uses the Channel thread to check for received data eliminating the need for a separate CheckForInput thread/class. 

  • Update Linux target layer to use consistent logging technique

  • LinIoTarg now creates a thread per channel (when not configured to run in polled mode). Once the channel has been opened, this thread will establish/listen for the channel connection and wait on the data socket for incoming data. This eliminates the latency when polling for received data. Also, locking has been reduced by eliminating the linked list of TCP Channels which required locking each time the list was accessed.

  • Updated linTCP_transmit to check the error code returned by send. If its EAGAIN indicating that the socket is busy, wait for the socket to become writable and retry the send instead of disconnecting immediately. 

  • The Linux target layer has been updated to provide a basis for porting a target layer to another OS: 
  • A tmwtargcnfg.h file has been added to both the Linux and Windows target layer. This configuration file defines which features a given target layer supports. This will allow customers porting the Linux target layer to other OS's to easily identify code that may be unnecessary for their application and remove it instead of wasting time porting it. Target layer features currently defined in this file are:
    1. RS232
    2. TCP
    3. UDP (Only required for DNP)
    4. TLS
    5. EPOLL
  • Made improvements to target layer timer examples.

  • Implemented event driven receive data in winiotarg so channels don’t have to be polled. This is also available in liniotarg.

  • Updated the Linux target layer, replaced LINIOCNFG_EVENT_DRIVEN conditional with polledMode configuration.

  • Support for epoll has been added to the Linux target layer. This support is controlled by the preprocessor conditional LINIOTARG_SUPPORT_EPOLL. If this is not defined, select is used. The select option has been left in place so we continue to have an example that can be ported to OS’s that do not support epoll.

  • Include files to allow SCL customers to generate Windows project files for different versions of Visual Studio.

  • Support for 64-bit versions of the .NET Protocol Components has been added.

  • Added configuration for the generation of diagnostic messages per sector, session, and channel to allow maximum flexibility. Maximum performance can be achieved by configuring each mask to zero so no diagnostic messages are generated, thus no messages would be forwarded to the .NET code. This also would allow a user to enable diagnostic messages on a single sector, session, etc. in a large configuration on a problem connection and avoid having to filter out diagnostic messages from all other connections.

  • Updated database wrapper header files and removed the /clr flag from the 870Managed and utilsManaged projects.

  • Updated simulated databases to use this diagnostic function, i14diag_securityStatisticString, instead of each maintaining its own copy.


  • Improved performance of database interface and other library functions
  • Restructured directories and sample code for Windows® and Linux® target layer libraries
  • Expanded Windows target layer support for resolving IP address from destination host name
  • Updated Linux sample makefiles to generate debug information by default
  • 101/104: Added multiple enhancements to Secure Authentication library and documentation
  • 101/104: Updated IEC 60870-5 (101/104) Master CI Guide to better reflect capabilities of library
  • 104: Added support for IPv6 in Linux target layer
  • 101/104: Added support for Secure Authentication for IEC 60870-5 (-101 and -104) according to the IEC 60870-5-7 standard based on the cyber-security standard IEC 62351 (Parts 3, 5, and 8)
  • 101/102/103/104: Improved Linux makefiles and Windows solution and project files
  • 101/104: Improved integration with OpenSSL library
  • 101/104: Added call to the user callback function for master when ACT CON response is received in response to CICNA and CCINA requests
  • 101/104: Added call to the user callback function for master when ACT TERM response is received from each sector in response to CICNA and CCINA broadcast requests, not just the final ACT TERM response
  • 104: Improved handling of TCP connection loss for controlled station (outstation)
  • 101/104: Improved support for creating a redundant channel
  • 101: Corrected an error in Delay Acquisition, where the time was calculated incorrectly
  • 101/104: Fixed issue with The Double Transmission feature
  • 101/104: Corrected an issue when using unique functions for cdc and crc status functions and using the automatic generation of 101/104 protocol events with COT Remote when a control is received
  • 101: Added support in .NET library for case when user overrides control database but not monitored point database
  • 101/104: Modify code to allow use of either UNICODE or MBCS character set
  • 101/102/104: Changed master 101/102/104 to ignore the COT "test bit". Master will indicate the COT test bit was set in the diagnostics messages, then mask off that bit and process the COT normally
  • 101/104: Improved Master 101/104 to better enforce rules for responses to Select requests
  • 104: Add configuration for time tagged requests with time in the future to be allowed.
  • 104: Validate time tagged requests with time in the future not just expired time and expand maximum allowed “age” in the past or in the future of allowed commands.
  • 101: Added feature to allow controlled station to support multiple requests of the same Type Id to be processed simultaneously
  • Added more checking to discard improperly formatted messages
  • Allow compile time choice of using either standard or Microsoft “safe” string functions that include the length of the buffer to be written to (ie strcpy or strcpy_s)
  • Only generate cyclic and background data when online. This was done to improve cyclic behavior when the connection is lost
  • 101 and 104: Enhanced examples to show the different addEvent possibilities and use the sector time instead of the system time
  • 104: Added validating state for conformance testing - disconnect if I or S Frame is received when link is stopped

for IEC 60870-5-101:
v3.12 - Added support for Peer (dual mode) session with the same address and support for Double Transmission. v3.07 - Added sample Linux and Window target implementation. v3.01.01 - Added ability to keep time on a per-session basis. v3.00.45 - Added support for Gasunie PIDs. v3.00.38 - Added ability to display Structured IOAs.

for IEC 60870-5-102:

v3.07 - Added sample Linux and Window target implementation.
v3.01.01 - Added ability to keep time on a per-session basis.
v3.00.25 - Added ability for Master to queue commands.

for IEC 60870-5-103:
v3.07 - Added sample Linux and Window target implementation.
v3.01.01 - Added ability to keep time on a per-session basis.
v3.00.45 - Added support for Areva private ASDUs and for Siemens SIPROTEC private ASDU 205.
v3.00.29 - Enhanced support for multiple threads.
v3.00.25 - Added ability for Master to queue commands.
v3.00.22 - Added support for ASDU 124 Procomoe specification.

for IEC 60870-5-104:
v3.12 - Added support for Double Transmission.
v3.07 - Added sample Linux and Window target implementation.
v3.01.01 - Added ability to keep time on a per-session basis.
v3.00.45 - Added support for Gasunie PIDs.
v3.00.38 - Added ability to display Structured IOAs.
v3.00.35 - Added memory alignment support.
v3.00.32 - Added support for multiple threads.
v3.00.25 - Added ability for Master to queue commands.




Quick Links  Contact Us:
About Us

Triangle MicroWorks, Inc.
Sales: +1 919.870.5101
Support: +1 919.781.1931
Fax: +1 919.870.6692

Follow us on YouTube Follow us on Facebook Visit us on LinkedIn Follow us on Twitter

Copyright © 2013-2024 Triangle MicroWorks, Inc. All Rights Reserved