This is tougher than I thought?

  • Follow


Hi everybody. My name is Axonn Echysttas and I'm a newbie to NTP. I'm
currently working at developing a replacement for the Windows OS
Systray clock. This program is free and I've been working on it for
the past year a lot. It will enter Beta 2 no later than 25 January this
year and Beta 3 (which will be public) probably during March this year.
However, for the time being, even though I built a lot of functionality
and it looks quite nice (very flexible and customizable), I didn't
yet start on NTP time synchronization. I got the RFC about NTP and it
scared me a little to see all those math formulae in it. On
http://tf.nist.gov/service/its.htm I read that "The NIST servers
listen for a NTP request on port 123, and respond by sending a udp/ip
data packet in the NTP format. The data packet includes a 64-bit
timestamp containing the time in UTC seconds since January 1, 1900 with
a resolution of 200 ps."

My question is this: could you help me for a good cause? I would like
to know how does the NTP format look like and how to take an accurate
time out of it. I suppose I can always start reading and searching by
myself, of course. But this thing doesn't look very easy at the first
glance. Also, the amount of documentation on NTP seems huge. I don't
know if the client-side NTP involves a lot of math but if it does,
I'm not that good at math yet. I didn't yet graduate University and
my school is on freeze for the last two years since I need to work to
sustain my family. However, this project of mine I did in my free time
and for the pleasure of doing something good and helping others, I will
never request money for it.

So how can I synchronize with a NTP server or more NTP servers? Is it
so hard as I imagine after going a little through the FAQs? I would
hope that the hard part is for servers, not for clients. I await your
answers with great anticipation.

Thank you very much for your time,
Axonn Echysttas,
ASD Clock creator.

0
Reply axonnus (1) 1/21/2006 10:28:18 AM

Axonn wrote:
[]
> So how can I synchronize with a NTP server or more NTP servers? Is it
> so hard as I imagine after going a little through the FAQs? I would
> hope that the hard part is for servers, not for clients. I await your
> answers with great anticipation.
>
> Thank you very much for your time,
> Axonn Echysttas,
> ASD Clock creator.

Axonn,

I have two answers for you:

1 - NTP is already available for Windows.  You can download client 
software here:

  http://www.meinberg.de/english/sw/ntp.htm

Then use the normal Windows functions to read the system time, and let NTP 
worry about setting the system time.  By the way, this client also 
incorporates the server.  My understanding is that the client is the 
harder part, at least the precision timekeeping part, and deciding which 
server to trust.

2 - to get a simple time value, use the SNTP protocol.  See:

  http://www.faqs.org/rfcs/rfc2030.html

Basically, format a packet as shown in section 4, send it to the chosen 
NTP server over UDP on port 123, and parse the packet you get back.  For 
greatest simplicity, use the "Transmit" timestamp field, but you can do 
better.

By far the best way is to let the NTP software (1) control the computer's 
clock.

Cheers,
David 


0
Reply David 1/21/2006 10:54:29 AM


Thank you David for your assistance. I wish to include NTP
functionality in my program due to the lack of such features on most
Windows OS versions and hard-to-find (for the average user) features on
newer versions. I guess I'll go for using the SNTP. Anyway, it seems
like I'm gonna  have to go though some serious development work with
this thing.

Do you (or anybody here for that matter) happen to know of any FREE
(preferably open source) DLL that could provide one with a time from a
NTP server?

0
Reply Axonn 1/21/2006 12:11:54 PM

Axonn wrote:
> Thank you David for your assistance. I wish to include NTP
> functionality in my program due to the lack of such features on most
> Windows OS versions and hard-to-find (for the average user) features on
> newer versions. I guess I'll go for using the SNTP. Anyway, it seems
> like I'm gonna  have to go though some serious development work with
> this thing.
> 
> Do you (or anybody here for that matter) happen to know of any FREE
> (preferably open source) DLL that could provide one with a time from a
> NTP server?
> 
I Don't Do Windows (tm) but, if I understand you are writing a user 
control and display interface to the system clock.  Install the existing 
NTP client as part of your install process, and let it handle ntp 
correctly, which is much more complictaed that just getting the time 
from some server.  Then you can worry about the user interface part.
my $0.015 (after taxes),
Tim Keck
0
Reply Tim 1/21/2006 1:25:12 PM

Axonn wrote:

>Hi everybody. My name is Axonn Echysttas and I'm a newbie to NTP. I'm
>currently working at developing a replacement for the Windows OS
>Systray clock. This program is free and I've been working on it for
>the past year a lot. It will enter Beta 2 no later than 25 January this
>year and Beta 3 (which will be public) probably during March this year.
>However, for the time being, even though I built a lot of functionality
>and it looks quite nice (very flexible and customizable), I didn't
>yet start on NTP time synchronization. I got the RFC about NTP and it
>scared me a little to see all those math formulae in it. On
>http://tf.nist.gov/service/its.htm I read that "The NIST servers
>listen for a NTP request on port 123, and respond by sending a udp/ip
>data packet in the NTP format. The data packet includes a 64-bit
>timestamp containing the time in UTC seconds since January 1, 1900 with
>a resolution of 200 ps."
>
>My question is this: could you help me for a good cause? I would like
>to know how does the NTP format look like and how to take an accurate
>time out of it. I suppose I can always start reading and searching by
>myself, of course. But this thing doesn't look very easy at the first
>glance. Also, the amount of documentation on NTP seems huge. I don't
>know if the client-side NTP involves a lot of math but if it does,
>I'm not that good at math yet. I didn't yet graduate University and
>my school is on freeze for the last two years since I need to work to
>sustain my family. However, this project of mine I did in my free time
>and for the pleasure of doing something good and helping others, I will
>never request money for it.
>
>So how can I synchronize with a NTP server or more NTP servers? Is it
>so hard as I imagine after going a little through the FAQs? I would
>hope that the hard part is for servers, not for clients. I await your
>answers with great anticipation.
>
>Thank you very much for your time,
>Axonn Echysttas,
>ASD Clock creator.
>
>  
>
I think you ask too much!   The packet format is documented in RFC 1305 
on pages 50 et. seq.   The formula used to compensate for transmission 
delay will be found on page 100.  That should be enough to get you a 
time correct within, say, fifty milliseconds by querying a single 
server, interpreting the reply packet and stuffing the resulting time 
into your clock.  

