Package org.opennms.protocols.icmp
Class ICMPEchoPacket
java.lang.Object
org.opennms.protocols.icmp.ICMPHeader
org.opennms.protocols.icmp.ICMPEchoPacket
The ping packet for discovery
- Author:
- Brian Weaver, Sowmya, OpenNMS
-
Field Summary
Fields inherited from class org.opennms.protocols.icmp.ICMPHeader
CODE_BAD_IP_HEADER, CODE_COMMUNICATIONS_ADMIN_PROHIBITIED, CODE_DESTINATION_HOST_ADMIN_PROHIBITED, CODE_DESTINATION_HOST_UNKNOWN, CODE_DESTINATION_NETWORK_ADMIN_PROHIBITED, CODE_DESTINATION_NETWORK_UNKNOWN, CODE_FRAGMENTATION_NEEDED, CODE_HOST_PRECEDENCE_VIOLATION, CODE_HOST_UNREACHABLE, CODE_HOST_UNREACHABLE_FOR_TOS, CODE_NETWORK_UNREACHABLE, CODE_NETWORK_UNREACHABLE_FOR_TOS, CODE_PORT_UNREACHABLE, CODE_PRECEDENCE_CUTOFF_IN_EFFECT, CODE_PROTOCOL_UNREACHABLE, CODE_REDIRECT_FOR_HOST, CODE_REDIRECT_FOR_NETWORK, CODE_REDIRECT_FOR_TYPE_OF_SERVICE_AND_HOST, CODE_REDIRECT_FOR_TYPE_OF_SERVICE_AND_NETWORK, CODE_REQUIRED_OPTION_MISSING, CODE_SOURCE_HOST_ISOLATED, CODE_SOURCE_ROUTE_FAILED, CODE_TTL_EQ_ZERO_IN_REASSEMBLY, CODE_TTL_EQ_ZERO_IN_TRANSIT, TYPE_ADDRESS_MASK_REPLY, TYPE_ADDRESS_MASK_REQUEST, TYPE_DESTINATION_UNREACHABLE, TYPE_ECHO_REPLY, TYPE_ECHO_REQUEST, TYPE_INFORMATION_REPLY, TYPE_INFORMATION_REQUEST, TYPE_PARAMETER_PROBLEM, TYPE_REDIRECT, TYPE_ROUTER_ADVERTISEMENT, TYPE_ROUTER_SOLICITATION, TYPE_SOURCE_QUENCH, TYPE_TIME_EXCEEDED, TYPE_TIMESTAMP_REPLY, TYPE_TIMESTAMP_REQUEST -
Constructor Summary
ConstructorsConstructorDescriptionICMPEchoPacket(byte[] buf) Creates a new discovery ping packet from the passed buffer.ICMPEchoPacket(long tid) Creates a new discovery ping packet that can be sent to a remote protocol stack.ICMPEchoPacket(long tid, int packetsize) Creates a new discovery ping packet that can be sent to a remote protocol stack. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidComputes and stores the current checksum based upon the data currently contained in the object.intReturns the size of the integer headers in packetintReturns the size of the integer headers in the packet plus the required 'OpenNMS!'static final intDeprecated.intfinal longGets the ping Round Trip Timefinal longGets the currently set received time.final longReturns the time the packet was sent.final longgetTID()Returns the currently set Thread IDfinal intloadFromBuffer(byte[] buf, int offset) Loads the data from the passed buffer into the current object.final voidsetPingRTT(long time) Sets the ping Round Trip Timefinal longSets the recieved time for the packet.final voidsetReceivedTime(long time) Sets the received time to the passed value.final longSets the sent time to the current time.final voidsetSentTime(long time) Sets the sent time to the passed value.final voidsetTID(long tid) Sets the current Thread Idfinal intstoreToBuffer(byte[] buf, int offset) Writes the objects data out to the specified buffer at the starting offset.final byte[]toBytes()Converts the object into an array of bytes which is suitable for transmission to remote hosts.Methods inherited from class org.opennms.protocols.icmp.ICMPHeader
byteToInt, byteToShort, computeChecksum, getChecksum, getCode, getHeaderSize, getIdentity, getSequenceId, getType, isEchoReply, isEchoRequest, nextSequenceId, setChecksum, setCode, setIdentity, setNextSequenceId, setSequenceId, setType
-
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.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:
computeChecksumin classICMPHeader
-
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:
loadFromBufferin classICMPHeader- Parameters:
buf- The buffer to load fromoffset- 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:
storeToBufferin classICMPHeader- 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:
toBytesin classICMPHeader- Returns:
- The object as an array of bytes.
-