cgl.narada.service.time.ntptime
Class NtpHeader

java.lang.Object
  extended by cgl.narada.service.time.ntptime.NtpHeader

public class NtpHeader
extends Object

This class encapsulates the header of a NtpDatagram. See rfc2030 for more details. 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |LI | VN |Mode | Stratum | Poll | Precision | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Root Delay | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Root Dispersion | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reference Identifier | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


Field Summary
static NtpHeader defaultHeader
          The default header for a client datagram.
static byte[] defaultHeaderData
          The default header data for a client datagram.
 
Constructor Summary
NtpHeader(byte[] data)
          Construct a NtpHeader from a 16 byte array.
NtpHeader(int offset, byte[] data)
          Construct a NtpHeader from a byte array and offset
 
Method Summary
 byte[] getHeaderData()
          Gets the 16 byte array constituting the header.
 int getLeapIndicator()
          Gets leap indicator
 int getMode()
          Gets mode
 int getPollInterval()
          Gets poll interval
 double getPrecision()
          Gets precision in milliseconds
 String getReferenceID()
          Gets ReferenceID using the stratum and version number of the packet.
 String getReferenceID(int stratumVal, int versionVal)
          Gets ReferenceID with the given stratum and version number.
 double getRootDelay()
          Gets root delay in milliseconds.
 double getRootDispersion()
          Gets root dispersion.
 int getStratum()
          Gets stratum
 int getVersionNumber()
          Gets version number
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultHeaderData

public static final byte[] defaultHeaderData
The default header data for a client datagram. Version=3, Mode=client.


defaultHeader

public static final NtpHeader defaultHeader
The default header for a client datagram. This is a wrapper around defaultHeaderData

Constructor Detail

NtpHeader

public NtpHeader(byte[] data)
Construct a NtpHeader from a 16 byte array.


NtpHeader

public NtpHeader(int offset,
                 byte[] data)
Construct a NtpHeader from a byte array and offset

Method Detail

getHeaderData

public byte[] getHeaderData()
Gets the 16 byte array constituting the header.

Returns:
byte [] - header data

getLeapIndicator

public int getLeapIndicator()
Gets leap indicator

Returns:
int - leap indicator

getMode

public int getMode()
Gets mode

Returns:
int - mode

getPollInterval

public int getPollInterval()
Gets poll interval

Returns:
int - poll interval

getPrecision

public double getPrecision()
Gets precision in milliseconds

Returns:
double - precision

getReferenceID

public String getReferenceID(int stratumVal,
                             int versionVal)
Gets ReferenceID with the given stratum and version number.

Parameters:
stratumVal - stratum value of the server
versionVal - version number of the packet
Returns:
String - reference ID

getReferenceID

public String getReferenceID()
Gets ReferenceID using the stratum and version number of the packet.

Returns:
String - reference ID

getRootDelay

public double getRootDelay()
Gets root delay in milliseconds.

Returns:
double - root delay

getRootDispersion

public double getRootDispersion()
Gets root dispersion.

Returns:
double - root dispersion

getStratum

public int getStratum()
Gets stratum

Returns:
int - stratum

getVersionNumber

public int getVersionNumber()
Gets version number

Returns:
int - version number


For comments and suggestions please send e-mail to The NaradaBrokering Project