There is a freely available reference implementation of ntpd and 
associated utilities.  There is even a pre-built version available for 
Windoze.  If you want real accuracy, you will need to implement the 
entire package or use the reference implementation.   With a very good 
server and low network latencies, ntpd is capable of synchronizing a 
client within a few microseconds
0
Reply Richard 1/21/2006 2:02:26 PM

Tim, Richard, thank you for your answers ::- ). I would appreciate some
links of stuff to read and sources to use in this NTP thingy? Could you
please throw some my way? ::- ). I got RFC 1305, but not a single line
of code about NTP.

Tim: I'm pretty fond of Linux myself and I intend to build a game there
in the future (provided nothing unexpected happens in my life) but for
the time being I really want to finish this Win project. It's a long
way already and I wish to give something back to the Internet Community
which helped me so much in my career as a computer programmer. A
freeware (would-be open source) project would be the perfect way to do
it, at least in my view. Anyway, thank you all for your time and
interest.

0
Reply Axonn 1/21/2006 5:44:47 PM

Axonn wrote:

>Tim, Richard, thank you for your answers ::- ). I would appreciate some
>links of stuff to read and sources to use in this NTP thingy? Could you
>please throw some my way? ::- ). I got RFC 1305, but not a single line
>of code about NTP.
>
>  
>
Here's the basic link for NTP <http://www.ntp.org/>

There you will find links to source code, documentation, etc, etc.

Here's a link to a site by a well known "Time-Nut" 
<http://www.leapsecond.com/>
You'll enjoy his send-up of the "atomic wristwatch".

Read the archives of  comp.protocols.time.ntp <http://groups.google.com/>
for more stuff.
0
Reply Richard 1/21/2006 8:02:26 PM

Thanks Richard. Well, it's clear... I'm gonna have to postpone adding
NTP functionality for my program for now... at least for the following
two months. This is too much to get myself into, especially considering
that I got a pretty big amount of development to finish at the alarms
and address book sections. And for whoever is interested and is a
Windows user, I will launch a Beta 2 this Wednesday (compatible with
Windows NT 5.0 or greater) and you can e-mail me to put you on the
list. The program is pretty stable and is very flexible and allows tons
of customization.

Anyway, thank you all for your help, I'll be back with questions
probably when I gather enough courage to get myself into this NTP
thingy : ).

0
Reply Axonn 1/22/2006 9:40:43 AM

Axonn wrote:
> Thanks Richard. Well, it's clear... I'm gonna have to postpone adding
> NTP functionality for my program for now... at least for the following
> two months. This is too much to get myself into, especially
> considering that I got a pretty big amount of development to finish
> at the alarms and address book sections. And for whoever is
> interested and is a Windows user, I will launch a Beta 2 this
> Wednesday (compatible with Windows NT 5.0 or greater) and you can
> e-mail me to put you on the list. The program is pretty stable and is
> very flexible and allows tons of customization.
>
> Anyway, thank you all for your help, I'll be back with questions
> probably when I gather enough courage to get myself into this NTP
> thingy : ).

Axonn,

It's not that difficult!  All you need to do is to complete a single 
packet, send it to a server, and parse the value of one 64-bit returned 
number.  Does the programming language you are using not offer a UDP 
socket / datagram you can use?  Which fields of the packet are you 
uncertain about?

Here's the 64-bit time type:

type
  // NTP uses a 32+32 bit field with whole and fractional seconds
  TTimestamp = record
    seconds:  Longint;     // in network order
    fraction: Longint;     // in network order
  end;

and the packet: (part of a bigger variant record in my program)

      1: (flags: byte;
          stratum: byte;
          poll: byte;
          precision: shortint;
          root_delay: Longint;
          root_dispersion: Longint;
          reference_identifier: Longint;
          reference_timestamp: TTimestamp;
          originate_timestamp: TTimestamp;
          receive_timestamp: TTimestamp;
          transmit_timestamp: TTimestamp;
         );

In my own code, I only fill in the Flags and the Originate Timestamp 
fields!  Simply reading the Transmit Timestamp would give you a 
"reasonable" time value.

Why won't your program also work on Windows NT 4?

Cheers,
David 


0
Reply David 1/22/2006 10:00:19 AM

Hi again David, thanks for your time.

I work in various programming languages... this particular program I'm
working on is largely in C++ but has a Visual Basic side too and some
other flavors as well. As far as I can "smell" your code looks like my
first programming language, Pascal, that is now Delphi. I am a bit
ashamed to confess that I don't know that much about packets. Even
though about 3 years ago I programmed an IRC bot in Delphi, that was
using built in Delphi socket support and I am not so familiar with the
packet term. I know what it is, how it works but this ain't enough. As
far as I see in your code, it's pretty clear that your packet has a
certain size... but... packets need an IP and other info which gets
filled by whom? Sorry, really, I know that I shouldn't bother people
here with this, I am too much of a newbie in some areas. I've been into
programming only 8 years now out of which only the past 3 were more
intensive.

