public class NtpV3Impl extends Object implements NtpV3Packet
NtpV3Packet to convert Java objects to and from the Network Time Protocol (NTP) data message header format described in RFC-1305.LI_ALARM_CONDITION, LI_LAST_MINUTE_HAS_59_SECONDS, LI_LAST_MINUTE_HAS_61_SECONDS, LI_NO_WARNING, MODE_BROADCAST, MODE_CLIENT, MODE_CONTROL_MESSAGE, MODE_PRIVATE, MODE_RESERVED, MODE_SERVER, MODE_SYMMETRIC_ACTIVE, MODE_SYMMETRIC_PASSIVE, NTP_MAXCLOCK, NTP_MAXPOLL, NTP_MINCLOCK, NTP_MINPOLL, NTP_PORT, TYPE_DAYTIME, TYPE_ICMP, TYPE_NTP, TYPE_TIME, VERSION_3, VERSION_4| Constructor and Description |
|---|
NtpV3Impl()
Creates a new instance of NtpV3Impl
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Compares this object against the specified object.
|
DatagramPacket |
getDatagramPacket()
Gets the datagram packet with the NTP details already filled in.
|
int |
getLeapIndicator()
Gets leap indicator as defined in RFC-1305 which is a two-bit code: 0=no warning 1=last minute has 61 seconds 2=last minute has 59 seconds 3=alarm
condition (clock not synchronized)
|
int |
getMode()
Gets the mode as defined in RFC-1305 which is a 3-bit integer whose value is indicated by the MODE_xxx parameters.
|
String |
getModeName()
Gets the human-readable name of message mode type as described in RFC 1305.
|
TimeStamp |
getOriginateTimeStamp()
Gets the
originate time as defined in RFC-1305. |
int |
getPoll()
Gets the poll interval as defined in RFC-1305, which is an eight-bit signed integer indicating the maximum interval between successive messages, in
seconds to the nearest power of two (e.g.
|
int |
getPrecision()
Gets the precision as defined in RFC-1305 encoded as an 8-bit signed integer (seconds to the nearest power of two).
|
TimeStamp |
getReceiveTimeStamp()
Gets the
receive timestamp as defined in RFC-1305. |
int |
getReferenceId()
Gets the reference id as defined in RFC-1305, which is a 32-bit integer whose value is dependent on several criteria.
|
String |
getReferenceIdString()
Gets the reference id string.
|
TimeStamp |
getReferenceTimeStamp()
Gets the reference time as defined in RFC-1305.
|
int |
getRootDelay()
Gets the root delay as defined in RFC-1305, which is the total roundtrip delay to the primary reference source, in seconds.
|
double |
getRootDelayInMillisDouble()
Gets the root delay as defined in RFC-1305 in milliseconds, which is the total roundtrip delay to the primary reference source, in seconds.
|
int |
getRootDispersion()
Gets the root dispersion as defined in RFC-1305.
|
long |
getRootDispersionInMillis()
Gets the root dispersion (as defined in RFC-1305) in milliseconds.
|
double |
getRootDispersionInMillisDouble()
Gets the root dispersion (as defined in RFC-1305) in milliseconds as double precision value.
|
int |
getStratum()
Gets the Stratum as defined in RFC-1305, which indicates the stratum level of the local clock, with values defined as follows: 0=unspecified, 1=primary
ref clock, and all others a secondary reference (via NTP).
|
TimeStamp |
getTransmitTimeStamp()
Gets the
transmit timestamp as defined in RFC-1305. |
String |
getType()
Gets the type of time packet.
|
int |
getVersion()
Gets the NTP version number as defined in RFC-1305.
|
int |
hashCode()
Computes a hash code for this object.
|
void |
setDatagramPacket(DatagramPacket srcDp)
Sets the contents of this object from source datagram packet.
|
void |
setLeapIndicator(int li)
Sets leap indicator as defined in RFC-1305.
|
void |
setMode(int mode)
Sets mode as defined in RFC-1305.
|
void |
setOriginateTimeStamp(TimeStamp ts)
Sets originate timestamp given NTP TimeStamp object.
|
void |
setPoll(int poll)
Sets poll interval as defined in RFC-1305.
|
void |
setPrecision(int precision)
Sets precision as defined in RFC-1305.
|
void |
setReceiveTimeStamp(TimeStamp ts)
Sets receive timestamp given NTP TimeStamp object.
|
void |
setReferenceId(int refId)
Sets reference clock identifier field with 32-bit unsigned integer value.
|
void |
setReferenceTime(TimeStamp ts)
Sets Reference time with NTP timestamp.
|
void |
setRootDelay(int delay)
Sets root delay as defined in RFC-1305.
|
void |
setRootDispersion(int dispersion)
Sets root dispersion as defined in RFC-1305.
|
void |
setStratum(int stratum)
Sets stratum level as defined in RFC-1305.
|
void |
setTransmitTime(TimeStamp ts)
Sets transmit time with NTP timestamp.
|
void |
setVersion(int version)
Sets NTP version as defined in RFC-1305.
|
String |
toString()
Returns details of NTP packet as a string.
|
protected static int |
ui(byte b)
Convert byte to unsigned integer.
|
protected static long |
ul(byte b)
Convert byte to unsigned long.
|
public boolean equals(Object obj)
true if and only if the argument is not null and is a
NtpV3Impl object that contains the same values as this object.public DatagramPacket getDatagramPacket()
getDatagramPacket in interface NtpV3Packetpublic int getLeapIndicator()
getLeapIndicator in interface NtpV3Packetpublic int getMode()
getMode in interface NtpV3Packetpublic String getModeName()
getModeName in interface NtpV3Packetpublic TimeStamp getOriginateTimeStamp()
originate time as defined in RFC-1305.getOriginateTimeStamp in interface NtpV3Packetoriginate time. Never returns null.public int getPoll()
getPoll in interface NtpV3Packetpublic int getPrecision()
getPrecision in interface NtpV3Packetpublic TimeStamp getReceiveTimeStamp()
receive timestamp as defined in RFC-1305.getReceiveTimeStamp in interface NtpV3Packetreceive time. Never returns null.public int getReferenceId()
getReferenceId in interface NtpV3Packetpublic String getReferenceIdString()
getReferenceIdString in interface NtpV3Packetpublic TimeStamp getReferenceTimeStamp()
getReferenceTimeStamp in interface NtpV3PacketTimeStamp object. Never returns null.public int getRootDelay()
getRootDelay in interface NtpV3Packetpublic double getRootDelayInMillisDouble()
getRootDelayInMillisDouble in interface NtpV3Packetpublic int getRootDispersion()
getRootDispersion in interface NtpV3Packetpublic long getRootDispersionInMillis()
getRootDispersionInMillis in interface NtpV3Packetpublic double getRootDispersionInMillisDouble()
getRootDispersionInMillisDouble in interface NtpV3Packetpublic int getStratum()
getStratum in interface NtpV3Packetpublic TimeStamp getTransmitTimeStamp()
transmit timestamp as defined in RFC-1305.getTransmitTimeStamp in interface NtpV3Packettransmit timestamp as defined in RFC-1305. Never returns a null object.public String getType()
getType in interface NtpV3Packetpublic int getVersion()
getVersion in interface NtpV3Packetpublic int hashCode()
public void setDatagramPacket(DatagramPacket srcDp)
setDatagramPacket in interface NtpV3PacketsrcDp - source DatagramPacket to copy contents from, never null.IllegalArgumentException - if srcDp is null or byte length is less than minimum length of 48 bytespublic void setLeapIndicator(int li)
setLeapIndicator in interface NtpV3Packetli - leap indicator.public void setMode(int mode)
setMode in interface NtpV3Packetmode - the mode to setpublic void setOriginateTimeStamp(TimeStamp ts)
ts is null then zero time is used.setOriginateTimeStamp in interface NtpV3Packetts - NTP timestamppublic void setPoll(int poll)
setPoll in interface NtpV3Packetpoll - poll interval.public void setPrecision(int precision)
setPrecision in interface NtpV3Packetprecision - the precision to setpublic void setReceiveTimeStamp(TimeStamp ts)
ts is null then zero time is used.setReceiveTimeStamp in interface NtpV3Packetts - timestamppublic void setReferenceId(int refId)
setReferenceId in interface NtpV3PacketrefId - reference clock identifier.public void setReferenceTime(TimeStamp ts)
ts is null then zero time is used.setReferenceTime in interface NtpV3Packetts - NTP timestamppublic void setRootDelay(int delay)
setRootDelay in interface NtpV3Packetdelay - root delaypublic void setRootDispersion(int dispersion)
setRootDispersion in interface NtpV3Packetdispersion - root dispersionpublic void setStratum(int stratum)
setStratum in interface NtpV3Packetstratum - stratum level.public void setTransmitTime(TimeStamp ts)
ts is null then zero time is used.setTransmitTime in interface NtpV3Packetts - NTP timestamppublic void setVersion(int version)
setVersion in interface NtpV3Packetversion - NTP version.public String toString()
protected static final int ui(byte b)
b - input byteprotected static final long ul(byte b)
b - input byte