Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复ping时统计异常的问题 #385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kelephant
Copy link

【问题】
该IP是可以被ping通的,但是在ping过程中收到无效包,程序并没有再继续等待ping echo,而是继续发送ping req,导致后面回来的ping echo没有被标记为ok
root@localhost:/share/wenqikai# ./ping 5.5.12.101
64 bytes from 5.5.12.101: icmp_seq=1 ttl=64 time=0.5 ms
recv invalid icmp packet!
recv invalid icmp packet!
recv invalid icmp packet!
--- 5.5.12.101 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 1002 ms(--> 收到4个包, 没有丢失,实际上把无效包也统计在内了)
rtt min/avg/max = 0.460/0.460/0.460 ms
ping 4 count, 1 ok.(--> 这里显示只有1个有效包)

【解决方案】
收到无效包时,继续接收ping echo。如1s内未接收不到有效ping echo包,再发送下一个ping req

Update icmp.c
@Kelephant Kelephant changed the title 更新 icmp.c 修复ping时统计异常的问题 May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant