简体   繁体   English

Android TraceRoute,Ping,dnslookup

[英]Android traceroute, ping, dnslookup

I want to implement traceroute/ping/dns lookup in the my application. 我想在我的应用程序中实现traceroute / ping / dns查找。 For ping i use a ProcessBuilder: 对于ping,我使用ProcessBuilder:

    ProcessBuilder processBuilder = new ProcessBuilder("ping", "-c 1", host);
    Process process = processBuilder.start();

But how can i use a traceroute and dns lookup? 但是我该如何使用traceroute和dns查找呢? Is it possible without root? 没有root可能吗? Thx. 谢谢。

Regarding the traceroute command. 关于traceroute命令。 This command is essentially recursive ping with TTL (time to live) flag set. 此命令本质上是设置了TTL (生存时间)标志的递归ping TTL does not have anything to do with time. TTL与时间无关。 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. 每次IP数据包通过路由器或交换机时,TTL字段都会减少1。此字段的长度为8位,因此最大跃点为255。

This means that you can do your own traceroute with ping. 这意味着您可以使用ping进行自己的traceroute。

Something like: 就像是:

ProcessBuilder processBuilder;
for(int i = 100; i != 0; i==) {
  processBuilder = new ProcessBuilder("ping", "-c 1 -T " + i, host);
  /* do stuff here */
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM