cgl.narada.service.time.ntptime
Class NtpDatagramPacket

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

public class NtpDatagramPacket
extends Object

This class encapsulates a NtpDatagram. See rfc2030 for more details.


Constructor Summary
NtpDatagramPacket()
          Constructs an uninitialized NtpDatagram from a UDP datagram.
NtpDatagramPacket(DatagramPacket dp)
          Sets the UDP packet to the given one.
NtpDatagramPacket(InetAddress iaddr, int iport)
          Constructs a NtpDatagram with only the transmit timestamp filled in (set to the current time).
NtpDatagramPacket(NtpHeader header, InetAddress iaddr, int iport)
          Constructs a NtpDatagram with only the transmit timestamp filled in (set to the current time).
 
Method Summary
 DatagramPacket getDatagramPacket()
          Gets the UDP datagram associated to NtpDatagramPacket.
 NtpHeader getHeader()
          Gets the header associated to a NtpDatagramPacket.
 NtpInfo getInfo()
          Gets the information in a NtpDatagramPacket.
 NtpTimestamp getOriginateTimeStamp()
          Gets the originate timestamp.
 NtpTimestamp getReceiveTimeStamp()
          Gets the receive timestamp.
 NtpTimestamp getReceptionTimeStamp()
          Gets the reception timestamp.
 NtpTimestamp getReferenceTimeStamp()
          Gets the reference timestamp.
 NtpTimestamp getTransmitTimeStamp()
          Gets the transmit timestamp.
 void setNtpTimestamps()
          sets ReferenceTimeStamp, OriginateTimeStamp, ReceiveTimeStamp, TransmitTimeStamp using the data value of the Ntp Packet
 String toString()
          Gets NtpDatagramPacket in String format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NtpDatagramPacket

public NtpDatagramPacket(NtpHeader header,
                         InetAddress iaddr,
                         int iport)
Constructs a NtpDatagram with only the transmit timestamp filled in (set to the current time).

Parameters:
header - NtpHeader
iaddr - InetAddress - InetAddress of the server
iport - int - port number of the server

NtpDatagramPacket

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

Parameters:
iaddr - InetAddress - InetAddress of the server
iport - int - port number of the server

NtpDatagramPacket

public NtpDatagramPacket()
Constructs an uninitialized NtpDatagram from a UDP datagram.


NtpDatagramPacket

public NtpDatagramPacket(DatagramPacket dp)
Sets the UDP packet to the given one.

Parameters:
dp - - UDP datagram packet
Method Detail

getDatagramPacket

public DatagramPacket getDatagramPacket()
Gets the UDP datagram associated to NtpDatagramPacket.

Returns:
DatagramPacket - UDP datagram packet

getHeader

public NtpHeader getHeader()
Gets the header associated to a NtpDatagramPacket.

Returns:
NtpHeader - Header of the NTP packet

getInfo

public NtpInfo getInfo()
Gets the information in a NtpDatagramPacket.

Returns:
NtpInfo - values of the NtpInfo object is set and returned

setNtpTimestamps

public void setNtpTimestamps()
sets ReferenceTimeStamp, OriginateTimeStamp, ReceiveTimeStamp, TransmitTimeStamp using the data value of the Ntp Packet


getOriginateTimeStamp

public NtpTimestamp getOriginateTimeStamp()
Gets the originate timestamp.

Returns:
NtpTimestamp

getReceiveTimeStamp

public NtpTimestamp getReceiveTimeStamp()
Gets the receive timestamp.

Returns:
NtpTimestamp

getReceptionTimeStamp

public NtpTimestamp getReceptionTimeStamp()
Gets the reception timestamp.

Returns:
NtpTimestamp

getReferenceTimeStamp

public NtpTimestamp getReferenceTimeStamp()
Gets the reference timestamp.

Returns:
NtpTimestamp

getTransmitTimeStamp

public NtpTimestamp getTransmitTimeStamp()
Gets the transmit timestamp.

Returns:
NtpTimestamp

toString

public String toString()
Gets NtpDatagramPacket in String format. String includes the followings: Header, ReferenceTimeStamp, OriginateTimeStamp, ReceiveTimeStamp, TransmitTimeStamp

Overrides:
toString in class Object
Returns:
String - String representation of NtpDatagramPacket


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