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));