package org.apache.commons.net.ntp;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import java.net.DatagramPacket;

Interface for a NtpV3Packet with get/set methods corresponding to the fields in the NTP Data Message Header described in RFC 1305.
Version:$Revision: 1652868 $
/** * Interface for a NtpV3Packet with get/set methods corresponding to the fields * in the NTP Data Message Header described in RFC 1305. * * @version $Revision: 1652868 $ */
public interface NtpV3Packet {
Standard NTP UDP port
/** * Standard NTP UDP port */
public static final int NTP_PORT = 123; public static final int LI_NO_WARNING = 0; public static final int LI_LAST_MINUTE_HAS_61_SECONDS = 1; public static final int LI_LAST_MINUTE_HAS_59_SECONDS = 2; public static final int LI_ALARM_CONDITION = 3; /* mode options */ public static final int MODE_RESERVED = 0; public static final int MODE_SYMMETRIC_ACTIVE = 1; public static final int MODE_SYMMETRIC_PASSIVE = 2; public static final int MODE_CLIENT = 3; public static final int MODE_SERVER = 4; public static final int MODE_BROADCAST = 5; public static final int MODE_CONTROL_MESSAGE = 6; public static final int MODE_PRIVATE = 7; public static final int NTP_MINPOLL = 4; // 16 seconds public static final int NTP_MAXPOLL = 14; // 16284 seconds public static final int NTP_MINCLOCK = 1; public static final int NTP_MAXCLOCK = 10; public static final int VERSION_3 = 3; public static final int VERSION_4 = 4; /* possible getType values such that other time-related protocols can * have its information represented as NTP packets */ public static final String TYPE_NTP = "NTP"; // RFC-1305/2030 public static final String TYPE_ICMP = "ICMP"; // RFC-792 public static final String TYPE_TIME = "TIME"; // RFC-868 public static final String TYPE_DAYTIME = "DAYTIME"; // RFC-867
Returns:a datagram packet with the NTP parts already filled in
/** * @return a datagram packet with the NTP parts already filled in */
public DatagramPacket getDatagramPacket();
Set the contents of this object from the datagram packet
Params:
  • dp – the packet
/** * Set the contents of this object from the datagram packet * @param dp the packet */
public void setDatagramPacket(DatagramPacket dp);
Returns:leap indicator as defined in RFC-1305
/** * @return leap indicator as defined in RFC-1305 */
public int getLeapIndicator();
Set leap indicator.
Params:
  • li – - leap indicator code
/** * Set leap indicator. * @param li - leap indicator code */
public void setLeapIndicator(int li);
Returns:mode as defined in RFC-1305
/** * @return mode as defined in RFC-1305 */
public int getMode();
Returns:mode as human readable string; e.g. 3=Client
/** * @return mode as human readable string; e.g. 3=Client */
public String getModeName();
Set mode as defined in RFC-1305
Params:
  • mode – the mode to set
/** * Set mode as defined in RFC-1305 * @param mode the mode to set */
public void setMode(int mode);
Returns:poll interval as defined in RFC-1305. Field range between NTP_MINPOLL and NTP_MAXPOLL.
/** * @return poll interval as defined in RFC-1305. * Field range between NTP_MINPOLL and NTP_MAXPOLL. */
public int getPoll();
Set poll interval as defined in RFC-1305. Field range between NTP_MINPOLL and NTP_MAXPOLL.
Params:
  • poll – the interval to set
/** * Set poll interval as defined in RFC-1305. * Field range between NTP_MINPOLL and NTP_MAXPOLL. * @param poll the interval to set */
public void setPoll(int poll);
Returns:precision as defined in RFC-1305
/** * @return precision as defined in RFC-1305 */
public int getPrecision();
Set precision as defined in RFC-1305
Params:
  • precision – Precision
Since:3.4
/** * Set precision as defined in RFC-1305 * @param precision Precision * @since 3.4 */
void setPrecision(int precision);
Returns:root delay as defined in RFC-1305
/** * @return root delay as defined in RFC-1305 */
public int getRootDelay();
Set root delay as defined in RFC-1305
Params:
  • delay – the delay to set
Since:3.4
/** * Set root delay as defined in RFC-1305 * @param delay the delay to set * @since 3.4 */
void setRootDelay(int delay);
Returns:root delay in milliseconds
/** * @return root delay in milliseconds */
public double getRootDelayInMillisDouble();
Returns:root dispersion as defined in RFC-1305
/** * @return root dispersion as defined in RFC-1305 */
public int getRootDispersion();
Params:
  • dispersion – the value to set
Since:3.4
/** * * @param dispersion the value to set * @since 3.4 */
void setRootDispersion(int dispersion);
Returns:root dispersion in milliseconds
/** * @return root dispersion in milliseconds */
public long getRootDispersionInMillis();
Returns:root dispersion in milliseconds
/** * @return root dispersion in milliseconds */
public double getRootDispersionInMillisDouble();
Returns:version as defined in RFC-1305
/** * @return version as defined in RFC-1305 */
public int getVersion();
Set version as defined in RFC-1305
Params:
  • version – the version to set
/** * Set version as defined in RFC-1305 * @param version the version to set */
public void setVersion(int version);
Returns:stratum as defined in RFC-1305
/** * @return stratum as defined in RFC-1305 */
public int getStratum();
Set stratum as defined in RFC-1305
Params:
  • stratum – the stratum to set
/** * Set stratum as defined in RFC-1305 * @param stratum the stratum to set */
public void setStratum(int stratum);
Returns:the reference id string
/** * @return the reference id string */
public String getReferenceIdString();
Returns:the reference id (32-bit code) as defined in RFC-1305
/** * @return the reference id (32-bit code) as defined in RFC-1305 */
public int getReferenceId();
Set reference clock identifier field.
Params:
  • refId – the clock id field to set
/** * Set reference clock identifier field. * @param refId the clock id field to set */
public void setReferenceId(int refId);
Returns:the transmit timestamp as defined in RFC-1305
/** * @return the transmit timestamp as defined in RFC-1305 */
public TimeStamp getTransmitTimeStamp();
Returns:the reference time as defined in RFC-1305
/** * @return the reference time as defined in RFC-1305 */
public TimeStamp getReferenceTimeStamp();
Returns:the originate time as defined in RFC-1305
/** * @return the originate time as defined in RFC-1305 */
public TimeStamp getOriginateTimeStamp();
Returns:the receive time as defined in RFC-1305
/** * @return the receive time as defined in RFC-1305 */
public TimeStamp getReceiveTimeStamp();
Set the transmit timestamp given NTP TimeStamp object.
Params:
  • ts – - timestamp
/** * Set the transmit timestamp given NTP TimeStamp object. * @param ts - timestamp */
public void setTransmitTime(TimeStamp ts);
Set the reference timestamp given NTP TimeStamp object.
Params:
  • ts – - timestamp
/** * Set the reference timestamp given NTP TimeStamp object. * @param ts - timestamp */
public void setReferenceTime(TimeStamp ts);
Set originate timestamp given NTP TimeStamp object.
Params:
  • ts – - timestamp
/** * Set originate timestamp given NTP TimeStamp object. * @param ts - timestamp */
public void setOriginateTimeStamp(TimeStamp ts);
Set receive timestamp given NTP TimeStamp object.
Params:
  • ts – - timestamp
/** * Set receive timestamp given NTP TimeStamp object. * @param ts - timestamp */
public void setReceiveTimeStamp(TimeStamp ts);
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
/** * Return type of time packet. The values (e.g. NTP, TIME, ICMP, ...) * correspond to the protocol used to obtain the timing information. * * @return packet type string identifier */
public String getType(); }