As for my program... well... it works on NT 4 but I haven't tested it
yet. It uses some features like layered windows which are only
available on NT 5 and greater. So before saying that it works on NT 4
and 9x I gotta first install it there and make sure all code that
refers to NT 5 features is separated properly and doesn't crash. When
complete it will work on any Windows from 95 (included) above. Right
now I'm working to fix a few gremlins that have been pesting me since
yesterday at the functionality which replaces the systray clock with my
clock. This weekend sure is full of work... which I'm gonna go back to
right now...

0
Reply Axonn 1/22/2006 11:12:14 AM

Axonn wrote:
> Hi again David, thanks for your time.
>
> I work in various programming languages... this particular program I'm
> working on is largely in C++ but has a Visual Basic side too and some
> other flavors as well. As far as I can "smell" your code looks like my
> first programming language, Pascal, that is now Delphi. I am a bit
> ashamed to confess that I don't know that much about packets. Even
> though about 3 years ago I programmed an IRC bot in Delphi, that was
> using built in Delphi socket support and I am not so familiar with the
> packet term. I know what it is, how it works but this ain't enough. As
> far as I see in your code, it's pretty clear that your packet has a
> certain size... but... packets need an IP and other info which gets
> filled by whom? Sorry, really, I know that I shouldn't bother people
> here with this, I am too much of a newbie in some areas. I've been
> into programming only 8 years now out of which only the past 3 were
> more intensive.
>
> As for my program... well... it works on NT 4 but I haven't tested it
> yet. It uses some features like layered windows which are only
> available on NT 5 and greater. So before saying that it works on NT 4
> and 9x I gotta first install it there and make sure all code that
> refers to NT 5 features is separated properly and doesn't crash. When
> complete it will work on any Windows from 95 (included) above. Right
> now I'm working to fix a few gremlins that have been pesting me since
> yesterday at the functionality which replaces the systray clock with
> my clock. This weekend sure is full of work... which I'm gonna go
> back to right now...

Axonn,

Thanks for your comments on the software.  I am interested to know what 
features peope now use which require Windows 2000 or later, and I can see 
what you need.  I now rate my own software for Windows 2000 and XP, as 
some features won't work on FAT32 file systems (limit of number of files 
per folder), and Win 9X is not stable enought for reliable 24 x 7 
operation.

Coming back to enquiring of an NTP server, my own software uses the 
TBasicClientSocket from dWinsock which handles all the IP stuff.  You just 
tell it port 123, UDP, send the packet , and handle the OnRead event for 
the return packet.  Very simple, really.  Yes, it's Borland's Delphi. 
Perhaps my use of the term packet is confusing - I simply mean a chunk of 
data which you feed to the socket's "Send" mthod (or whatever it's 
called).

Entering "visual basic ntp component" into Google produces quite a lot of 
hits!

Cheers,
David 


0
Reply David 1/22/2006 11:49:44 AM

NT 5 brings a lot of new stuff, and a few security glitches with that
stuff : ). But 2000 is pretty solid by now. Anyway, this escapes the
topic so I'd rather mail you about it.

Unfortunately lots of those Google search hits are .Net and I'm not
interested in .Net since it's very low in portability and few people
would install .Net on low-end machines just to have a few programs they
could live without. I avoid .Net whenever I can. As for the other hits,
there are some components but they cost and I don't think there's
anything helpful there but then again I can't stay too much searching
for that. I guess in a desparate case I can even buy a component, since
I already invested 170$ (and that's pretty much where I come from) in
the website of this program even if the program itself will always be
free.

I guess I can then use sockets from VC++ or even Visual Basic to send
the data. I got a Send method there but I need to know what to dump in
it : ). A packet isn't a string and isn't a number either. It's that
structure you wrote above... I can probably send that... *scatches
head*. I think it's the first thing I'll try once I finish this Beta 2
version which presses me immensely right now since I self-imposed a
deadline of 25 January to myself.

0
Reply Axonn 1/22/2006 12:15:02 PM

Axonn wrote:
> I guess I can then use sockets from VC++ or even Visual Basic to send
> the data. I got a Send method there but I need to know what to dump in
> it : ). A packet isn't a string and isn't a number either. It's that
> structure you wrote above... I can probably send that... *scatches
> head*. I think it's the first thing I'll try once I finish this Beta 2
> version which presses me immensely right now since I self-imposed a
> deadline of 25 January to myself.

Axonn,

Yes, the "packet" is simply the packed data structure I referred to above. 
You send the structure (one Send or Write command) and should get the same 
structure back.  As it's UDP, there's no need to set up the connection or 
anything complicated like that.  Fill in the server IP or FQDN, set the 
protocol to UDP, the port to 123.  In the data structure, fill it with 
zeros, fill in the Flags field and the Originate Time (the first 32 bits 
are Unix seconds, IIRC).  Send the packet (you probably need the start 
address and a length), wait for a reply with timeout (your socket 
component should do all that), and read the time from the packet you get 
back.

A few lines of code, all being well.

In principle, you should be able to take almost any example which sends 
and recieves a UDP packet, and just modify the port to 123 and the data 
structure you use. COme back when you're ready to chat more.

By the way, one article describes using the DAYTIME protocol (port 13) 
instead:

http://www.skillreactor.org/cgi-bin/index.pl?inettime

