|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectnetworkClock.NetworkClockController
public class NetworkClockController
Controller class of component NetworkClock
.
Provides a clock, which can be synchronized with a SNTP server (See RFC 2030 for further information).
Can retrieve SNTP messages from a SNTP server at regular intervals and calculate the local clock's offset each time. The local clock's offset calculation is implemented according to the SNTP algorithm specified in RFC 2030.
The method getTime()
can be used to generate timestamps (The
typical accuracy of a SNTP client/server exchange is fractions of a second).
The System's time is never changed.
Uses Adam Buckley's class NtpMessage
as message format.
NtpMessage
Field Summary | |
---|---|
private static InternalInformationPortController |
internalInformationPort
Reference on component InternalInformationPort . |
private static long |
localClockOffset
The local clock's offset (compared to the SNTP server) (accuracy: ~10ms). |
private static java.util.logging.Logger |
LOGGER
Logger used to log and display information. |
private static java.net.InetAddress |
timeServerHost
The SNTP server's address. |
private static java.net.DatagramSocket |
timeServerSocket
Datagram socket to communicate with SNTP server. |
private static boolean |
useSynchronizedClock
Indicates whether to synchronize clock (with SNTP server) or not. |
Constructor Summary | |
---|---|
NetworkClockController()
Generates a new NetworkClock component which provides a
clock, synchronized with a SNTP server. |
Method Summary | |
---|---|
long |
getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT (The typical accuracy of a SNTP client/server exchange is fractions of a second.) |
void |
initialize()
Initializes the this component. |
private static void |
synchronizeClocks()
Retrieves an SNTP message from a SNTP server and calculates the local clock's offset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static InternalInformationPortController internalInformationPort
InternalInformationPort
.
Used to display and/or log data and read general settings.
private static final java.util.logging.Logger LOGGER
private static long localClockOffset
private static java.net.DatagramSocket timeServerSocket
private static java.net.InetAddress timeServerHost
private static boolean useSynchronizedClock
Constructor Detail |
---|
public NetworkClockController()
NetworkClock
component which provides a
clock, synchronized with a SNTP server.
Method Detail |
---|
public void initialize()
private static void synchronizeClocks()
public long getTime()
getTime
in interface NetworkClockInterface
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |