Subject: RAW sockets problems: RFC
To: Tech Net <>
From: Bryan J. Phillippe \(spamblock\) <>
List: tech-net
Date: 11/13/2002 13:35:40

I am currently writing a packet test utility which allows command-line
parameters to be used to specify fields of IP/TCP/UDP/ICMP/etc protocol
headers.  I am using the following sockets calls to access the sockets

setsockopt(s, SOL_SOCKET, SO_BROADCAST, yeah) /* do I need this? */
setsockopt(s, IPPROTO_IP, IP_HDRINCL, yeah)

(this appears to be pretty much what libnet does as well)

This works fairly well, however, there are some glitches:

1.) If I _want_ an IP ID of 0, the stack will test for ip_id == 0 and
interpret truth as "I want the stack to use the next natural IP ID".

2.) If I _want_ a source address of, a similar replacement is done
using the outgoing interface address.

2.1.) Due to the above, the checksum I generate for a TCP/UDP packet (for
example) will be wrong.

3.) The ip header checksum is always calculated by the stack, meaning I
can't force a bad one.

4.) I can't set a bogus value for ip_len.

Is there another socket type I can use to accomplish these goals, or should
I experiment with adding another socket option which means "use the header

Thanks for any suggestions,
# bryan_at_darkforest_dot_org
# Software Engineer