Master the fundamental concepts of raw sockets through this focused micro-challenge.
Ping sends an ICMP Echo Request (type 8, code 0) and waits for an Echo Reply (type 0, code 0). ICMP sits on IP (protocol 1) with no port numbers. For example, a request to 8.8.8.8 might carry identifier 0x1234 and sequence 1 in the echo header fields.
The ICMP header fields you must set:
8 (ICMP_ECHO)0getpid() & 0xFFFFcLoading…
socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) lets you craft the ICMP payload while the kernel builds the IP header. Raw sockets require root or CAP_NET_RAW. A wrong checksum means the receiver silently discards the packet.
This task asks you to construct and print every ICMP field for a raw echo request. iputils' ping.c does exactly this on Linux, and you will reuse the same checksum logic for traceroute later in the track. nmap's -PE host discovery and many CTF challenges depend on crafting a byte-perfect ICMP echo that a real kernel will accept and reply to.
Implement a C program that documents raw ICMP echo request construction.
Requirements:
Success Criteria:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github