'Android traceroute, ping, dnslookup
I want to implement traceroute/ping/dns lookup in the my application. For ping i use a ProcessBuilder:
ProcessBuilder processBuilder = new ProcessBuilder("ping", "-c 1", host);
Process process = processBuilder.start();
But how can i use a traceroute and dns lookup? Is it possible without root? Thx.
Solution 1:[1]
Regarding the traceroute command. This command is essentially recursive ping with TTL (time to live) flag set. TTL does not have anything to do with time. Instead it's a hop counter. Each time the IP packet passes through a router or switch the TTL field is decremented by 1. This field is 8 bits long, so max hops would be 255.
This means that you can do your own traceroute with ping.
Something like:
ProcessBuilder processBuilder;
for(int i = 100; i != 0; i--) {
processBuilder = new ProcessBuilder("ping", "-c 1 -T " + i, host);
/* do stuff here */
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ryan M |