Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
【问题】
该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