Skip to content

C tool to record the read timestamp of IEC 61850 Sampled Values

License

Notifications You must be signed in to change notification settings

seapath/sv_timestamp_logger

Description

The SV Timestamp Logger tool lets you record the timestamps of sample values received on a network interface.

In accordance with the IEC 61850 standard, SV enable the transmission of current and voltage values in the form of different digital streams. With this tool, it is possible to listen to one or all streams.

If the NIC enables hardware PTP, hardware timestamping can also be activated.

If required, the SV drop can be calculated, i.e. the number of SVs that could not be logged.

Note that the timestamp record file is configurable and that it is also possible to record only the timestamp of the first SV.

How to install

Get SV parser

sv_timestamp_logger uses sv_parser as a git submodule. The sv_timestamp_logger repository must be cloned with --recurse-submodules option. If you already clone the repository without this submodule, you can launch git submodule update --init.

Build Docker container

Just run:

docker build . --tag sv_timestamp_logger

If you want to create an archive:

docker image save -o sv_timestamp_logger.tar sv_timestamp_logger

Cross compilation

This container was tested on both x86 and arm64 machines. Cross-compilation is available throug Docker build command.

For example, to build the container for arm64 on a x86 machine, use the command

docker build --platform linux/arm64 . --tag sv_timestamp_logger_arm64

Static build

A static version of sv_timestamp_logger is available. It requires the following packages : - clang - cmake - libpcap - make - ninja

You can build the static version with the commands:

cmake -G Ninja -DBUILD_STATIC=ON .
ninja sv_timestamp_logger

Static build with docker

To avoid having to install the dependency, the dockerfile can be used to compile the static version of sv_timestamp_logger:

docker build -t sv_timestamp_logger_static --build-arg CMAKE_ADDITIONNAL_ARGS="-DBUILD_STATIC=ON" .

Once the build is done, you must launch the container to retrieve the static binary and copy it on your machine.

docker run --rm -v $(pwd):$(pwd) --entrypoint "" sv_timestamp_logger_static cp /usr/bin/sv_timestamp_logger $(pwd)/sv_timestamp_logger_static

The binary will be owned by root. You can change the owner to your user with the following command:

chown $USER:$USER sv_timestamp_logger_static

Note: If you are cross compiling from one platform to another, you will need to add the argument --platform to the docker run command. This requires the qemu-static package of your distribution to be installed.

Usage

Launch the docker container with the following command, to get the help message of sv_timestamp_logger.

docker run sv_timestamp_logger --help

For example, the following command launch sv_timestamp_logger to capture all SV streams on interface enp3s0 and log them to /tmp/sv_log.

docker run --cap-add=sys_nice -v /tmp:/tmp --network=host sv_timestamp_logger -d enp3s0 -f /tmp/sv_log

Note: --cap-add=sys_nice and --network=host option are required respectively to enable RT priority and to access the host network interfaces. --cap-add=net_admin will also be required to use hardware timestamping.

Usage on SEAPATH

For more information on how to use this tool to test a SEAPATH infrastructure, refer to Simulating IEC61850 traffic for Seapath" on the SEAPATH wiki

Results

The docker must be stopped for the results to be printed entirely. The data generated by the sv_timestamp_logger looks the following:

0:svID0000:3999:1727698715978775
0:svID0001:3999:1727698715978797
0:svID0002:3999:1727698715978804
...
  • The first column designates the number of times the PCAP file is played.

  • The second column designates the stream ID of each SV recorded.

  • The third column designates the SV counter of each SV recorded.

  • The last column designates the timestamp when the SV has been recorded, in µs. This timestamp follows the UNIX time format “Epoch” (number of µs elapsed since 01/01/1970). In this example, the PCAP is played for the first time, three streams are received (svID0000, svID0001 and svID0002) and all the SV have the number 3999.

About this documentation

This documentation uses the AsciiDoc documentation generator. It is a convenient format that allows using plain-text formatted writing that can later be converted to various output formats such as HTML and PDF.

In order to generate an HTML version of this documentation, use the following command (the asciidoc package will need to be installed in your Linux distribution):

$ asciidoc README.adoc

This will result in a README.html file being generated in the current directory.

If you prefer a PDF version of the documentation instead, use the following command (the dblatex package will need to be installed on your Linux distribution):

$ asciidoctor-pdf README.adoc

About

C tool to record the read timestamp of IEC 61850 Sampled Values

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published