异步 icmp ping 问题

发布于 2024-08-23 00:49:36 字数 169 浏览 5 评论 0原文

我正在用 python 编写异步 ping 域的服务。所以它必须能够同时 ping 多个 ip。我在 epoll ioloop 上写的,但是有丢包的问题。 当同时存在许多 ICMP 请求时,大部分回复都没有到达我的服务。是什么可能导致这种情况以及如何使我的服务同时 ping 许多主机而不丢失数据包?

谢谢)

I'm writing service in python that async ping domains. So it must be able to ping many ip's at the same time. I wrote it on epoll ioloop, but have problem with packets loss.
When there are many simultaneous ICMP requests much part of replies on them didn't reach my servise. What may cause this situation and how i can make my service ping many hosts at the same time without packet loss?

Thanks)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野生奥特曼 2024-08-30 00:49:36

您可能遇到的问题是由于 ICMP 是 OSI 模型的第 3 层并且不使用端口进行通信。简而言之,ICMP 并不是为此而设计的。期望的行为仍然是可能的,但也许您正在使用的 IP 堆栈会妨碍,如果这是在 Windows 系统上,那么 100% 肯定这是您的问题。我会启动 Wireshark 以确保您确实收到传入数据包,如果是这种情况,那么我会使用 libpcap 来跟踪 ICMP 回复。如果问题出在发送上,那么您将不得不使用原始套接字并构建自己的 ICMP 数据包。

A problem you might be having is due to the fact that ICMP is layer 3 of the OSI model and does not use a port for communication. In short, ICMP isn't really designed for this. The desired behavior is still possible but perhaps the IP Stack you are using is getting in the way and if this is on a Windows system then 100% sure this is your problem. I would fire up Wireshark to make sure you are actually getting incoming packets, if this is the case then I would use libpcap to track in ICMP replies. If the problem is with sending then you'll have to use raw sockets and build your own ICMP packets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文