Skip to content

Latest commit

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

NTP Client

GoDoc

A simple Network Time Protocol (NTP) Client

This NTP Client is specially designd for computers without a hardware clock, such as the Raspberry Pi, and for Laptops.

Installation

  • Download the latest release for your OS from here

Mapping Raspberry Pi Models to Architectures

Raspberry Pi ModelArchitecture
Raspberry Pi 1 (A, B, A+, B+), Zero, Zero Warm6
Raspberry Pi 2 (v1.1)arm7
Raspberry Pi 2 (v1.2), 3, 3+, CM3arm7
Raspberry Pi 4, 400, CM4 (32-bit OS)arm7
Raspberry Pi 4, 400, CM4 (64-bit OS)arm64
Raspberry Pi 5 (64-bit OS)arm64
  • Rename the executable to ntpc

Usage

Run manually, at system start as a service, and/or as a cron job

Usage of ntpc:
-d	Show detailed debug results
-e string
NTP host (default "pool.ntp.org")
-s	Update system date & time
Example:
# ntpc -s -e en.pool.ntp.org
OR
# ntpc -s -e 10.10.10.1

NTP packet format

This info is for coders!

// NTP packet format (v3 with optional v4 fields removed)
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |LI | VN |Mode | Stratum | Poll | Precision |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Root Delay |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Root Dispersion |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Reference ID |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// + Reference Timestamp (64) +
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// + Origin Timestamp (64) +
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// + Receive Timestamp (64) +
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// + Transmit Timestamp (64) +
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

This is a fork of Vladimir Vivien's go-ntp-client. (Thank you Vladimir)
The original code is explained by Vladimir Vivien in this writeup titled Let's make an NTP client in Go

About

A simple Network Time Protocol (NTP) Client

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages