I want to run traceroute command through my application.
How do I do this?

Runtime.getRuntime().exec("traceroute google.com")

not working.

java.io.IOException: Error running exec(). Command: [traceroute, -4, google.com] Working Directory: null Environment: null 11-02 12:51:38.399: E/trace(1604): at java.lang.ProcessManager.exec(ProcessManager.java:224)

Is there another way like using NDK or else.
Please help me out.

有帮助吗?

解决方案

You can not use use traceroute command in Android.

If you want to use it in a rooted device with busybox installed, use path of the busybox installation to run the command. thi library can be useful if you want to use it in rooted devices. http://code.google.com/p/roottools/

其他提示

Another thing you can do is use the simple ping command to create your own traceroute. Traceroute is essentially sending out pings with modified TTL fields. When the ip packet reaches it's lowered TTL limit (before the destinated server) a response is sent from the server. These responses are how traceroutes are able to find how a packet gets to it's destination.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top