Package org.opennms.netmgt.icmp.jni
Class JniPingResponse
- java.lang.Object
-
- org.opennms.netmgt.icmp.jni.JniPingResponse
-
- All Implemented Interfaces:
EchoPacket
,org.opennms.protocols.rt.Response
,org.opennms.protocols.rt.ResponseWithId<JniPingRequestId>
public final class JniPingResponse extends Object implements org.opennms.protocols.rt.ResponseWithId<JniPingRequestId>, EchoPacket
This class is use to encapsulate an ICMP reply that conforms to the
packet
class. The reply must be of type ICMP Echo Reply and be the correct length.When constructed by the
create
method the returned reply encapsulates the sender's address and the received packet as final, non-mutable values for the instance.
-
-
Constructor Summary
Constructors Constructor Description JniPingResponse(InetAddress addr, org.opennms.protocols.icmp.ICMPEchoPacket pkt)
Constructs a new reply with the passed address and packet as the contents of the reply.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
elapsedTime(TimeUnit timeUnit)
Returns the round trip time in the requested TimeUnit (note that a fractional value will be returned if necessary)InetAddress
getAddress()
Returns the internet address of the host that sent the reply.int
getIdentifier()
long
getReceivedTimeNanos()
JniPingRequestId
getRequestId()
getRequestIdlong
getSentTimeNanos()
int
getSequenceNumber()
long
getThreadId()
boolean
isEchoReply()
Returns true if the recovered packet is an echo reply.String
toString()
-
-
-
Constructor Detail
-
JniPingResponse
public JniPingResponse(InetAddress addr, org.opennms.protocols.icmp.ICMPEchoPacket pkt)
Constructs a new reply with the passed address and packet as the contents of the reply.- Parameters:
addr
- The address of the ICMP sender.pkt
- The received packet.
-
-
Method Detail
-
getAddress
public InetAddress getAddress()
Returns the internet address of the host that sent the reply.- Returns:
- a
InetAddress
object.
-
getRequestId
public JniPingRequestId getRequestId()
getRequestId
- Specified by:
getRequestId
in interfaceorg.opennms.protocols.rt.ResponseWithId<JniPingRequestId>
- Returns:
- a
org.opennms.netmgt.icmp.spi.PingRequestId
object.
-
isEchoReply
public boolean isEchoReply()
Returns true if the recovered packet is an echo reply.- Specified by:
isEchoReply
in interfaceEchoPacket
- Returns:
- a boolean.
-
getIdentifier
public int getIdentifier()
- Specified by:
getIdentifier
in interfaceEchoPacket
-
getSequenceNumber
public int getSequenceNumber()
- Specified by:
getSequenceNumber
in interfaceEchoPacket
-
getThreadId
public long getThreadId()
- Specified by:
getThreadId
in interfaceEchoPacket
-
getSentTimeNanos
public long getSentTimeNanos()
- Specified by:
getSentTimeNanos
in interfaceEchoPacket
-
getReceivedTimeNanos
public long getReceivedTimeNanos()
- Specified by:
getReceivedTimeNanos
in interfaceEchoPacket
-
elapsedTime
public double elapsedTime(TimeUnit timeUnit)
Description copied from interface:EchoPacket
Returns the round trip time in the requested TimeUnit (note that a fractional value will be returned if necessary)- Specified by:
elapsedTime
in interfaceEchoPacket
-
-