Git Product home page Git Product logo

clock-bound's Introduction

ClockBound

Summary:

ClockBound allows you to generate and compare bounded timestamps that include accumulated error as reported from the local chronyd process. On every request, ClockBound uses two pieces of information: the current time and the associated absolute error range, which is also known as the clock error bound. This means that the “true” time of a ClockBound timestamp is within a set range.

Using ClockBound with a consistent, trusted time service will allow you to compare timestamps to determine order and consistency for events and transactions, independent from the instances’ respective geographic locations. We recommend you use the Amazon Time Sync Service, a highly accurate and reliable time reference that is natively accessible from Amazon EC2 instances, to get the most out of ClockBound on your AWS infrastructure. For more information on the Amazon Time Sync Service, see the EC2 User Guide.

Calculations:

Clock accuracy is a measure of clock error, typically defined as the offset to UTC. This clock error is the difference between the observed time on the computer and reference time (also known as true time). In an NTP architecture, this error can be bounded using three measurements that are defined by the protocol:

  • Local offset (the system time): The residual adjustment to be applied to the operating system clock.
  • Root dispersion: The accumulation of clock drift at each NTP server on the path to the reference clock.
  • Root delay: The accumulation of network delays on the path to the reference clock.

The clock error bound is calculated using the formula below:

Clock Error Bound = |Local Offset| + Root Dispersion + (Root Delay / 2)

Clock Error Bound Image
Figure 1: The clock error bound provides a bound on the worst case offset of a clock with regard to “true time”.

The combination of local offset, root dispersion, and root delay provides us with a clock error bound. For a given reading of the clock C(t) at true time t, this bound makes sure that true time exists within the clock error bound. The clock error bound is used as a proxy for clock accuracy and measures the worst case scenario (see Figure 1). Therefore, clock error bound is the main metric used to determine the accuracy of an NTP service.

ClockBound uses this clock error bound to return a bounded range of timestamps. This is calculated by adding and subtracting the clock error bound from the timestamp provided by a system's clock. It also contains functionality to check if a given timestamp is in the past or future. This allows users to have consistency when dealing with time sensitive transactions.

Usage

ClockBound is composed of two parts:
ClockBoundD - A daemon to provide clients with an error bounded timestamp interval.
ClockBoundC - A client library to communicate with ClockBoundD.

To use ClockBound you first need to install and set up ClockBoundD. See the ClockBoundD README for more info.

Once ClockBoundD is set up you will need a client to communicate with it. The ClockBoundC client library is the recommended method of usage from a rust codebase.

Custom Client

The ClockBound Protocol is provided if there is interest in creating a custom client.

Clients can be created in any programming language that can communicate with Unix Datagram Sockets:

  1. Bind the client to its own Unix Datagram Socket.
  2. Connect the client's Unix Datagram Socket to ClockBoundD's own socket.
  3. Send and receive messages as defined in the ClockBound Protocol.

See the implementation in ClockBoundC as an example.

Security

See CONTRIBUTING for more information.

License

ClockBoundC is licensed under the Apache 2.0 LICENSE.

ClockBoundD is licensed under the GPL v2 LICENSE

clock-bound's People

Contributors

amazon-auto avatar basilnsindhu avatar daxinc avatar dependabot[bot] avatar dfoxfranke avatar jacoblwisniewski avatar siddontang avatar tphan25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clock-bound's Issues

Run clock-bound-d on Docker

Hello.
I would like to run clock-bound-d on Docker, but there are probably two barriers.

  1. clock-bound-d currently supports only syslog logging.

I wrote the following Dockerfile, but this gives me an error.

FROM rust:1.59.0-bullseye
RUN cargo install clock-bound-d --version 0.1.1
CMD ["clockboundd"]
thread 'main' panicked at 'could not connect to syslog: Error(Initialization, State { next_error: Some(Error(Io(Os { code: 2, kind: NotFound, message: "No such file or directory" }), State { next_error: None, backtrace: InternalBacktrace })), backtrace: InternalBacktrace })', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/clock-bound-d-0.1.1/src/main.rs:65:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  1. clock-bound-d supports only 323 port.

When running clock-bound-d on Docker, I'm thinking of running chrony as a side car.
For example, I'm thinking of using https://github.com/cturra/docker-ntp , which works with port 123.
I think a workaround is possible, but it would be useful to be able to use a port other than 323.

Are there any plans to make these two points configurable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.