and this program claims to include NTP source for Visual Basic 6:

  http://www.karenware.com/newsletters/2004/2004-04-27.asp

Good luck!

Cheers,
David 


0
Reply David 1/22/2006 1:42:59 PM

Axonn wrote:
> Hi everybody. My name is Axonn Echysttas and I'm a newbie to NTP. I'm
> currently working at developing a replacement for the Windows OS
> Systray clock. This program is free and I've been working on it for
> the past year a lot. It will enter Beta 2 no later than 25 January this
> year and Beta 3 (which will be public) probably during March this year.
> However, for the time being, even though I built a lot of functionality
> and it looks quite nice (very flexible and customizable), I didn't
> yet start on NTP time synchronization. I got the RFC about NTP and it
> scared me a little to see all those math formulae in it. On
> http://tf.nist.gov/service/its.htm I read that "The NIST servers
> listen for a NTP request on port 123, and respond by sending a udp/ip
> data packet in the NTP format. The data packet includes a 64-bit
> timestamp containing the time in UTC seconds since January 1, 1900 with
> a resolution of 200 ps."
> 
> My question is this: could you help me for a good cause? I would like
> to know how does the NTP format look like and how to take an accurate
> time out of it. I suppose I can always start reading and searching by
> myself, of course. But this thing doesn't look very easy at the first
> glance. Also, the amount of documentation on NTP seems huge. I don't
> know if the client-side NTP involves a lot of math but if it does,
> I'm not that good at math yet. I didn't yet graduate University and
> my school is on freeze for the last two years since I need to work to
> sustain my family. However, this project of mine I did in my free time
> and for the pleasure of doing something good and helping others, I will
> never request money for it.
> 
> So how can I synchronize with a NTP server or more NTP servers? Is it
> so hard as I imagine after going a little through the FAQs? I would
> hope that the hard part is for servers, not for clients. I await your
> answers with great anticipation.
> 
> Thank you very much for your time,
> Axonn Echysttas,
> ASD Clock creator.
> 

I'm not sure what it is that you are trying to accomplish, but if you
install the Windows version of NTP, the local clock will be as accurate
as it can be and you need to do nothing else. Calls to GetLocalTime() at
that point will get you the time accurate to the millisecond if you want
to display in local time. I don't think you really need to duplicate the
functionality of NTP that's already available on Windows.

Danny
_______________________________________________
questions mailing list
questions@lists.ntp.isc.org
https://lists.ntp.isc.org/mailman/listinfo/questions

0
Reply mayer 1/22/2006 9:23:47 PM

Axonn wrote:
> Thank you David for your assistance. I wish to include NTP
> functionality in my program due to the lack of such features on most
> Windows OS versions and hard-to-find (for the average user) features on
> newer versions. I guess I'll go for using the SNTP. Anyway, it seems
> like I'm gonna  have to go though some serious development work with
> this thing.

You are talking of years of development. Is it worth it to reproduce
what's already available? And don't forget this is a moving target as we
add new features.

> 
> Do you (or anybody here for that matter) happen to know of any FREE
> (preferably open source) DLL that could provide one with a time from a
> NTP server?
> 

NTP is already open-source. There currently are no DLL's built. You are
free to copy any and all parts of the source. Just read and follow the
copyright statement.

Danny
_______________________________________________
questions mailing list
questions@lists.ntp.isc.org
https://lists.ntp.isc.org/mailman/listinfo/questions

0
Reply mayer 1/22/2006 9:28:22 PM

"Axonn" <axonnus@gmail.com> wrote in message
news:1137839298.170001.151320@g47g2000cwa.googlegroups.com...

> [...] I'm currently working at developing a replacement for the
> Windows OS Systray clock. ... I didn't yet start on NTP time
> synchronization.

For an interactive program, you don't need any interaction with the
NTP service; you just read the OS clock and display its time. If NTP
is running in the background, the OS clock will tell that much better
time.

NTP the protocol might come in useful if you were trying to display
the time on another computer. If that computer is running its own NTP
daemon, it will answer NTP requests with its own idea of time. Your
clock could display that time instead of its local OS's time. Not that
it would serve much purpose. If NTP is running on both machines, their
clocks should not have an interactively noticeable time difference.

Groetjes,
Maarten Wiltink


0
Reply Maarten 1/23/2006 7:55:05 PM

Thanks for answering, David, Danny, Maarten...

David: I think you just saved my life since that code is really helpful
and is pretty much exactly what I need. I can port it to VC++ or use it
directly from VB. Thank you a lot!!!

Danny: wasn't thinking at re-inventing the wheel anyway. But I didn't
find any ready-to-use tools until David showed me that. I wouldn't have
imagined NTP is such a big thing but I like it. I would study it more
but I got a software to finish and priorities to set. I just wanted a
piece of mind from you experts in this matters. And you really saved me
of a lot of hours of dirt digging probably.

Some more questions:
1. I know this is a stupid question probably, but I'm still gonna ask
it: synchronizing via SNTP should discard network latencies right? So
if I got a lag of 5 seconds to a server, I should still get the time
within a pretty accurate margin.

2. Why do some servers have "stratum" = 1 and other = 2?

0
Reply Axonn 1/24/2006 2:50:36 PM

Axonn wrote:

