Package org.opennms.netmgt.icmp.jni
Class JniPinger
- java.lang.Object
-
- org.opennms.netmgt.icmp.jni.JniPinger
-
- All Implemented Interfaces:
Pinger
public class JniPinger extends Object implements Pinger
JniPinger class.
- Author:
- Ben Reed, Mathew Brozowski
-
-
Constructor Summary
Constructors Constructor Description JniPinger()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinitialize4()Initialize IPv4 in this Pinger implementation.voidinitialize6()Initialize IPv6 in this Pinger implementation.booleanisV4Available()Whether or not IPv4 is initialized and available for this implementation.booleanisV6Available()Whether or not IPv6 is initialized and available for this implementation.List<Number>parallelPing(InetAddress host, int count, long timeout, long pingInterval)Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.List<Number>parallelPing(InetAddress host, int count, long timeout, long pingInterval, int size)Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.Numberping(InetAddress host)Ping a remote host, using the default number of retries and timeouts.Numberping(InetAddress host, long timeout, int retries)This method is used to ping a remote host to test for ICMP support.Numberping(InetAddress host, long timeout, int retries, int packetsize)This method is used to ping a remote host to test for ICMP support.voidping(InetAddress host, long timeout, int retries, int packetsize, int sequenceId, PingResponseCallback cb)pingvoidping(InetAddress host, long timeout, int retries, int sequenceId, PingResponseCallback cb)pingvoidsetAllowFragmentation(boolean allow)voidsetTrafficClass(int tc)
-
-
-
Method Detail
-
initialize4
public void initialize4() throws ExceptionDescription copied from interface:PingerInitialize IPv4 in this Pinger implementation. If unable to do so, implementations should throw an exception.- Specified by:
initialize4in interfacePinger- Throws:
Exception
-
initialize6
public void initialize6() throws ExceptionDescription copied from interface:PingerInitialize IPv6 in this Pinger implementation. If unable to do so, implementations should throw an exception.- Specified by:
initialize6in interfacePinger- Throws:
Exception
-
isV4Available
public boolean isV4Available()
Description copied from interface:PingerWhether or not IPv4 is initialized and available for this implementation.- Specified by:
isV4Availablein interfacePinger
-
isV6Available
public boolean isV6Available()
Description copied from interface:PingerWhether or not IPv6 is initialized and available for this implementation.- Specified by:
isV6Availablein interfacePinger- Returns:
-
ping
public void ping(InetAddress host, long timeout, int retries, int packetsize, int sequenceId, PingResponseCallback cb) throws Exception
ping
- Specified by:
pingin interfacePinger- Parameters:
host- aInetAddressobject.timeout- a long.retries- a int.packetsize- The size in byte of the ICMP packet.sequenceId- a short.cb- aorg.opennms.netmgt.icmp.jni.PingResponseCallbackobject.- Throws:
Exception- if any.
-
ping
public void ping(InetAddress host, long timeout, int retries, int sequenceId, PingResponseCallback cb) throws Exception
ping
- Specified by:
pingin interfacePinger- Parameters:
host- aInetAddressobject.timeout- a long.retries- a int.packetsize- The size in byte of the ICMP packet.sequenceId- a short.cb- aorg.opennms.netmgt.icmp.jni.PingResponseCallbackobject.- Throws:
Exception- if any.
-
ping
public Number ping(InetAddress host, long timeout, int retries, int packetsize) throws Exception
This method is used to ping a remote host to test for ICMP support. If the remote host responds within the specified period, defined by retries and timeouts, then the response time is returned.- Specified by:
pingin interfacePinger- Parameters:
host- The address to poll.timeout- The time to wait between each retry.retries- The number of times to retrypacketsize- The size in byte of the ICMP packet.- Returns:
- The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value.
- Throws:
InterruptedException- if any.IOException- if any.Exception- if any.
-
ping
public Number ping(InetAddress host, long timeout, int retries) throws Exception
This method is used to ping a remote host to test for ICMP support. If the remote host responds within the specified period, defined by retries and timeouts, then the response time is returned.- Specified by:
pingin interfacePinger- Parameters:
host- The address to poll.timeout- The time to wait between each retry.retries- The number of times to retry- Returns:
- The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value.
- Throws:
InterruptedException- if any.IOException- if any.Exception- if any.
-
ping
public Number ping(InetAddress host) throws Exception
Ping a remote host, using the default number of retries and timeouts.- Specified by:
pingin interfacePinger- Parameters:
host- the host to ping- Returns:
- the round-trip time of the packet
- Throws:
IOException- if any.InterruptedException- if any.Exception- if any.
-
parallelPing
public List<Number> parallelPing(InetAddress host, int count, long timeout, long pingInterval, int size) throws Exception
Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.- Specified by:
parallelPingin interfacePinger- Parameters:
host- TheInetAddressaddress to poll.count- The number of packets to send.timeout- The time to wait between each retry.pingInterval- The interval at which packets will be sent.size- The size of the packet to send.- Returns:
- a
Listof response times in microseconds. If, for a given ping request, the host is reachable and has responded with an echo reply, it will contain a number, otherwise a null value. - Throws:
Exception
-
parallelPing
public List<Number> parallelPing(InetAddress host, int count, long timeout, long pingInterval) throws Exception
Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.- Specified by:
parallelPingin interfacePinger- Parameters:
host- TheInetAddressaddress to poll.count- The number of packets to send.timeout- The time to wait between each retry.pingInterval- The interval at which packets will be sent.- Returns:
- a
Listof response times in microseconds. If, for a given ping request, the host is reachable and has responded with an echo reply, it will contain a number, otherwise a null value. - Throws:
Exception
-
setTrafficClass
public void setTrafficClass(int tc) throws Exception- Specified by:
setTrafficClassin interfacePinger- Throws:
Exception
-
setAllowFragmentation
public void setAllowFragmentation(boolean allow) throws Exception- Specified by:
setAllowFragmentationin interfacePinger- Throws:
Exception
-
-