forked fromvladimirvivien/go-ntp-client
- Notifications
You must be signed in to change notification settings - Fork0
A Network Time Protocol client in Go
License
NotificationsYou must be signed in to change notification settings
gotamer/ntpc
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
============
This is an implementation of a simple NTP client in Go. It uses theencoding/binary
package to encode and decode NTP packets sent to and received from a remote NTP server over UDP.
It also does:
- log via linux syslog
- local date update
I use it to periodically update my Linux laptop system time.On my system it runs once an hour via a cron job.
// 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 titledLet's make an NTP client in Go
About
A Network Time Protocol client in Go
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published
Languages
- Go100.0%