>Thanks for answering, David, Danny, Maarten...
>
>David: I think you just saved my life since that code is really helpful
>and is pretty much exactly what I need. I can port it to VC++ or use it
>directly from VB. Thank you a lot!!!
>
>Danny: wasn't thinking at re-inventing the wheel anyway. But I didn't
>find any ready-to-use tools until David showed me that. I wouldn't have
>imagined NTP is such a big thing but I like it. I would study it more
>but I got a software to finish and priorities to set. I just wanted a
>piece of mind from you experts in this matters. And you really saved me
>of a lot of hours of dirt digging probably.
>
>Some more questions:
>1. I know this is a stupid question probably, but I'm still gonna ask
>it: synchronizing via SNTP should discard network latencies right? So
>if I got a lag of 5 seconds to a server, I should still get the time
>within a pretty accurate margin.
>  
>
If you get a "lag" of five seconds, you are using the wrong server or an 
extremely poor network connection!  The potential error in transmitting 
time from server to client is equal to one half of the round trip 
delay!  Typical round trip delays, using a broadband internet connection 
(cable or ADSL), are in the range of ten to fifty milliseconds!

>2. Why do some servers have "stratum" = 1 and other = 2?
>
>  
>
Stratum one servers get their time directly from an "atomic clock".   
Stratum two servers get their time from one or more stratum one 
servers.  Stratum two servers frequently provide better time than 
stratum one servers because the stratum two servers and their network 
connections are not a heavily loaded as the stratum one servers.  IOW, 
stratum is a measure of "distance" from the atomic clock, rather than a 
measure of the accuracy of the time you might obtain from a particular 
server.

There are stratum three servers but these are seldom available to the 
public; usually they are operated by small businesses for their own 
internal use.
Any server with a stratum of four or greater is probably serving its own 
unsynchronized local clock although ten is the conventional stratum in 
this case.
0
Reply Richard 1/24/2006 3:39:05 PM

Axonn wrote:
> Thanks for answering, David, Danny, Maarten...
>
> David: I think you just saved my life since that code is really
> helpful and is pretty much exactly what I need. I can port it to VC++
> or use it directly from VB. Thank you a lot!!!

You're welcome!

[]
> Some more questions:
> 1. I know this is a stupid question probably, but I'm still gonna ask
> it: synchronizing via SNTP should discard network latencies right? So
> if I got a lag of 5 seconds to a server, I should still get the time
> within a pretty accurate margin.

As Richard has said, delays to the server and back to yourself should be 
tens of milliseconds - perhaps more on dial-up.  If you use servers local 
to you (same country or continent), that would be best.  Try to avoid 
servers on another continent (e.g. using US servers from Europe) as there 
will be a satellite delay as well.  But all well under one second.

If you set the Originate time, you can measure the round-trip time, and 
hence improve your estimate of the real time with respect to the server 
you queried, but for a quick "look at the wall clock" type of measurement, 
you can skip that complication.

> 2. Why do some servers have "stratum" = 1 and other = 2?

Stratum is (essentially) the number of "hops" you are away from a known 
reference source, as Richard explained.  An absolute source of time, like 
a GPS receiver, radio clock, or atomic clock would be "stratum 0" although 
you don't see that term used.

Cheers,
David 


0
Reply David 1/24/2006 3:55:02 PM

"Axonn" <axonnus@gmail.com> wrote in message
news:1138114236.831110.128690@g49g2000cwa.googlegroups.com...
[...]
> 1. I know this is a stupid question probably, but I'm still gonna ask
> it: synchronizing via SNTP should discard network latencies right? ...

People will shortly fall over each other to impress upon you that
anything to do with SNTP can never "synchronise" any clock. They
reserve that term for what the full package does, based on its
communication with reference servers, and insist an SNTP client can
only _set_ the time, as often as you like.

The very word SNTP means you never look at more than one packet at a
time, more or less. Actually two - a request and a reply. That gives
you four timestamps, and a way to estimate the total link delay. No
way to estimate the two links delays separately, because you mustn't
assume the clock in the request tells the same time as the clock in
the reply.

So SNP only gives you a means to peek at another machine's clock, at
an instant you can only guess, because you receive it one network
latency period later, and you don't know the exact latency. You only
know the sum of it and the latency in the opposite direction.

It's not unlike gazing at different stars through a telescope. The
distance to each star is different, and with that the time it takes
its light to reach you. If you're reading clocks on their surfaces
that _should_ all be running synchronously, of course you should
compensate for the observation delay or their combined times will
never make sense.


> 2. Why do some servers have "stratum" = 1 and other = 2?

Stratum goes from zero to sixteen. Reference clocks are stratum zero
by definition, and every synchronisation hop adds one. In practice,
few if any paths to a reference clock are longer than four or five
hops. That leaves room for tricks such as fudging reference clocks
that don't really know what time it is to stratum 8 or 10 (for
backup purposes), and interpreting 16 as infinity and unsynchronised.

So a stratum-1 server is synchronising its own clock to an attached
(hardware) reference clock, and a stratum-2 server is synchronising
its clock to a stratum-1 server. My Internet gateway is currently
stratum 3, synchronised to one of my ISP's stratum-2 servers, and the
machine I'm typing this on is synchronised to the gateway, making it
stratum 4. If the gateway loses its Internet connection, it will start
using its own internal clock at stratum 8 and become stratum 9 itself,
and all the other machines in my attic will drop to stratum 10.

Groetjes,
Maarten Wiltink


0
Reply Maarten 1/24/2006 4:07:04 PM

Thank you Maarten, David, Richard. This is for now all the information
I need. You will hear from me again in at least a month, at most three
months. Until then, you've been very nice to me and I appreciate this.
I'll mention everybody that helped in my "Thanks to" list in the
program :- D. I'll also post around here a link to my program when
it'll reach a Beta 3 status (tomorrow it enters Beta 2) for those of
you which use Windows ::- ). 'till then, it's work work work for me...

