quamj.qps.util.ntp
Class NtpDatagramPacket

java.lang.Object
  |
  +--quamj.qps.util.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()
           
 
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.

Method Detail

getHeader

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

See Also:
NtpHeader

getReferenceTimeStamp

public TimeStamp getReferenceTimeStamp()
Returns the reference timestamp.


getOriginateTimeStamp

public TimeStamp getOriginateTimeStamp()
Returns the originate timestamp


getReceiveTimeStamp

public TimeStamp getReceiveTimeStamp()
Returns the receive timestamp


getTransmitTimeStamp

public TimeStamp getTransmitTimeStamp()
Returns the transmit timestamp


getReceptionTimeStamp

public TimeStamp getReceptionTimeStamp()
Returns the reception timestamp


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()
Overrides:
toString in class java.lang.Object