In order to create the complete IP packet (including the header), we use a socket option:
char on = 1; setsockopt(s, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on));From now, the kernel expects us to supply a complete IP packet. Originally written by guy keren