Class Ping


  • public class Ping
    extends java.lang.Object
    A helper class to execute a ping operation.
    As the java ping is not non-admin, there will use the sbproxy ping to implement it.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Ping.PingResult  
    • Constructor Summary

      Constructors 
      Constructor Description
      Ping()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Ping.PingResult exec​(java.lang.String hostname, int pktsToSend, int timeoutInMs)
      execute a ping operation with hostname, pktsToSend and timeoutInMs provided
      static Ping.PingResult exec​(java.net.InetAddress address, int pktsToSend, int timeoutInMs)
      execute a ping operation with address, pktsToSend and timeoutInMs provided
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Ping

        public Ping()
    • Method Detail

      • exec

        public static Ping.PingResult exec​(java.net.InetAddress address,
                                           int pktsToSend,
                                           int timeoutInMs)
                                    throws java.lang.Exception
        execute a ping operation with address, pktsToSend and timeoutInMs provided
        Parameters:
        address - ping host address
        pktsToSend - send packet number, it needs more than 0 and less than 50, the pktsToSend relate to the timeoutInMS parameter
        timeoutInMs - timeout time in millseconds, it needs more than 10000 ms and depends on the the pktsToSend parameter
        Returns:
        When the ping execute ok, it will return PingResult object. When the ping execute failed, It will throw Exception, the detail information refer to the exception message
        Throws:
        java.lang.Exception
      • exec

        public static Ping.PingResult exec​(java.lang.String hostname,
                                           int pktsToSend,
                                           int timeoutInMs)
                                    throws java.lang.Exception
        execute a ping operation with hostname, pktsToSend and timeoutInMs provided
        Parameters:
        hostname - ping host name or IP address
        pktsToSend - send packet number, it needs more than 0 and less than 50, the pktsToSend relate to the timeoutInMS parameter
        timeoutInMs - timeout time in millseconds, it needs more than 10000 ms and depends on the the pktsToSend parameter
        Returns:
        When the ping execute ok, it will return PingResult object. When the ping execute failed, It will throw Exception, the detail information refer to the exception message
        Throws:
        java.lang.Exception