Raw Sockets and IP Datagrams

James Pinakis jamesp at wacsvax.uwa.oz
Thu Jun 7 15:08:37 AEST 1990


I'm trying to write programs which communicate via IP datagrams using the
raw socket interface in SunOS 4.0.3.  I was initially somewhat confused by the
difference between sending a receiving a datagram i.e. when I do a 'sendto' on
the raw socket I provide it with the data part of the datagram but when I do a
'recvfrom' I am provided the whole datagram including the header.  Upon
close inspection of the ip(4p) man page I found this to be as it should.
Now I find that in received datagrams, the TOTAL LENGTH field contains only
the length of the data part and does not include the length of the header
as specified in the RFC.  Also, it appears the HEADER CHECKSUM contains
zero.  Obviously the IP layer is changing these fields, but this isn't
mentioned in the manual entry (which in fact says "Received datagrams are
returned with the IP header and options intact").  Is this normal behaviour or
am I experiencing something peculiar? Are there any other pitfalls to be wary
of when using raw sockets?  There seems to be a dearth of documentation in
this area.

james
jamesp at bison.cs.uwa.oz.au



More information about the Comp.unix.wizards mailing list