statime-linux

Crates.iostatime-linux
lib.rsstatime-linux
version0.2.2
sourcesrc
created_at2023-11-24 15:28:22.306236
updated_at2024-09-20 14:30:03.732231
descriptionLinux daemon for the Statime Precision Time Protocol library
homepagehttps://github.com/pendulum-project/statime
repositoryhttps://github.com/pendulum-project/statime
max_upload_size
id1047119
size158,143
David Venhoek (davidv1992)

documentation

README

Statime

codecov book book

Statime is a library providing an implementation of PTP version 2.1 (IEEE1588-2019). It provides all the building blocks to setup PTP ordinary and boundary clocks.

It is designed to be able to work with many different underlying platforms, including embedded targets. This does mean that it cannot use the standard library and platform specific libraries to interact with the system clock and to access the network. That needs to be provided by the user of the library.

On modern Linux kernels, the statime-linux crate provides ready to use implementations of these interfaces. For other platforms the user will need to implement these themselves.

The statime-stm32 crate gives an example of how to use statime on an embedded target.

Statime - PTP in Rust

The statime-linux crate provides a binary for Linux implementing an ordinary or boundary clock. It will need sufficient permissions to change the system clock to use. The easiest way to start it is through sudo:

sudo ./target/debug/statime -c path/to/statime.toml

Structure

The statime library has been built in a way to try and be platform-agnostic. To do that, the network and clock have been abstracted. The statime-linux library provides implementations of these abstractions for linux-based platforms. For other platforms, this needs to be provided by the user. For more details, see the documentation

Rust version

Statime requires a nigthly version of cargo/rust. The easiest way to obtain these is through rustup

Running with elevated privileges

Because of the use of ports 319 and 320 in the PTP protocol, the code here needs to be run as root. It is best to build the code as a non-root user with

cargo +nightly build

and then run it as root with

sudo ./target/debug/statime -i <ETHERNET INTERFACE NAME>

PTPd setup for testing

PTPd can be used as a ptp master clock for testing. Because of the port usage required by the PTP standard, this master clock must be on a different machine than that used to run the code in this repository. On Ubuntu, it can be installed with

apt install ptpd

You probably wont want to run this continuously as a service, so disable it with

service ptpd disable

Then, to start ptpd, as root run

ptpd -V -n -M -i <INTERFACE>

where <INTERFACE> is the network interface you want ptpd to use. Here -n disables clock adjustment by ptpd, and -M ensures that it runs in master mode only.

Roadmap

  • Q2 2024: Power sector profile + experimental NTS4PTP
  • Q3 2024: Stable release Statime (pending funding)
  • Q1-Q4 2024: Adoption work & maintenance work

Support our work

The development of Statime is kindly supported by the NGI Assure Fund of the NLnet Foundation.

Logo NLnet Logo NGI Assure

SIDN Fonds is supporting us with a grant to develop clock devices running Statime and ntpd-rs, in collaboration with SIDN Labs' TimeNL.

In August of 2023, Sovereign Tech Fund invested in Pendulum (Statime and ntpd-rs). Read more on their website.

Logo STF

We continuously seek the involvement of interested parties and funding for future work. See Project Pendulum or reach out to pendulum@tweedegolf.com.

Commit count: 749

cargo fmt