public class NtpV3Impl extends Object implements NtpV3Packet
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()
Returns the datagram packet with the NTP details already filled in.
|
int |
getLeapIndicator()
Returns 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()
Returns mode as defined in RFC-1305 which is a 3-bit integer
whose value is indicated by the MODE_xxx parameters.
|
String |
getModeName()
Return human-readable name of message mode type as described in
RFC 1305.
|
TimeStamp |
getOriginateTimeStamp()
Returns the originate time as defined in RFC-1305.
|
int |
getPoll()
Returns 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()
Returns precision as defined in RFC-1305 encoded as an 8-bit signed
integer (seconds to nearest power of two).
|
TimeStamp |
getReceiveTimeStamp()
Returns receive timestamp as defined in RFC-1305.
|
int |
getReferenceId()
Returns the reference id as defined in RFC-1305, which is
a 32-bit integer whose value is dependent on several criteria.
|
String |
getReferenceIdString()
Returns the reference id string.
|
TimeStamp |
getReferenceTimeStamp()
Returns the reference time as defined in RFC-1305.
|
int |
getRootDelay()
Return root delay as defined in RFC-1305, which is the total roundtrip delay
to the primary reference source, in seconds.
|
double |
getRootDelayInMillisDouble()
Return root delay as defined in RFC-1305 in milliseconds, which is
the total roundtrip delay to the primary reference source, in
seconds.
|
int |
getRootDispersion()
Returns root dispersion as defined in RFC-1305.
|
long |
getRootDispersionInMillis()
Returns root dispersion (as defined in RFC-1305) in milliseconds.
|
double |
getRootDispersionInMillisDouble()
Returns root dispersion (as defined in RFC-1305) in milliseconds
as double precision value.
|
int |
getStratum()
Returns 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()
Returns the transmit timestamp as defined in RFC-1305.
|
String |
getType()
Return type of time packet.
|
int |
getVersion()
Returns NTP version number as defined in RFC-1305.
|
int |
hashCode()
Computes a hashcode for this object.
|
void |
setDatagramPacket(DatagramPacket srcDp)
Set the contents of this object from source datagram packet.
|
void |
setLeapIndicator(int li)
Set leap indicator as defined in RFC-1305.
|
void |
setMode(int mode)
Set mode as defined in RFC-1305.
|
void |
setOriginateTimeStamp(TimeStamp ts)
Set originate timestamp given NTP TimeStamp object.
|
void |
setPoll(int poll)
Set poll interval as defined in RFC-1305.
|
void |
setPrecision(int precision)
Set precision as defined in RFC-1305.
|
void |
setReceiveTimeStamp(TimeStamp ts)
Set receive timestamp given NTP TimeStamp object.
|
void |
setReferenceId(int refId)
Set reference clock identifier field with 32-bit unsigned integer value.
|
void |
setReferenceTime(TimeStamp ts)
Set Reference time with NTP timestamp.
|
void |
setRootDelay(int delay)
Set root delay as defined in RFC-1305.
|
void |
setRootDispersion(int dispersion)
Set root dispersion as defined in RFC-1305.
|
void |
setStratum(int stratum)
Set stratum level as defined in RFC-1305.
|
void |
setTransmitTime(TimeStamp ts)
Set transmit time with NTP timestamp.
|
void |
setVersion(int version)
Set 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 NtpV3Impl()
public int getMode()
getMode in interface NtpV3Packetpublic String getModeName()
getModeName in interface NtpV3Packetpublic void setMode(int mode)
setMode in interface NtpV3Packetmode - the mode to setpublic int getLeapIndicator()
getLeapIndicator in interface NtpV3Packetpublic void setLeapIndicator(int li)
setLeapIndicator in interface NtpV3Packetli - leap indicator.public int getPoll()
getPoll in interface NtpV3Packetpublic void setPoll(int poll)
setPoll in interface NtpV3Packetpoll - poll interval.public int getPrecision()
getPrecision in interface NtpV3Packetpublic void setPrecision(int precision)
setPrecision in interface NtpV3Packetprecision - the precision to setpublic int getVersion()
getVersion in interface NtpV3Packetpublic void setVersion(int version)
setVersion in interface NtpV3Packetversion - NTP version.public int getStratum()
getStratum in interface NtpV3Packetpublic void setStratum(int stratum)
setStratum in interface NtpV3Packetstratum - stratum level.public int getRootDelay()
getRootDelay in interface NtpV3Packetpublic void setRootDelay(int delay)
setRootDelay in interface NtpV3Packetdelay - root delaypublic double getRootDelayInMillisDouble()
getRootDelayInMillisDouble in interface NtpV3Packetpublic int getRootDispersion()
getRootDispersion in interface NtpV3Packetpublic void setRootDispersion(int dispersion)
setRootDispersion in interface NtpV3Packetdispersion - root dispersionpublic long getRootDispersionInMillis()
getRootDispersionInMillis in interface NtpV3Packetpublic double getRootDispersionInMillisDouble()
getRootDispersionInMillisDouble in interface NtpV3Packetpublic void setReferenceId(int refId)
setReferenceId in interface NtpV3PacketrefId - reference clock identifier.public int getReferenceId()
getReferenceId in interface NtpV3Packetpublic String getReferenceIdString()
getReferenceIdString in interface NtpV3Packetpublic TimeStamp getTransmitTimeStamp()
getTransmitTimeStamp in interface NtpV3Packetpublic void setTransmitTime(TimeStamp ts)
ts is null then zero time is used.setTransmitTime in interface NtpV3Packetts - NTP timestamppublic void setOriginateTimeStamp(TimeStamp ts)
ts is null then zero time is used.setOriginateTimeStamp in interface NtpV3Packetts - NTP timestamppublic TimeStamp getOriginateTimeStamp()
getOriginateTimeStamp in interface NtpV3Packetpublic TimeStamp getReferenceTimeStamp()
getReferenceTimeStamp in interface NtpV3PacketTimeStamp object.
Never returns null.public void setReferenceTime(TimeStamp ts)
ts is null
then zero time is used.setReferenceTime in interface NtpV3Packetts - NTP timestamppublic TimeStamp getReceiveTimeStamp()
getReceiveTimeStamp in interface NtpV3Packetpublic void setReceiveTimeStamp(TimeStamp ts)
ts is null then zero time is used.setReceiveTimeStamp in interface NtpV3Packetts - timestamppublic String getType()
getType in interface NtpV3Packetpublic DatagramPacket getDatagramPacket()
getDatagramPacket in interface NtpV3Packetpublic 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 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 int hashCode()
protected static final int ui(byte b)
b - input byteprotected static final long ul(byte b)
b - input byteCopyright © 2001–2017 The Apache Software Foundation. All rights reserved.