Create a simplified reimplementation of the UNIX ping command, which sends ICMP packets to an IP address and measures the response time.

Doing this project to reimplement the ping command in C allowed me to delve into the lower layers of network operation, in particular the ICMP protocol. Unlike using ready-made tools or high-level libraries, here I had to manually build network packets and manage sockets directly

Understanding the ICMP protocol: by constructing the ICMP headers myself (type, code, checksum), I better understood the structure and role of the ECHO_REQUEST and ECHO_REPLY messages.

Finally, this project gave me a better overall understanding of how a system networking tool like ping works, which I’d been using without really knowing the inner workings. It also pushed me to pay attention to important details like memory structures (struct sockaddr_in, struct icmphdr) and respecting packet format so that the kernel can process them correctly.

Screen

Sending a ping packet relies mainly on the struct icmphdr structure, which defines how to construct a valid ICMP message. This is what I used to initialize each packet before sending it via a raw socket.

Screen