В "Network Programming for Microsoft Windows" Anthony Jones, Jim
Ohlund сказано:
The one limitation of raw sockets is that you can work only with
certain protocols that are already defined, such as ICMP and IGMP. You
cannot create a raw socket with IPPROTO_UDP and manipulate the UDP
header; likewise with TCP. To manipulate the IP header as well as
either the TCP or UDP header (or any other protocol encapsulated in
IP), you must use the IP_HDRINCL socket option with a raw socket. This
option allows you to build your own IP header as well as the headers
of other protocols.
Но на практике можно обойтись и без IP_HDRINCL, т.е. следующая
программа нормально работает на локальной машине: