org.jscience.net.ntp
Class NtpDatagramPacket

java.lang.Object
  extended by org.jscience.net.ntp.NtpDatagramPacket

public class NtpDatagramPacket
extends java.lang.Object

This class encapsulates a ntp-datagram as described in rfc2030. Such a datagram consists of a header and four timestamps. The four timestamps are respectively:

We have added a fifth timestamp. Namely a 'reception timestamp' which is normally set by NtpConnection.receive(NtpDatagramPacket). When transmitted a ntp-datagram is wrapped in a UDP datagram.

See Also:
java.net.Datagram, TimeStamp, NtpHeader, NtpConnection

Constructor Summary
NtpDatagramPacket()
          Constructs an uninitialized NtpDatagram.
NtpDatagramPacket(java.net.DatagramPacket dp)
          Constructs an uninitialized NtpDatagram from a UDP datagram.
NtpDatagramPacket(java.net.InetAddress iaddr, int iport)
          Construct a NtpDatagram with only the transmit timestamp filled in (set to the current time).
NtpDatagramPacket(NtpHeader header, TimeStamp referenceTimeStamp, TimeStamp originateTimeStamp, TimeStamp receiveTimeStamp, TimeStamp transmitTimeStamp, java.net.InetAddress iaddr, int iport)
          Construct a NtpDatagram from a header, four timestamps, an Inetaddress and a portnumber.
 
Method Summary
 NtpHeader getHeader()
          Returns the header associated to a NtpDatagram.
 NtpInfo getInfo()
          A convenience method which returns the useful information contained in a NtpDatagram.
 TimeStamp getOriginateTimeStamp()
          Returns the originate timestamp
 TimeStamp getReceiveTimeStamp()
          Returns the receive timestamp
 TimeStamp getReceptionTimeStamp()
          Returns the reception timestamp
 TimeStamp getReferenceTimeStamp()
          Returns the reference timestamp.
 TimeStamp getTransmitTimeStamp()
          Returns the transmit timestamp
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NtpDatagramPacket

public NtpDatagramPacket(NtpHeader header,
                         TimeStamp referenceTimeStamp,
                         TimeStamp originateTimeStamp,
                         TimeStamp receiveTimeStamp,
                         TimeStamp transmitTimeStamp,
                         java.net.InetAddress iaddr,
                         int iport)
Construct a NtpDatagram from a header, four timestamps, an Inetaddress and a portnumber.

See Also:
InetAddress

NtpDatagramPacket

public NtpDatagramPacket(java.net.InetAddress iaddr,
                         int iport)
Construct a NtpDatagram with only the transmit timestamp filled in (set to the current time). The header is set to a NtpHeader.defaultHeader.

See Also:
NtpHeader

NtpDatagramPacket

public NtpDatagramPacket()
Constructs an uninitialized NtpDatagram.


NtpDatagramPacket

public NtpDatagramPacket(java.net.DatagramPacket dp)
Constructs an uninitialized NtpDatagram from a UDP datagram.

Parameters:
dp - DOCUMENT ME!
Method Detail

getHeader

public NtpHeader getHeader()
Returns the header associated to a NtpDatagram.

See Also:
NtpHeader

getReferenceTimeStamp

public TimeStamp getReferenceTimeStamp()
Returns the reference timestamp.

Returns:
DOCUMENT ME!

getOriginateTimeStamp

public TimeStamp getOriginateTimeStamp()
Returns the originate timestamp

Returns:
DOCUMENT ME!

getReceiveTimeStamp

public TimeStamp getReceiveTimeStamp()
Returns the receive timestamp

Returns:
DOCUMENT ME!

getTransmitTimeStamp

public TimeStamp getTransmitTimeStamp()
Returns the transmit timestamp

Returns:
DOCUMENT ME!

getReceptionTimeStamp

public TimeStamp getReceptionTimeStamp()
Returns the reception timestamp

Returns:
DOCUMENT ME!

getInfo

public NtpInfo getInfo()
A convenience method which returns the useful information contained in a NtpDatagram.

See Also:
NtpInfo

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENT ME!