org.opennms.netmgt.icmp.jna
Class JnaPingReply

java.lang.Object
  extended by org.opennms.netmgt.icmp.jna.JnaPingReply
All Implemented Interfaces:
EchoPacket, org.opennms.protocols.rt.Response, org.opennms.protocols.rt.ResponseWithId<JnaPingRequestId>

public final class JnaPingReply
extends Object
implements org.opennms.protocols.rt.ResponseWithId<JnaPingRequestId>, EchoPacket

This class is use to encapsulate an ICMP reply that conforms to the packetclass. 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.

Author:
Brian Weaver , Sowmya

Constructor Summary
JnaPingReply(InetAddress addr, EchoPacket pkt)
          Constructs a new reply with the passed address and packet as the contents of the reply.
 
Method Summary
 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()
           
 JnaPingRequestId getRequestId()
          getRequestId
 long getSentTimeNanos()
           
 int getSequenceNumber()
           
 long getThreadId()
           
 boolean isEchoReply()
          Returns true if the recovered packet is an echo reply.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JnaPingReply

public JnaPingReply(InetAddress addr,
                    EchoPacket 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

getRequestId

public JnaPingRequestId getRequestId()

getRequestId

Specified by:
getRequestId in interface org.opennms.protocols.rt.ResponseWithId<JnaPingRequestId>
Returns:
a org.opennms.netmgt.icmp.spi.PingRequestId object.

getAddress

public final InetAddress getAddress()
Returns the internet address of the host that sent the reply.

Returns:
a InetAddress object.

isEchoReply

public boolean isEchoReply()
Returns true if the recovered packet is an echo reply.

Specified by:
isEchoReply in interface EchoPacket
Returns:
a boolean.

getIdentifier

public int getIdentifier()
Specified by:
getIdentifier in interface EchoPacket

getSequenceNumber

public int getSequenceNumber()
Specified by:
getSequenceNumber in interface EchoPacket

getThreadId

public long getThreadId()
Specified by:
getThreadId in interface EchoPacket

getReceivedTimeNanos

public long getReceivedTimeNanos()
Specified by:
getReceivedTimeNanos in interface EchoPacket

getSentTimeNanos

public long getSentTimeNanos()
Specified by:
getSentTimeNanos in interface EchoPacket

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 interface EchoPacket

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.