为了编写程序,我需要知道ping命令是如何工作的。
我想知道的是,如果执行ping -c1 "something“命令,会创建多少个ipv4数据包和以太网帧?考虑到每个缓存都是空的
谢谢..
发布于 2018-05-09 06:51:57
ping命令使用ICMP数据包。要编写ping命令代码,您需要能够发送和接收ICMP数据包。
在windows中,这是使用winsock raw socket support完成的。这是一个使用原始套接字的ping的example。
在Linux中,您只需要套接字支持。这是一个关于如何在Linux中处理ICMP数据包的堆栈溢出question。
或者,您可以找到一个为您实现此功能的库。
发布于 2020-09-30 01:39:29
Reply from 192.168.2.10: bytes=32 time<1ms TTL=128 - **Computer is on OS kernel still in memory**
Request timed out. - **OS is shutdown/Firewall blocking ICMP**
Reply from 192.168.2.10: Destination host unreachable. - **Computer powered off. Physical network active**这里解释了用于排除故障的ping命令
https://stackoverflow.com/questions/50243139
复制相似问题