net.ping 的匹配机制问题
#3166
-
查看源码,ping的机制是捕获ping的报文,然后再进行匹配以获取数据 function _ping(ping, host)
local data = nil
if is_host("windows") then
data = try { function () return os.iorun("%s -n 1 -w 1000 %s", ping.program, host) end }
elseif is_host("macosx") then
data = try { function () return os.iorun("%s -c 1 -t 1 %s", ping.program, host) end }
else
data = try { function () return os.iorun("%s -c 1 -W 1 %s", ping.program, host) end }
end
local timeval = "65535"
if data then
timeval = data:match("time=([%d%s%.]-)ms", 1, true) or data:match("=([%d%s%.]-)ms TTL", 1, true) or "65535"
end
if timeval then
timeval = tonumber(timeval:trim())
end
return timeval
end 常规模式下,理想报文为: 正在 Ping aoufnebg.dayugslb.com [212.64.63.215] 具有 32 字节的数据:
来自 212.64.63.215 的回复: 字节=32 时间=33ms TTL=52
212.64.63.215 的 Ping 统计信息:
数据包: 已发送 = 1,已接收 = 1,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 33ms,最长 = 33ms,平均 = 33ms 但是在局域网部署的镜像服务器中,ping是这样的: 正在 Ping github.com [198.18.0.11] 具有 32 字节的数据:
来自 198.18.0.11 的回复: 字节=32 时间<1ms TTL=64
198.18.0.11 的 Ping 统计信息:
数据包: 已发送 = 1,已接收 = 1,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms 问题来了,由于时间过短,为 |
Beta Was this translation helpful? Give feedback.
Answered by
waruqi
Dec 12, 2022
Replies: 1 comment 1 reply
-
改了下,再试试,xmake update -s dev |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
xqyjlj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
改了下,再试试,xmake update -s dev