Synchronizing clock times between two seperate machines?

K

Ken Adams

How does one go about synchronizing clock times of two distributed computers
in java. Basically I would imagine there would be potential for clock drift
so this synchronization would have to be done at continuous intervals. Any
suggestions.

Thanks

Ken
 
T

Tom Dyess

Ken Adams said:
How does one go about synchronizing clock times of two distributed
computers in java. Basically I would imagine there would be potential for
clock drift so this synchronization would have to be done at continuous
intervals. Any suggestions.

Thanks

Ken

If you want to do it at the network level, research NTPD (Network Time
Protocol Daemon). This will probaby be the simplest way to synchronize..

If you want to do this at the application level, you can do a few things.

If you have some sort of centalized location (single ejb server, single
database server, database cluster) you can pull the time from that single
location in a predetermined interval (every hour or day or week). You can
also pull it whenever you need it (when comparing, etc).

If you are peer to peer, and you want the applicatoin level, it can get
pretty tough, unless java has a library I'm not aware of (which is quite
possible). It would involve designating a "master" timekeeper peer and have
the other peers contact it at intervals, or have it broadcast to all it's
connected peers. Probably don't want to do it this way. If this sounds like
a customer NTPD, well, it is. Lol.
 
D

Dotty

Ken Adams said:
How does one go about synchronizing clock times of two distributed computers
in java. Basically I would imagine there would be potential for clock drift
so this synchronization would have to be done at continuous intervals. Any
suggestions.

Thanks

Ken

The 'clock time' of the two distributed computers is not
part of java, it is part of the operating system. You should
be using "NTP: The Network Time Protocol" http://www.ntp.org/
A tremendous amount of work has gone into the development of this product
at the univ. Delaware and it works very well, much better than
you could hope to achieve with a java program.
Windows XP uses this to set the system time, but it only updates
it once per week. Maybe you could look into having it update more
frequently. Sun operating systems use it too as of about 3 years ago.
It is also a standard that telecoms use.
 
P

Paul van Rossem

The 'clock time' of the two distributed computers is not
part of java, it is part of the operating system. You should
be using "NTP: The Network Time Protocol" http://www.ntp.org/
A tremendous amount of work has gone into the development of this product
at the univ. Delaware and it works very well, much better than
you could hope to achieve with a java program.
Windows XP uses this to set the system time, but it only updates
it once per week. Maybe you could look into having it update more
frequently. Sun operating systems use it too as of about 3 years ago.
It is also a standard that telecoms use.
I agree, don't invent the wheel again. Use NTP on all computers in your
network. In the date/time control panel (Internet tab), select a NTP
service near to your own location. This makes it even more accurate than
it already is. To update the system time in XP more frequently, you need
to change a registry key as follows:
* goto HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
W32Time\TimeProviders\NtpClient
* Select key "SpecialPollInterval"
* The value shown is the value in seconds:
o Default value: 604800 (one week)
o Update every day = 86400 (seconds)
o Update every hour = 3600 (seconds)

Paul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top