I am learning about the ping implementation in C. The problem is, I was using a raw sockets to receive the packet. For all packets we have a identification value in ICMP header.

I was running the ping in multiple terminal.

For example, I was running three ping google.com in three terminals.

For the first ping the identification value is 23456, the second ping identification value is 34564, and the third ping identification value is 98763.

My problem is the second ping have to receives the identification with 34564 packet, but it receives the identification value as 23456.

For each ping the new raw socket is creating. But it receives another ping packet.

Can anyone please explain me, why it receives another ping packet ?


Basically, the raw socket will capture all ICMP packets. The internal number you quote is exactly to identify packets from the current process. There's no port number in ICMP to allow per-socket demultiplexing by the protocol stack.

To answer your comment, if the packet has been received, it hasn't been lost, has it? All sockets set up like ping does get copies of all matching packets, so all running pings get copies of all received ICMP packets.

  • If it receives another ping packet, then that packet is gets lost or not ?
    – user152030
    May 5 '16 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy