3

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.

Raga
  • 43
  • 1
  • 1
  • 5

2 Answers2

3

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/

darshanz
  • 402
  • 3
  • 11
  • 3
    Google play having the applications which gives ping,DNS, Traceroute Check port,HTTP Header like action.then how they code?That application runs the traceroute command without rooted device. – Raga Oct 31 '12 at 10:25
2

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.