gpt4 book ai didi

java - Java中如何判断请求的IP地址距离?

转载 作者:行者123 更新时间:2023-12-02 03:43:37 25 4
gpt4 key购买 nike

我想使用Java查找IP地址的距离。例如,我的服务器在印度运行,有两个服务器请求,一个来自美国,另一个来自新加坡。现在我想确定请求IP的最短距离。有没有办法可以有效地实现这一目标?

最佳答案

距离并不是识别网络连接相关问题的好方法。

相反,您应该考虑到达目的地之前所经过的总跳数(或遍历的路由器列表)。

我们有traceroute命令:

traceroute is a computer network diagnostic tool for displaying the route (path) and measuring transit delays of packets across an Internet Protocol (IP) network. The history of the route is recorded as the round-trip times of the packets received from each successive host (remote node) in the route (path); the sum of the mean times in each hop is a measure of the total time spent to establish the connection. Traceroute proceeds unless all (three) sent packets are lost more than twice, then the connection is lost and the route cannot be evaluated.

运行时,traceroute 以简单的文本格式输出遍历的路由器列表以及计时信息。

enter image description here

您可以通过java轻松执行此命令,并解析结果以获得连接想法。

关于java - Java中如何判断请求的IP地址距离?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36565421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com