Skip to main content

A Python module to simulate SCADA and RTU communication over protocol 60870-5-104 to research ICT behavior in power grids.

Project description

iec104-python

Table of contents

  1. Introduction
  2. Licensing
  3. System requirements
  4. Installation
  5. Wiki
  6. Contribution

Introduction

This software provides an object-oriented high-level python module to simulate scada systems and remote terminal units communicating via 60870-5-104 protocol.

The python module c104 combines the use of lib60870-C with state structures and python callback handlers.

Example remote terminal unit

import c104

# server and station preparation
server = c104.Server(ip="0.0.0.0", port=2404)

# add local station and points
station = server.add_station(common_address=47)
measurement_point = station.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000)
command_point = station.add_point(io_address=12, type=c104.Type.C_RC_TA_1)

server.start()

Example scada unit

import c104

client = c104.Client(tick_rate_ms=1000, command_timeout_ms=5000)

# add RTU with station and points
connection = client.add_connection(ip="127.0.0.1", port=2404, init=c104.Init.INTERROGATION)
station = connection.add_station(common_address=47)
measurement_point = station.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000)
command_point = station.add_point(io_address=12, type=c104.Type.C_RC_TA_1)

client.start()

See examples folder for more detailed examples.

Licensing

This software is licensed under the GPLv3 (https://www.gnu.org/licenses/gpl-3.0.en.html).

See LICENSE file for the complete license text.

Dependencies

lib60870-C

This project is build on top of lib60870-C v2 from MZ Automation GmbH, which is licensed under GPLv3.

The library is used for 60870-5-104 protocol based communication.

» Source code

» Documentation

mbedtls

This project is build on top of mbedtls from the Mbed TLS Contributors, which is licensed under Apache-2.0.

The library is used to add transport layer security to the 60870-5-104 protocol based communication.

» Source code

» Documentation

pybind11

This project is build on top of pybind11 from Wenzel Jakob, which is licensed under a BSD-style license.

The library is used to wrap c++ code into a python module and allow seamless operability between python and c++.

» Source code

» Documentation

catch2

This project is build on top of catch2 from the Catch2 Authors, which is licensed under BSL-1.0.

The library is used as testing framework for test-automation.

» Source code

» Documentation

System requirements

Operating systems

  • Debian/Ubuntu (x64): YES >= 20.04
  • Raspbian (arm32v7): YES
  • Windows (x64): YES
  • Raspbian (aarch64): Not yet tested

Python versions

  • python >= 3.6, < 3.13

Installation

Please adjust the version number to the latest version or use a specific version according to your needs.

Install from pypi.org

python3 -m pip install c104

Install from git with tag

python3 -m pip install c104@git+https://github.com/fraunhofer-fit-dien/iec104-python.git

Documentation

Read more about the Classes and their Properties in our read the docs documentation.

Contribution

How to contribute

  1. Add feature requests and report bugs using GitHub's issues

  2. Create pull requests

How to build for multiple python versions (linux with docker)

  1. Build wheels via docker
    /bin/bash ./bin/linux-build.sh
    

How to build (linux)

  1. Install dependencies

    sudo apt-get install build-essential python3-pip python3-dev python3-dbg
    python3 -m pip install --upgrade pip
    
  2. Build wheel

    python3 -m pip wheel .
    

How to analyze performance (linux)

  1. Install dependencies

    sudo apt-get install google-perftools valgrind
    sudo pip3 install yep
    
  2. Copy pprof binary

    cd /usr/bin
    sudo wget https://raw.githubusercontent.com/gperftools/gperftools/master/src/pprof
    sudo chmod +x pprof
    
  3. Execute profiler script

    ./bin/profiler.sh
    

How to build (windows)

  1. Install dependencies

  2. Build wheel

    python3 -m pip wheel .
    

Generate documentation

  1. Build c104 module

  2. Install dependencies

    • python3 -m pip install --upgrade sphinx breathe sphinx-autodoc-typehints
    • doxygen
    • graphviz
  3. Build doxygen xml

    doxygen Doxyfile
    
  4. Build sphinx html

    python3 bin/build-docs.py
    

Change log

Track all changes in our CHANGELOG documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c104-1.18.0.tar.gz (1.8 MB view hashes)

Uploaded Source

Built Distributions

c104-1.18.0-cp312-cp312-win_amd64.whl (386.6 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

c104-1.18.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (532.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

c104-1.18.0-cp311-cp311-win_amd64.whl (385.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

c104-1.18.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (535.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

c104-1.18.0-cp310-cp310-win_amd64.whl (385.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

c104-1.18.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (534.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

c104-1.18.0-cp39-cp39-win_amd64.whl (385.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

c104-1.18.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (533.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

c104-1.18.0-cp39-cp39-linux_armv7l.whl (476.6 kB view hashes)

Uploaded CPython 3.9

c104-1.18.0-cp38-cp38-win_amd64.whl (385.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

c104-1.18.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (558.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

c104-1.18.0-cp37-cp37m-win_amd64.whl (385.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

c104-1.18.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

c104-1.18.0-cp36-cp36m-win_amd64.whl (384.8 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

c104-1.18.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.0 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page