You can get statistics about protocol stacks icmp, udp, tcp, ip from the file
Every new packet which sent or received increments related counters here. You can learn a lot of information for icmp stack like received message count, received errors, received checksum errors etc.
You may get a hint about your icmp packet loss from
But there is another file which is probably main reason for your packet loss:
Value in this file controls maximum rate at which the kernel generates icmp messages of the types specified by icmp_ratemask. The value is the number of jiffies the kernel has to wait between sending two such messages. Therefore zero means no limit. It is used with
icmp_ratemask value which gives you an option to select rate limit calculation on which icmp types. So, it is good to disable rate limiting and test your program again like below:
echo 0 > /proc/sys/net/ipv4/icmp_ratelimit