Statime is a work in progress Rust implementation of PTP version 2.1 (IEEE 1588-2019). It is currently highly in flux and not yet usable.
The current state of the project is such that the main binary, when compiled, measures and outputs the time difference to any ptp master clock happening to be sending in the network it listens to.
The library has been built in a way to try and be platform-agnostic. To do that, the network and clock have been abstracted.
Many things are event-based where the user needs to call a function on the ptp instance object to let it handle e.g. an incoming network packet.
For compiling this software we advise using the latest version of cargo/rustc as available through rustup. At time of writing this is 1.58.1
.
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/linux -i <ETHERNET INTERFACE NAME>
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 netwerk interface you want ptpd to use. Here -n
disables clock adjustment by ptpd, and -M
ensures that it runs in master mode only.
The development of Statime is kindly supported by the NLnet Foundation.
SIDN Fonds is supporting us with a grant to develop clock devices running Statime and ntpd-rs, in collaboration with SIDN Labs' TimeNL.
We seek involvement and/or sponsoring of interested parties, see the announcement here.