# Statime [![codecov](https://codecov.io/gh/pendulum-project/statime/branch/main/graph/badge.svg?token=QCO6NKS64J)](https://codecov.io/gh/pendulum-project/statime) [![book](https://shields.io/badge/manual-main-blue)](https://docs.statime.pendulum-project.org/) [![book](https://shields.io/badge/docs.rs-statime-green)](https://docs.statime.pendulum-project.org/api/statime/) 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.
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](https://docs.statime.pendulum-project.org/api/statime/) ## Rust version Statime requires a nigthly version of cargo/rust. The easiest way to obtain these is through [rustup](https://rustup.rs) ## 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