ping - 您可以在 Java 中运行真正的 ping 吗?

标签 ping icmp diagnostics traceroute packet-loss

最近几周我做了相当多的研究试图创建一个连接诊断工具,我不太想只检查连接是否可用而是诊断是否存在抖动、数据包丢失等..

到目前为止,Java 似乎不支持真正的 ICMP 请求,并且有一些解决方法,但没有一个能实现我正在尝试做的事情。

有谁知道是否可以构建这种工具,或者我应该开始研究其他选项吗?

最佳答案

InetAdress 似乎在可能的情况下使用 ICMP:

https://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html

看看 public boolean isReachable(int timeout)

Test whether that address is reachable. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.

您可以在这里找到一个简单的使用示例: How to test if a remote system is reachable 或这里 How to ping an IP address

关于ping - 您可以在 Java 中运行真正的 ping 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28968846/

相关文章:

azure - Azure 本地存储 TraceListener 位于何处?

C捕获ICMP数据包

go - 无法接收超时消息

linux - 执行 tcpstat 命令并同时对其输出执行操作

.net - 用于测量操作时间的最合适的性能计数器类型是什么?

python - 尝试使用 python 对多台电脑执行 ping 操作。 。

windows - 无法从 Windows ping 到多播地址

windows-phone-8 - 如何在windows phone 8中实现ping

带有 ping 和 mysql 查询结果的 php 主机状态

c# - 测量 ASP.NET MVC 3 的性能