实现机器人跟踪路由功能 [英] Implement Traceroute functionality in android

查看:147
本文介绍了实现机器人跟踪路由功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次问任何问题,所以请原谅我对我的任何错误。

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.

视觉TracertPro

路由跟踪

我知道,在窗口中输入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.

这篇关于实现机器人跟踪路由功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