0
Reply Axonn 1/24/2006 8:25:11 PM

Maarten,

Please consider adding this information to http://ntp.isc.org/Support .

H
0
Reply Harlan 1/24/2006 8:49:14 PM

Harlan Stenn wrote:

>Maarten,
>
>Please consider adding this information to http://ntp.isc.org/Support .
>
>H
>  
>
Harlan,

If you would quote at least a small portion of the message you are 
replying to, it would help people to figure out just what you are 
talking about.  The person who posted the information you would like 
added to http://ntp.isc.org/Support may not have any idea that your 
message is directed to him or what information you want!
0
Reply Richard 1/24/2006 9:02:04 PM

A threaded newsreader is all that's needed, right?

H
0
Reply Harlan 1/25/2006 4:56:16 AM

"Harlan Stenn" <stenn@ntp.isc.org> wrote in message
news:ywn9fync7vnz.fsf@ntp1.isc.org...

> A threaded newsreader is all that's needed, right?

No. I have a threaded newsreader, but I normally have it hiding read
messages, and anyway the message tree is below this window because
where I am now, I have only one screen.

Quoting is still good netiquette.

Groetjes,
Maarten Wiltink


0
Reply Maarten 1/25/2006 8:20:09 AM

Maarten Wiltink wrote:
[]
> Quoting is still good netiquette.
>
> Groetjes,
> Maarten Wiltink

Agreed.
David 


0
Reply David 1/25/2006 8:46:33 AM

"Harlan Stenn" <stenn@ntp.isc.org> wrote in message
news:ywn9wtgp73n9.fsf@ntp1.isc.org...

> Maarten,
>
> Please consider adding this information to http://ntp.isc.org/Support .

Where? I'm not opposed to the idea, but I'm not a prodigiously profligate
Wiki contributor (and I don't intend to become one right now, thank you)
and I don't see a "how does it all work" topic where either the SNTP bits
or the stratum bits might easily fit in.

There is a section, not named Glossary although it might be, which
explains stratum in rather fewer words than I did.

There is notably not anything about SNTP as such.

Groetjes,
Maarten Wiltink


0
Reply Maarten 1/25/2006 8:53:20 AM

In article <1138114236.831110.128690@g49g2000cwa.googlegroups.com>,
 "Axonn" <axonnus@gmail.com> writes:
>Thanks for answering, David, Danny, Maarten...

>David: I think you just saved my life since that code is really helpful
>and is pretty much exactly what I need. I can port it to VC++ or use it
>directly from VB. Thank you a lot!!!

>Danny: wasn't thinking at re-inventing the wheel anyway. But I didn't
>find any ready-to-use tools until David showed me that. I wouldn't have
>imagined NTP is such a big thing but I like it. I would study it more
>but I got a software to finish and priorities to set. I just wanted a
>piece of mind from you experts in this matters. And you really saved me
>of a lot of hours of dirt digging probably.

I haven't figured out what you really want to do, but since you
seem determined to write your own low level networking code,
I'll toss in my 2 cents...

Rolling your own NTP is not a simple problem.  I'll break it down into
these parts:
  1)  Selecting the servers to use.
  2)  Sending/receiving a few packets.
  3)  Deciding when to send them.
  4)  Using the data in the answers to keep the local clock accurate.
  5)  Making sure you don't do anything abusive.

The second part is easy, but I think that's the one you are focused
on.  Please think about the other parts before you write any code to
fling packets around.

The last part is one of my hot buttons.  It's fairly easy to shoot
yourself in the foot by screwing up the retransmission heuristics.
With networks, it's possible to cause problems for other people.

I'd call the following report required reading for anybody thinking
about writing networking code.  Note that it happened with something
as simple as NTP.

Flawed Routers Flood University of Wisconsin Internet Time Server
  http://www.cs.wisc.edu/~plonka/netgear-sntp/

If you poke around on the pool project you will find that abusive
clients are a serious problem.  A big chunk of traffic comes from
a few clients.

I will also repeat the suggestion of running ntpd on your
system and letting it keep the local system time accurate.  Then your
code would just use the system time.  Please try it for a while.
You might learn something, especially if you keep an eye
on the NTP statistics.

-- 
The suespammers.org mail server is located in California.  So are all my
other mailboxes.  Please do not send unsolicited bulk e-mail or unsolicited
commercial e-mail to my suespammers.org address or any of my other addresses.
These are my opinions, not necessarily my employer's.  I hate spam.

0
Reply hmurray 1/25/2006 9:44:59 AM

Harlan Stenn wrote:

>A threaded newsreader is all that's needed, right?
>
>H
>  
>
If all you have to read news with is Netscape, no!  Solaris does not 
appear to ship with a newsreader.   That and Windoze are what I have.

Sure, I can go back through all the messages with the same subject line 
but that means that any of one to thirty messages could be the one I 
want.  One is easy.  More is not.
What about the people who get this as mail?

Netscape does, however, quote the text I'm replying to automagically!

You seem to be the only user of any newsgroup I read who does not quote!
0
Reply Richard 1/25/2006 11:35:59 AM

Axonn wrote:
> Thanks for answering, David, Danny, Maarten...
> 
> David: I think you just saved my life since that code is really
> helpful and is pretty much exactly what I need. I can port it to VC++
> or use it directly from VB. Thank you a lot!!!
> 
> Danny: wasn't thinking at re-inventing the wheel anyway. But I didn't
>  find any ready-to-use tools until David showed me that. I wouldn't
> have imagined NTP is such a big thing but I like it. I would study it
> more but I got a software to finish and priorities to set. I just
> wanted a piece of mind from you experts in this matters. And you
> really saved me of a lot of hours of dirt digging probably.
> 

