我用以下代码在unix系统上的Java中实现了一种获取RTT的方法:
String command[] = {"ping", "-c4", theIPAddress};
ProcessBuilder pb = new ProcessBuilder(command);
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line = in.readLine()) != null)
//the terminal output with the ping results...
etc...这很好用,我可以用输出计算RTT (延迟)(以毫秒为单位)。但是,如果主机阻止了ICMP,ping将超时。(即使在Mac OS X终端或Windows CMD中也是如此)
现在我想找到另一种方法来获得IP地址的RTT/延迟。(我不想在主机端安装软件。)如果您不能为我提供Java示例,请给我其他输入。我可以在多种语言之间进行翻译,而且我真的可以使用Google。
发布于 2011-03-01 03:45:21
Tracert是treaceroute的缩写(我最后检查的是windows命令),它也使用ICMP。
在linux上,等同的命令是tracepath,在类Unix操作系统上,UDP实用程序默认使用用户数据报协议(UDP)数据报,目的端口号从33434到33534。traceroute实用程序通常有一个option来指定使用Windows 回应请求(类型8),这与 tracert实用程序所使用的一样。
也有使用TCP数据包的traceroute实现,例如tcptraceroute或layer four traceroute。
来源:traceroute
发布于 2011-03-01 03:30:03
如果主机已阻止ICMP,则它不希望您这样做。试试tracert吧?
https://stackoverflow.com/questions/5146547
复制相似问题