This seems like it should be a simple solution to find, but I'm not having any luck. I want to write a simple ping/traceroute/dns troubleshooting app, but am simply not finding any documentation or examples on sending ICMP ECHO packets with set TTLs and interpreting their responses. I realize that Java likes to keep you away from "low-level" networking, but ICMP is a basic, major part of networking. Frankly, I'm shocked at the apparent difficulty. Am I making this more complicated than need be, or is there literally no good way to go about this? If the latter, in开发者_如何学Go what "bad" way do you most often work around this shortcoming?
Am I making this more complicated than need be, or is there literally no good way to go about this?
There is no pure-Java way to go about this. Java has never supported ICMP beyond its limited use in isReachable()
, and I cannot even confirm that this use of ICMP exists in Android.
However, you could try to use the NDK to link in a C library that implements ICMP.
精彩评论