Class ICMPEchoPacket

java.lang.Object
org.opennms.protocols.icmp.ICMPHeader
org.opennms.protocols.icmp.ICMPEchoPacket

public final class ICMPEchoPacket extends ICMPHeader
The ping packet for discovery
Author:
Brian Weaver, Sowmya, OpenNMS
  • Constructor Details

    • ICMPEchoPacket

      public ICMPEchoPacket(long tid)
      Creates a new discovery ping packet that can be sent to a remote protocol stack. The ICMP type is set to an Echo Request. The next sequence in the ICMPHeader base class is set and the sent time is set to the current time.
      Parameters:
      tid - The thread id for the packet.
      See Also:
    • ICMPEchoPacket

      public ICMPEchoPacket(long tid, int packetsize)
      Creates a new discovery ping packet that can be sent to a remote protocol stack. The ICMP type is set to an Echo Request. The next sequence in the ICMPHeader base class is set and the sent time is set to the current time.
      Parameters:
      tid - The thread id for the packet.
      packetsize - The pad size in bytes
      See Also:
    • ICMPEchoPacket

      public ICMPEchoPacket(byte[] buf)
      Creates a new discovery ping packet from the passed buffer.
      Parameters:
      buf - The buffer containing a refected ping packet.
  • Method Details

    • getSentTime

      public final long getSentTime()
      Returns the time the packet was sent.
    • setSentTime

      public final long setSentTime()
      Sets the sent time to the current time.
      See Also:
    • setSentTime

      public final void setSentTime(long time)
      Sets the sent time to the passed value.
      Parameters:
      time - The new sent time.
    • getReceivedTime

      public final long getReceivedTime()
      Gets the currently set received time.
    • setReceivedTime

      public final long setReceivedTime()
      Sets the recieved time for the packet.
      See Also:
    • setReceivedTime

      public final void setReceivedTime(long time)
      Sets the received time to the passed value.
      Parameters:
      time - The new received time.
    • setPingRTT

      public final void setPingRTT(long time)
      Sets the ping Round Trip Time
    • getPingRTT

      public final long getPingRTT()
      Gets the ping Round Trip Time
    • getDataSize

      public int getDataSize()
      Returns the size of the integer headers in packet
    • getMinimumNetworkSize

      public int getMinimumNetworkSize()
      Returns the size of the integer headers in the packet plus the required 'OpenNMS!' string.
    • getNetworkSize

      @Deprecated public static final int getNetworkSize()
      Deprecated.
      Useless function with variable packet sizes but preserved for backwards compatability
      Returns:
    • getPacketSize

      public int getPacketSize()
    • computeChecksum

      public final void computeChecksum()
      Computes and stores the current checksum based upon the data currently contained in the object.
      Overrides:
      computeChecksum in class ICMPHeader
    • getTID

      public final long getTID()
      Returns the currently set Thread ID
    • setTID

      public final void setTID(long tid)
      Sets the current Thread Id
    • loadFromBuffer

      public final int loadFromBuffer(byte[] buf, int offset)
      Loads the data from the passed buffer into the current object. Once loaded the object's values should reflect the contents of the buffer.
      Overrides:
      loadFromBuffer in class ICMPHeader
      Parameters:
      buf - The buffer to load from
      offset - The offset to begin loading from
      Returns:
      The offset of the next byte of data that was not used to initialize this object.
      Throws:
      IndexOutOfBoundsException - Thrown if there is not enough data contained in the buffer to sufficent set the state of the object
    • storeToBuffer

      public final int storeToBuffer(byte[] buf, int offset)
      Writes the objects data out to the specified buffer at the starting offset. If the buffer does not have sufficent data to store the information then an IndexOutOfBoundsException is thrown.
      Overrides:
      storeToBuffer in class ICMPHeader
      Parameters:
      buf - The storage buffer.
      offset - The location to start in buf.
      Returns:
      The new offset after storing to the buffer.
      Throws:
      IndexOutOfBoundsException - Thrown if the buffer does not have enough storage space.
    • toBytes

      public final byte[] toBytes()
      Converts the object into an array of bytes which is suitable for transmission to remote hosts.
      Overrides:
      toBytes in class ICMPHeader
      Returns:
      The object as an array of bytes.