Please understand that I'm not trying to discourage you in any way. This
is how one learns. Keep up the good work.

I'm only recommending you don't do this since it's a massive undertaking
 to do it right, requires lots of reading and understanding of the
protocols, issues, design which has been developed over 25 years or more.

> Some more questions: 1. I know this is a stupid question probably,
> but I'm still gonna ask it: synchronizing via SNTP should discard
> network latencies right? So if I got a lag of 5 seconds to a server,
> I should still get the time within a pretty accurate margin.

The first question you need to ask yourself is how do you know you have
a lag of 5 seconds? It happens to be one of the tougher questions to
answer. You can measure the round-trip time of a packet, but the best
you can do is to assume it took as long to go as it did to come back and
that's not necessarily true and probably is untrue.

> 
> 2. Why do some servers have "stratum" = 1 and other = 2?
> 
You should read up about this. A stratum 1 server gets its time from a
refclock directly attached to it. The refclock is defined as stratum 0.
A stratum 2 server gets its time from a stratum 1 server and so on. You
always add 1 to the stratum number of the server that you have preferred
based on the algorithms used to select a preference.

Danny
_______________________________________________
questions mailing list
questions@lists.ntp.isc.org
https://lists.ntp.isc.org/mailman/listinfo/questions

0
Reply mayer 1/25/2006 7:02:14 PM

Richard B. Gilbert wrote:
> Stratum one servers get their time directly from an "atomic clock".  
> Stratum two servers get their time from one or more stratum one
> servers.  Stratum two servers frequently provide better time than
> stratum one servers because the stratum two servers and their network
> connections are not a heavily loaded as the stratum one servers.  IOW,
> stratum is a measure of "distance" from the atomic clock, rather than a
> measure of the accuracy of the time you might obtain from a particular
> server.
> 
The term "hops" is probably a better term than "distance" here since it
doesn't indicated any measure of distance either by time or space.

Danny
_______________________________________________
questions mailing list
questions@lists.ntp.isc.org
https://lists.ntp.isc.org/mailman/listinfo/questions

0
Reply mayer 1/25/2006 7:07:00 PM

In article <GvmdneNrkM49_0renZ2dnUVZ_smdnZ2d@comcast.com> "Richard
B. Gilbert" <rgilbert88@comcast.net> writes:
>Harlan Stenn wrote:
>
>>A threaded newsreader is all that's needed, right?

No. I use an excellent threaded newsreader (I've mentioned it before
here:-), and now that threading works again here, I can go to the parent
article (assuming it's available) with a single keypress, and back again
with another - but why should I need to? What happens is basically this:

(Starts reading posting by Harlan)

What the f** is he talking about?

(Goes to parent article)

Aha, it was that thread... - and what did Harlan say?

(Goes back to Harlans post)

OK - and just how does that relate to what he is commenting on?

(Back to parent)

Etc etc. Compare this to having the nice, standard Usenet layout of
interleaved statements/questions and responses in one place - the
non-quoting style is a pain.

>If all you have to read news with is Netscape, no!  Solaris does not 
>appear to ship with a newsreader.   That and Windoze are what I have.

Well, there are plenty of free newsreaders that run on Solaris
around...

>Netscape does, however, quote the text I'm replying to automagically!

As any decent newsreader should. Perhaps you could also look into
trimming the quotes, and putting your comments next to the thing they're
commenting?:-) Seeing that your posting style is at the other extreme
from Harlan's.:-) (With the "quote everything and put new text at one
end" style, I actually prefer that the new text is (shudder) placed at
the top...)

>You seem to be the only user of any newsgroup I read who does not quote!

Actually, unfortunately, it is becoming quite widespread - but in most
cases, it can be blamed on the "new and improved" but totally broken
interface of Google Groups, combined with general newbieness (neither of
which applies to Harlan:-).

--Per Hedeland
per@hedeland.org
0
Reply per 1/26/2006 12:31:03 AM

Per Hedeland wrote:

>In article <GvmdneNrkM49_0renZ2dnUVZ_smdnZ2d@comcast.com> "Richard
>B. Gilbert" <rgilbert88@comcast.net> writes:
>  
>
>>Harlan Stenn wrote:
>>
>>    
>>
>>>A threaded newsreader is all that's needed, right?
>>>      
>>>
>
>No. I use an excellent threaded newsreader (I've 
>
<snip>

>Well, there are plenty of free newsreaders that run on Solaris
>around...
>  
>
If you can figure out which piece of software it is.   90% are called 
G*, where G seems to represent Gnu and * has little or nothing to 
suggest what the function of the package might be.  Netscape meets my 
very modest needs.

>  
>
>>Netscape does, however, quote the text I'm replying to automagically!
>>    
>>
>
>As any decent newsreader should. Perhaps you could also look into
>trimming the quotes, and putting your comments next to the thing they're
>commenting?:-) Seeing that your posting style is at the other extreme
>from Harlan's.:-) (With the "quote everything and put new text at one
>end" style, I actually prefer that the new text is (shudder) placed at
>the top...)
>
>  
>
Placing the new text at the top seems most logical to me as well but 
usenet custom decrees otherwise. . . .
<snip>
0
Reply Richard 1/26/2006 1:03:00 AM

On 2006-01-26, Richard B. Gilbert <rgilbert88@comcast.net> wrote:

