0

I am learning datalink raw socket programming on Linux, and I found these helpful examples. I compiled the icmp4_ll.c, and used it to send an ICMP packet to anther computer in the same LAN. I can receive the reply from the destination computer. However, when I used it to send an ICMP packet to the local computer, that is, I set the source and destination Ethernet MAC and IP addresses to the MAC and IP address of eth0, I cannot receive the ICMP reply on either eth0 or lo interface (In Wireshark, I only noticed the ICMP request sent over eth0, but no ICMP reply on any interface.) I think the ICMP request message is composed correctly, (otherwise the remote destination wont reply). But I don't know why the OS just doesn't reply the request. Any help or hints are appreciated.

user2975098
  • 115
  • 1
  • 7
  • If you don't get a reply, the echo request is either wrong, or there's something blocking the reply elsewhere. – nos Nov 22 '13 at 23:01
  • I was thinking this possibility, but when the same program is used to send an ICMP request to a remote computer, I can see the reply form that remote computer. The reply is missing only when the program is used to send a request to the local interface. – user2975098 Nov 25 '13 at 17:35

1 Answers1

0

RFC 792 defined special conditions for the ICMP messages:

  • No ICMP error messages are sent in response to ICMP error messages to avoid infinite repetition.

  • For fragmented IP datagrams, ICMP messages are only sent for errors on fragmented zero (the first fragment).

  • ICMP error messages are never sent in response to a datagram that is destined to a broadcast or a multicast address.

  • ICMP error messages are never sent in response to a datagram sent as a link layer broadcast.

  • ICMP error messages are never sent in response to a datagram whose source address does not represents a unique host (the source address cannot be zero, a loopback address, a broadcast address or a multicast address).

  • ICMP error messages are never sent in response to an IGMP message of any kind. When an ICMP message of unknown type is received, it must be silently discarded.

Routers will almost always generate ICMP messages but when it comes to a destination host, the number of ICMP messages generated is implementation dependent.

Michał
  • 2,456
  • 4
  • 26
  • 33
karthik manchala
  • 13,492
  • 1
  • 31
  • 55