{"id":16164257,"url":"https://github.com/troglobit/sntpd","last_synced_at":"2025-03-18T22:31:29.592Z","repository":{"id":4336880,"uuid":"5472592","full_name":"troglobit/sntpd","owner":"troglobit","description":"sntpd is a fork of Larry Doolittle's ntpclient with added daemon, syslog, and IPv6 support","archived":false,"fork":false,"pushed_at":"2023-09-03T08:33:09.000Z","size":411,"stargazers_count":50,"open_issues_count":0,"forks_count":21,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-08T00:45:30.617Z","etag":null,"topics":["embedded","embedded-systems","ntp","ntp-client","sntp","sntp-server","unix"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/troglobit.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-08-19T17:06:12.000Z","updated_at":"2025-03-02T13:57:29.000Z","dependencies_parsed_at":"2024-06-19T05:17:08.784Z","dependency_job_id":null,"html_url":"https://github.com/troglobit/sntpd","commit_stats":{"total_commits":260,"total_committers":4,"mean_commits":65.0,"dds":"0.011538461538461497","last_synced_commit":"58a0adde9d305beb4a5bdb789580336f3e64652a"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fsntpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fsntpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fsntpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fsntpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/troglobit","download_url":"https://codeload.github.com/troglobit/sntpd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243667453,"owners_count":20328029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded","embedded-systems","ntp","ntp-client","sntp","sntp-server","unix"],"created_at":"2024-10-10T02:45:57.804Z","updated_at":"2025-03-18T22:31:29.345Z","avatar_url":"https://github.com/troglobit.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"sntpd\n=====\n[![License Badge][]][License] [![GitHub Status][]][GitHub] [![Coverity Status][]][Coverity Scan]\n\nTable of Contents\n-----------------\n\n* [Introduction](#introduction)\n* [Usage](#usage)\n* [Troubleshooting](#troubleshooting)\n* [Bugs](#bugs)\n* [Compliance](#compliance)\n* [Building](#building)\n* [Building from GIT](#building-from-git)\n* [Origin \u0026 References](#origin--references)\n\n\nIntroduction\n------------\n\nsntpd is a small SNTP server and client for UNIX systems, implementing\n[RFC 1305][] and [RFC 4330][].  Its functionality is only a small subset\nof [ntpd][], [chrony][], [OpenNTPd][], and [xntpd][].  Since it is much\nsmaller it is also more relevant for embedded systems in need of only a\nbackground process to keep the system time in sync (client mode).\n\nsntpd is a fork of ntpclient by Larry Doolittle.  As such it implements\na compatibility mode when called with the name `ntpclient`.  The name\nhas been changed to indicate the expanded feature set, e.g. a background\ndaemon mode, IPv6, syslog, as well as changes in command line options.\n\nUse the GitHub [issue tracker][] to report bugs.  If you want to\ncontribute fixes or new features, see the file [CONTRIBUTING.md][].\n\n**Note:** sntpd has _limited_ support for acting as an SNTP server.\n\tThe server mode is enabled by default, disable with `-p 0`.\n\n\nUsage\n-----\n\nAll arguments are optional, sntpd defaults to use `pool.ntp.org`.\n\n    Usage:\n      sntpd [options] [SERVER]\n\n      -d       Dry run, no time correction, useful for debugging\n      -h       Show summary of command line options and exit\n      -i SEC   Check time every interval seconds.  Default: 600\n      -l LEVEL Set log level: none, err, warn, notice (default), info, debug\n      -n       Don't fork.  Prevents sntpd from daemonizing by default\n               Use '-s' with this to use syslog as well, for Finit + systemd\n      -p PORT  SNTP server mode port, default: 123, use 0 to disable\n      -q USEC  Minimum packet delay for transaction, default: 800 usec\n      -s       Use syslog instead of stdout, default unless -n\n      -t       Trust network and server, disable RFC4330 validation\n      -v       Show program version\n\n      SERVER   Optional NTP server to sync with, default: pool.ntp.org\n\n\nCompatibility\n-------------\n\nThe sntpd project comes with a compatiblity mode triggered when called\nas `ntpclient`.  This mode supports the original command line options.\n\nMortal users can use the `ntpclient` tool for monitoring, but not clock\nsetting (with the `-s` or `-l` switches).  The `-l` switch is designed\nto be robust in any network environment, but has seen the most extensive\ntesting in a low latency (less than 2 ms) Ethernet environment.  Users\nin other environments should study sntpd's behavior, and be prepared to\nadjust internal tuning parameters.  A long description of how and why to\nuse sntpd and ntpclient is in the [HowTo.md][] file.  sntpd always sends\npackets to the server's UDP port 123.\n\nOne commonly needed tuning parameter for lock mode is `min_delay`, the\nshortest possible round-trip transaction time.  This can be set with the\ncommand line `-q` switch.  The historical default of 800 microseconds\nwas good for local Ethernet hardware a few years ago.  If it is set too\nhigh, you will get a lot of \"inconsistent\" lines in the log file when\ntime locking (`-l` switch).  The only true future-proof value is 0, but\nthat will cause the local time to wander more than it should.  Setting\nit to 200 is recommended on an end client.\n\nThe `test.dat` file that is part of the source distribution has 200\nlines of sample output.  Its first few lines, with the output column\nheaders that are shown when the `-d` option is chosen, are:\n\n      day    second   elapsed    stall      skew  dispersion  freq\n    36765 00180.386    1398.0     40.3  953773.9       793.5  -1240000\n    36765 00780.382    1358.0     41.3  954329.0       915.5  -1240000\n    36765 01380.381    1439.0     56.0  954871.3       915.5  -1240000\n\n* day, second: time of measurement, UTC, relative to NTP epoch (Jan 1, 1900)\n* elapsed:     total time from query to response (microseconds)\n* stall:       time the server reports that it sat on the request (microseconds)\n* skew:        difference between local time and server time (microseconds)\n* dispersion:  reported by server, see [RFC 1305][] (microseconds)\n* freq:        local clock frequency adjustment (Linux only, ppm*65536)\n\nntclient performs a series of sanity checks on UDP packets received, as\nrecommended by [RFC 4330][].  If it fails one of these tests, the line\ndescribed above is replaced by `36765 01380.381 rejected packet` or, if\n`--enable-debug` was selected at `configure`, one of:\n\n    36765 01380.381  rejected packet: LI==3\n    36765 01380.381  rejected packet: VN\u003c3\n    36765 01380.381  rejected packet: MODE!=3\n    36765 01380.381  rejected packet: ORG!=sent\n    36765 01380.381  rejected packet: XMT==0\n    36765 01380.381  rejected packet: abs(DELAY)\u003e65536\n    36765 01380.381  rejected packet: abs(DISP)\u003e65536\n    36765 01380.381  rejected packet: STRATUM==0\n\nTo see the actual values of the rejected packet, start the ntpclient\ntool or sntpd with the `-d` option; this will give a human-readable\nprintout of every packet received, including the rejected ones.  To skip\nthese checks, use the `-t` switch.\n\nThe file `test.dat` is suitable for piping into \u003ckbd\u003entpclient -r\u003c/kbd\u003e.\nThere are more than 200000 samples (lines) archived for study.  They are\ngenerally spaced 10 minutes apart, representing over three years of data\nlogging (from a variety of machines, and not continuous, unfortunately).\nIf you are interested, [contact Larry][].\n\nAlso included is a version of the `adjtimex(1)` tool.  See its man page\nand the [HowTo.md][] file for more information.\n\nAnother tool is `envelope`, which is a perl script that was used for the\nlock studies.  It's kind of a hack and not worth documenting here.\n\n\nTroubleshooting\n---------------\n\nSome really old Linux systems (e.g., Red Hat EL-3.0 and Ubuntu 4.10)\nhave a totally broken POSIX `clock_settime()` implementation.  If you\nget the following with \u003ckbd\u003esntpd -s\u003c/kbd\u003e:\n\n    clock_settime: Invalid argument\n\nthen `configure --enable-obsolete`.  Linux systems that are even older\nwill not even compile without that switch set.\n\n\nBugs\n----\n\n* Doesn't understand the LI (Leap second Indicator) field of an NTP packet\n* Doesn't interact with `adjtimex(2)` status value\n* Cannot query multiple servers\n* Requires Linux `select()` semantics, where timeout value is modified\n\n\nCompliance\n----------\n\nAdherence to [RFC 4330][] chapter 10, Best practices:\n\n1. Enforced, unless someone tinkers with the source code\n2. No backoff, but no retry either; this isn't TCP\n3. Not in scope for the upstream source\n4. Defaults to pool.ntp.org, but is configurable\n5. Not in scope for the upstream source\n6. Supported\n7. Supported, connection to server reopened once a day\n8. Not supported (scary opportunity to DOS the _client_)\n\n\nBuilding\n--------\n\nPlease use released, and versioned, tarballs of this project.  All\nreleases are available from here:\n\n☞ https://github.com/troglobit/sntpd/releases\n\nsntpd uses the [GNU configure \u0026 build system][buildsystem]:\n\n```sh\n    ./configure\n    make\n```\n\nThe GNU build system use `/usr/local` as the default install prefix.  In\nmany cases this is useful, but many users expect `/usr` or `/opt`.  To\ninstall into `/usr/sbin/sntpd` and `/usr/bin/adjtimex`:\n\n```sh\n    ./configure --prefix=/usr\n    make\n    sudo make install-strip\n```\n\nThe last command installs, there is also a possiblity to uninstall all\nfiles using:\n\n```sh\n    sudo make uninstall\n```\n\nFor changing the system clock frequency, only the Linux `adjtimex(2)`\ninterface is implemented at this time.  Non-Linux systems can only use\nthe ntpclient tool to measure time differences and set the system clock,\nby way of the POSIX 1003.1-2001 standard, the routines `clock_gettime()`\nand `clock_settime()`.  Also, see section [Bugs](#bugs), below.\n\nThere are a few compile-time configurations possible.  E.g., for older\nLinux kernels, before the tickless erea (pre 3.0), you want to:\n\n```sh\n    ./configure --disable-siocgstamp\n```\n\nHowever, first try without changing the default.  That gives you a full-\nfeatured `sntpd` and `ntpclient` tool that use a modern POSIX time API\nand works reasonably well with any Linux kernel.\n\nSolaris and other UNIX users may need to adjust the `CFLAGS` slightly.\nFor other options, see \u003ckbd\u003e./configure --help\u003c/kbd\u003e\n\n\nBuilding from GIT\n-----------------\n\nIf you want to contribute, or try out the latest unreleased features,\nhere is a few things to know about [GNU build system][buildsystem]:\n\n- `configure.ac` and a per-directory `Makefile.am` are key files\n- `configure` and `Makefile.in` are generated from `autogen.sh`,\n  they are not stored in GIT but automatically generated for the\n  release tarballs\n- `Makefile` is generated by `configure` script\n\nTo build from GIT you first need to clone the repository and run the\n`autogen.sh` script.  This requires `automake` and `autoconf` to be\ninstalled on your system.\n\n```sh\n    git clone https://github.com/troglobit/sntpd.git\n    cd sntpd/\n    ./autogen.sh\n    ./configure \u0026\u0026 make\n```\n\n**Remember:** GIT sources are a moving target and not recommended for\n              production systems, unless you know what you are doing!\n\n\nOrigin \u0026 References\n-------------------\n\n[Larry Doolittle][] created ntpclient and made it freely available under\nthe terms of the GNU General Public [License][], version 2.  He remains\nthe official upstream for `ntpclient`.\n\nThis sntpd fork at GitHub is maintained by [Joachim Wiberg][] and adds\nfeatures like syslog, background daemon, IPv6, and systemd support.\n\n[ntpd]:            http://www.ntp.org\n[xntpd]:           http://www.eecis.udel.edu/~mills/ntp/\n[chrony]:          http://chrony.tuxfamily.org/\n[OpenNTPd]:        http://www.openntpd.org\n[RFC 1305]:        http://tools.ietf.org/html/rfc1305\n[RFC 4330]:        http://tools.ietf.org/html/rfc4330\n[Larry Doolittle]: http://doolittle.icarus.com/ntpclient/\n[contact Larry]:   larry@doolittle.boa.org\n[buildsystem]:     https://airs.com/ian/configure/\n[License]:         http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\n[License Badge]:   https://img.shields.io/badge/License-GPL%20v2-blue.svg\n[GitHub]:          https://github.com/troglobit/sntpd/actions/workflows/build.yml/\n[GitHub Status]:   https://github.com/troglobit/sntpd/actions/workflows/build.yml/badge.svg\n[CONTRIBUTING.md]: docs/CONTRIBUTING.md\n[issue tracker]:   https://github.com/troglobit/sntpd/issues\n[HowTo.md]:        docs/HowTo.md\n[Joachim Wiberg]:  http://troglobit.com\n[Coverity Scan]:   https://scan.coverity.com/projects/20498\n[Coverity Status]: https://scan.coverity.com/projects/20498/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroglobit%2Fsntpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftroglobit%2Fsntpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroglobit%2Fsntpd/lists"}