Package nts
Interface NtpV3Packet
- All Known Subinterfaces:
NtpV4Packet,NtsPacket
public interface NtpV3Packet
Interface for a NtpV3Packet with get/set methods corresponding to the fields in the NTP Data Message Header described in RFC 1305.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int3static final int2static final int1static final int0static final intMode option 5.static final intMode option 3.static final intMode option 6.static final intMode option 7.static final intMode option 0.static final intMode option 4.static final intMode option 1.static final intMode option 2.static final int10static final int14static final int1static final int4static final intStandard NTP UDP portstatic final String"DAYTIME"static final String"ICMP"static final String"NTP"static final String"TIME"static final int3static final int4 -
Method Summary
Modifier and TypeMethodDescriptionvoidBuild a request packetgetDatagramPacket(int sz) intintgetMode()intgetPoll()intintintdoubleintlongdoubleintgetType()Return type of time packet.intvoidSets the contents of this object from the datagram packetvoidsetLeapIndicator(int li) Sets leap indicator.voidsetMode(int mode) Sets mode as defined in RFC-1305voidSets originate timestamp given NTP TimeStamp object.voidsetPoll(int poll) Sets poll interval as defined in RFC-1305.voidsetPrecision(int precision) Sets precision as defined in RFC-1305voidSets receive timestamp given NTP TimeStamp object.voidsetReferenceId(int refId) Sets reference clock identifier field.voidSets the reference timestamp given NTP TimeStamp object.voidsetRootDelay(int delay) Sets root delay as defined in RFC-1305voidsetRootDispersion(int dispersion) voidsetStratum(int stratum) Sets stratum as defined in RFC-1305voidSets thetransmittimestamp given NTP TimeStamp object.voidsetVersion(int version) Sets version as defined in RFC-1305voidvalidate(NtpV3Packet req) Validate a response packet given a request packet
-
Field Details
-
NTP_PORT
static final int NTP_PORTStandard NTP UDP port- See Also:
-
LI_NO_WARNING
static final int LI_NO_WARNING0- See Also:
-
LI_LAST_MINUTE_HAS_61_SECONDS
static final int LI_LAST_MINUTE_HAS_61_SECONDS1- See Also:
-
LI_LAST_MINUTE_HAS_59_SECONDS
static final int LI_LAST_MINUTE_HAS_59_SECONDS2- See Also:
-
LI_ALARM_CONDITION
static final int LI_ALARM_CONDITION3- See Also:
-
MODE_RESERVED
static final int MODE_RESERVEDMode option 0.- See Also:
-
MODE_SYMMETRIC_ACTIVE
static final int MODE_SYMMETRIC_ACTIVEMode option 1.- See Also:
-
MODE_SYMMETRIC_PASSIVE
static final int MODE_SYMMETRIC_PASSIVEMode option 2.- See Also:
-
MODE_CLIENT
static final int MODE_CLIENTMode option 3.- See Also:
-
MODE_SERVER
static final int MODE_SERVERMode option 4.- See Also:
-
MODE_BROADCAST
static final int MODE_BROADCASTMode option 5.- See Also:
-
MODE_CONTROL_MESSAGE
static final int MODE_CONTROL_MESSAGEMode option 6.- See Also:
-
MODE_PRIVATE
static final int MODE_PRIVATEMode option 7.- See Also:
-
NTP_MINPOLL
static final int NTP_MINPOLL4- See Also:
-
NTP_MAXPOLL
static final int NTP_MAXPOLL14- See Also:
-
NTP_MINCLOCK
static final int NTP_MINCLOCK1- See Also:
-
NTP_MAXCLOCK
static final int NTP_MAXCLOCK10- See Also:
-
VERSION_3
static final int VERSION_33- See Also:
-
VERSION_4
static final int VERSION_44- See Also:
-
TYPE_NTP
"NTP"- See Also:
-
TYPE_ICMP
"ICMP"- See Also:
-
TYPE_TIME
"TIME"- See Also:
-
TYPE_DAYTIME
"DAYTIME"- See Also:
-
-
Method Details
-
buildRequest
void buildRequest()Build a request packet -
getDatagramPacket
DatagramPacket getDatagramPacket()- Returns:
- a datagram packet with the NTP parts already filled in
-
getDatagramPacket
- Returns:
- a datagram packet with the NTP parts already filled in
-
getLeapIndicator
int getLeapIndicator()- Returns:
- leap indicator as defined in RFC-1305
-
getMode
int getMode()- Returns:
- mode as defined in RFC-1305
-
getModeName
String getModeName()- Returns:
- mode as human readable string; e.g. 3=Client
-
getOriginateTimeStamp
TimeStamp getOriginateTimeStamp()- Returns:
- the
originatetime as defined in RFC-1305
-
getPoll
int getPoll()- Returns:
- poll interval as defined in RFC-1305. Field range between NTP_MINPOLL and NTP_MAXPOLL.
-
getPrecision
int getPrecision()- Returns:
- precision as defined in RFC-1305
-
getReceiveTimeStamp
TimeStamp getReceiveTimeStamp()- Returns:
- the
receivetime as defined in RFC-1305
-
getReferenceId
int getReferenceId()- Returns:
- the reference id (32-bit code) as defined in RFC-1305
-
getReferenceIdString
String getReferenceIdString()- Returns:
- the reference id string
-
getReferenceTimeStamp
TimeStamp getReferenceTimeStamp()- Returns:
- the reference time as defined in RFC-1305
-
getRootDelay
int getRootDelay()- Returns:
- root delay as defined in RFC-1305
-
getRootDelayInMillisDouble
double getRootDelayInMillisDouble()- Returns:
- root delay in milliseconds
-
getRootDispersion
int getRootDispersion()- Returns:
- root dispersion as defined in RFC-1305
-
getRootDispersionInMillis
long getRootDispersionInMillis()- Returns:
- root dispersion in milliseconds
-
getRootDispersionInMillisDouble
double getRootDispersionInMillisDouble()- Returns:
- root dispersion in milliseconds
-
getStratum
int getStratum()- Returns:
- stratum as defined in RFC-1305
-
getTransmitTimeStamp
TimeStamp getTransmitTimeStamp()- Returns:
- the
transmittimestamp as defined in RFC-1305
-
getType
String getType()Return type of time packet. The values (e.g. NTP, TIME, ICMP, ...) correspond to the protocol used to obtain the timing information.- Returns:
- packet type string identifier
-
getVersion
int getVersion()- Returns:
- version as defined in RFC-1305
-
setDatagramPacket
Sets the contents of this object from the datagram packet- Parameters:
dp- the packet
-
setLeapIndicator
void setLeapIndicator(int li) Sets leap indicator.- Parameters:
li- - leap indicator code
-
setMode
void setMode(int mode) Sets mode as defined in RFC-1305- Parameters:
mode- the mode to set
-
setOriginateTimeStamp
Sets originate timestamp given NTP TimeStamp object.- Parameters:
ts- - timestamp
-
setPoll
void setPoll(int poll) Sets poll interval as defined in RFC-1305. Field range between NTP_MINPOLL and NTP_MAXPOLL.- Parameters:
poll- the interval to set
-
setPrecision
void setPrecision(int precision) Sets precision as defined in RFC-1305- Parameters:
precision- Precision- Since:
- 3.4
-
setReceiveTimeStamp
Sets receive timestamp given NTP TimeStamp object.- Parameters:
ts- - timestamp
-
setReferenceId
void setReferenceId(int refId) Sets reference clock identifier field.- Parameters:
refId- the clock id field to set
-
setReferenceTime
Sets the reference timestamp given NTP TimeStamp object.- Parameters:
ts- - timestamp
-
setRootDelay
void setRootDelay(int delay) Sets root delay as defined in RFC-1305- Parameters:
delay- the delay to set- Since:
- 3.4
-
setRootDispersion
void setRootDispersion(int dispersion) - Parameters:
dispersion- the value to set- Since:
- 3.4
-
setStratum
void setStratum(int stratum) Sets stratum as defined in RFC-1305- Parameters:
stratum- the stratum to set
-
setTransmitTime
Sets thetransmittimestamp given NTP TimeStamp object.- Parameters:
ts- - timestamp
-
setVersion
void setVersion(int version) Sets version as defined in RFC-1305- Parameters:
version- the version to set
-
validate
Validate a response packet given a request packet- Parameters:
req- - The request packet- Throws:
IOException- - On failure
-