Sending A Packet Via The Raw Socket

More include files:
#include <netinet/ip_icmp.h>
And code:
struct icmphdr icmphdr

/* clear out the packet, and fill with contents. */
memset(&icmphdr, 0, sizeof(struct icmphdr));
icmphdr.type = ICMP_ECHO;
icmphdr.un.echo.sequence = 50;  /* just some random number. */
icmphdr.un.echo.id = 48;        /* just some random number. */
icmphdr.checksum =
    in_cksum((unsigned short*)&icmphdr, sizeof(struct icmphdr));
Originally written by Valid HTML 4.01!guy keren