• Post Reply Bookmark Topic Watch Topic
  • New Topic

count hops in java  RSS feed

 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to count how many hops it takes to send a message to a distant node?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing to come to mind is to use Runtime.exec() to invoke traceroute
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same here.

but i thought it would be faster if java has support for this instead of invoking an external process.

also, i would like to know whether it is true that usually network latency is long if the hop count is greater?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you search for "java traceroute" there's a couple hits. One I looked at used JNI. Don't know about the others. Traceroute works by adjusting the packet TTL so it can evaluate each hop. I don't know that Java allows that kind of functionality.

As for more hops equaling greater latency, I don't know if that's exactly true. I'd be more inclined to say that as the number of hops increases, the greater chance there is for higher latency. One could imagine a scenario where congestion would shut down the shortest route and a longer route would be faster.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!