异步 icmp ping 问题
我正在用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能遇到的问题是由于 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.