>Placing the new text at the top seems most logical to me as well but
>usenet custom decrees otherwise.

It is also customary to trim the quoted material. As. Much. As.
Possible.

-- 
Steve Kostecke <kostecke@ntp.isc.org>
NTP Public Services Project - http://ntp.isc.org/
0
Reply Steve 1/26/2006 4:31:37 AM

Harlan Stenn wrote:
> A threaded newsreader is all that's needed, right?
> 
> H
How do you use a threaded newsreader to read email? for what?

Danny
_______________________________________________
questions mailing list
questions@lists.ntp.isc.org
https://lists.ntp.isc.org/mailman/listinfo/questions

0
Reply mayer 1/26/2006 2:05:01 PM

In article <0vadnTlvnLVYgkXeRVn-og@comcast.com> "Richard B. Gilbert"
<rgilbert88@comcast.net> writes:
>Per Hedeland wrote:
>
>>As any decent newsreader should. Perhaps you could also look into
>>trimming the quotes, and putting your comments next to the thing they're
>>commenting?:-) Seeing that your posting style is at the other extreme
>>from Harlan's.:-) (With the "quote everything and put new text at one
>>end" style, I actually prefer that the new text is (shudder) placed at
>>the top...)
>>
>>  
>>
>Placing the new text at the top seems most logical to me as well but 
>usenet custom decrees otherwise. . . .

Ah, that explains it - you're a top-poster at heart!:-) You just need to
realize that when those that represent the "usenet custom" ask you not
to top-post, they don't mean "put all your text below the in-full quote
of the previous article instead of above it"... And it seems you already
have realized that - thanks!

--Per Hedeland
per@hedeland.org
0
Reply per 1/26/2006 11:05:37 PM

In article <43D8D70D.7020502@ntp.isc.org> Danny wrote:
> Harlan Stenn wrote:
> > A threaded newsreader is all that's needed, right?

> How do you use a threaded newsreader to read email? for what?

This forum is not an email forum, it is a Usenet one.  There is an
email gateway from it, but it is the responsibility of the users of that
gateway to compensate for their use of a degraded interface.

In any case, there are combined news and mail user agents that do thread
mail, and people also run reverse gateways to convert mailing lists into
local newsgroups.

The reason people use threading readers for mail is that mailing lists
generate the same sort of thread trees as other types of forum.

(For the record, though, I believe that selective quoting before each
point in the reply is best.)

[Harlan, please note that your References header was broken.]
0
Reply david 1/27/2006 7:44:56 AM

David Woolley wrote:

>In article <43D8D70D.7020502@ntp.isc.org> Danny wrote:
>  
>
>>Harlan Stenn wrote:
>>    
>>
>>>A threaded newsreader is all that's needed, right?
>>>      
>>>
>>How do you use a threaded newsreader to read email? for what?
>>    
>>
>
>This forum is not an email forum, it is a Usenet one.  
>
<snip>

>[Harlan, please note that your References header was broken.]
>  
>
It seems to me that I have heard that complaint before . . .  endlessly!

0
Reply Richard 1/27/2006 1:04:22 PM

In article <3NidnTMnN87Lh0feRVn-rA@comcast.com> "Richard B. Gilbert"
<rgilbert88@comcast.net> writes:
>David Woolley wrote:
>
>>[Harlan, please note that your References header was broken.]

Hm, seems perfectly fine to me?

>It seems to me that I have heard that complaint before . . .  endlessly!

Nah, it was just that a while ago, the mailing list gateway brokenly
mangled the Message-IDs, making it impossible to have correct References
headers, and Brad insisted that it would lead to total destruction of
Usenet if it was fixed - but then Steve just fixed it anyway.:-) Of
course it's impossible to have the threading work 100% perfectly when
any mailing list gateway is involved, but it sure is "good enough" the
way it is now (and Harlan doesn't post via the mailing list anyway it
seems).

--Per Hedeland
per@hedeland.org
0
Reply per 1/28/2006 2:05:43 PM

Whoah, did you people talk it or what :- ). Last time I was here there
were like 20 messages and now I saw I ain't seeing straight. Well I had
a tough week with a Beta 2 release for the freeware I'm forgin' at. And
I'll have some more busy weeks before I can finally start hitting at
the NTP :- )

Hal Murray: Thank you for the info Hal (hm, I feel like in Arthur C.
Clarke *laugh*... kidding, don't mean no disrespect!). I don't plan to
go flooding anybody with NTP packets. I'm considering doing something
rather gentle :- >.

Danny Mayer: I ain't gettin' discouraged so easily. But NTP is a huge
monster compared to what I was thinking it is (a tiny mouse). It's like
in a cartoon when some character steps down on the claw of a huge beast
and then looks up and up and up and up and up... and whoops *gulp*...
*laugh*. So the only that I can do is either study the very basics that
I need for my task (which I'm doing) or wait for a few years till I
have time to read it all (unlikely).

Yeah, I know the lag question. It's relative, obviously. Go trip
usually doesn't take the same as the return trip :- ), I do know THAT
much. That's why I was questioning the answer of a NTP server
altogether. Even if the latency is below 200 ms, how can NTP keep it
together to an accurancy less than 10 ms. But hey, I guess there ain't
no simple answer to that right? :- D. Unfortunately I won't have time
to read hundreds of pages about NTP in the near future, even if it's so
complexingly-interesting.

0
Reply Axonn 1/29/2006 3:26:04 PM

39 Replies
180 Views

(page loaded in 0.852 seconds)

Similiar Articles:


















7/26/2012 7:47:30 PM


Reply: