1

I've been learning about TCP and UDP lately, and I know that ping uses ICMP so I'm trying to understand that too. My understanding is that when the command ping google.com is run, your computer sends an echo request ICMP packet over IP to google, and then google responds with an echo reply message.

My question is, when a server responds with that echo reply message, what is actually taking care of that? Is it the operating system? Is it a particular application? Or is it something else entirely?

Christopher Shroba
  • 7,006
  • 8
  • 40
  • 68

2 Answers2

2

Its the Kernel module which responds the ICMP requests. The ICMPv4 module is net/ipv4/icmp.c.

The ICMP module defines a table of array on how to handle various ICMP requests with object being icmp_objects, named icmp_pointers which is indexed by ICMP message type.

ICMP control structure:

struct icmp_control {
  void (*handler)(struct sk_buff *skb);
  short error; /* This ICMP is classed as an error message */
};

static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
...
  [ICMP_ECHO] = {
        .handler = icmp_echo,
  },
...
};   

From above struct, when you send a echo request to google.com server the message type will be icmp_echo boiling down to subroutine call icmp_echo() which handles echo (ping) requests (ICMP_ECHO) by sending echo replies (ICMP_ECHOREPLY) with icmp_reply().

Sunil Bojanapally
  • 12,528
  • 4
  • 33
  • 46
-1

In terms of the TCP/IP reference model it is the Network layer of the protocol stack, which is normally in the kernel.

user207421
  • 305,947
  • 44
  • 307
  • 483