[ntp:questions] Re: Need *very* small NTP-Server for Linux

Terje Mathisen terje.mathisen at hda.hydro.com
Tue Sep 20 07:55:23 UTC 2005


Danny Mayer wrote:

> Johnson Luqaz wrote:
> 
>> You may wish to download NetTime from 
>> http://sourceforge.net/projects/nettime.
>>
> 
> I doubt it. He's talking about Unix and anyway that's a SNTP client and
> not a server and he needs NTP. It's nettime is not even RFC 2030 compliant.

Writing a really tiny (S)NTP server should be a fun exercise, as long as
you can make the following (extremely) simplifying assumptions:

a) The local system clock is always correct

b) All time stamps can be assumed to be correct.

c) No need to support either authentication or any form of ntpq/ntpdc
queries.

Under these assumptions you can reduce the code to something like this:

open socket 123

while (1) {
  retrieve ntp request packet
  T = query system time
  set T2, T3 and reference time = T
  update leap pending and any other required flags
  (In particular, set the stratum to a high value, like 8-10!)
  return the ntp packet to the requesting client.
}

I.e. it should be possible to reduce the code to less than 1 KB as long
as the socket library code is already resident.

Terje
-- 
- <Terje.Mathisen at hda.hydro.com>
"almost all programming can be viewed as an exercise in caching"




More information about the questions mailing list