实现机器人跟踪路由功能
这是我第一次问任何问题,所以请原谅我对我的任何错误。
This is the first time I am asking any question so forgive me for my any mistake.
我要实现路由跟踪功能,这类应用程序在Android中Play商店。
I want to implement traceroute functionality like this apps available in android play store.
我知道,在窗口中输入CMD,当路由跟踪google.com
将显示所使用的所有中间IP。
I know that when typing in CMD in windows traceroute google.com
will display all intermediate IP used.
现在我都试过了。
我尝试使用路由跟踪
命令但是Android不支持路由跟踪
只有扎根设备支持它。
I try using traceroute
command but android not support traceroute
only rooted device support it.
Process process =Runtime.getRuntime().exec("traceroute yahoo.com");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
int i;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((i = reader.read(buffer)) > 0)
output.append(buffer, 0, i);
reader.close();
Log.d("*************", ""+output);
所以我想使用ping命令来实现,但使用ping命令就只给google.com的IP不是因为我需要和上述应用中的展示不能得到任何success.By。
So I thought to achieve using ping command but couldn't get any success.By using ping command it only gives ip of google.com not as I need and above apps display.
Process process = Runtime.getRuntime().exec("/system/bin/ping -t 1 -c 1 google.com");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
int i;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((i = reader.read(buffer)) > 0)
output.append(buffer, 0, i);
reader.close();
Log.d("*************", ""+output);
请指导我如何实现这一目标。有些链接或者一些教程将是非常有用的。
Please guide me how to achieve this. Some link or some tutorial will be very useful.
请多多关照。
借助的busybox 工具包括跟踪路由。您可以不按照此 YouTube的教程生根您的手机上运行您的设备上busybox的。然后,您应该能够使用您发布从您的应用程序中查询的traceroute第一code段。当然,你需要确保你的traceroute打电话时,请使用正确的路径。
The busybox utility includes traceroute. You can run busybox on your device without rooting your phone by following this youtube tutorial. You should then be able to use the first code segment you posted to query traceroute from within your app. Of course, you will need to make sure that you use the correct path when calling traceroute.