Java for Ping

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Mallory

    Java for Ping

    Can Java perform two pings at one time and display the best ping time
    with the best result?

    Also, can Java perform two trace routes at one time and display the
    trace with the fewest hops?

    Thank you for your help.

    Mike

  • Ingo Pakleppa - ingo at kkeane dot com

    #2
    Re: Java for Ping

    Java actually cannot do ping itself at all (unless that feature was
    recently added). But of course you can use Runtime.exec() to run the
    operating system's implementation of ping. You can do that twice, and then
    get the data from their respective stdout's and parse them out (keeping in
    mind that both starting ping, and later parsing it, will be specific to
    the operating system).

    The same goes for tracert, which essentially is the same as ping anyway.

    Also, keep in mind that if there are two routes to a destination, tracert
    inherently cannot give you a reliable response anyway, so displaying the
    trace with the fewest hops may not give you reliable values.

    Basically, the way tracert works is simply by pinging the destination
    several times. The first time, it uses a hop count of 1. Of course, the
    first router along the line will reject the ping because the hop count has
    reached 0. tracert then displays the address of that router and repeats
    the process, incrementing the hop count each time. So the second, third,
    etc. router along the way will do the rejecting.

    Unfortunately, if there are two or more ways to a destination, it is
    entirely possible that each of these individual pings takes a different
    route. Or, in your example, assume that there are two paths, one with 5
    hops and one with 20 hops. Then, it is possible that the first ten pings
    all take the long path, and then the 11th suddenly takes the short one.
    Tracert would then print out not the short route that you would expect,
    but rather the first 10 hops of the long path.

    On Fri, 01 Aug 2003 14:22:47 -0700, Mike Mallory wrote:
    [color=blue]
    > Can Java perform two pings at one time and display the best ping time
    > with the best result?
    >
    > Also, can Java perform two trace routes at one time and display the
    > trace with the fewest hops?
    >
    > Thank you for your help.
    >
    > Mike[/color]

    --
    Keep American Families united! Support H.R. 539 and H.R. 832
    For more information, see http://www.kkeane.com/lobbyspousal-faq.shtml

    Comment

    Working...