Raw Sockets and IP Datagrams
Abhijit Khale
akhale at chamomile.uucp
Fri Jun 8 13:21:55 AEST 1990
In article <jamesp.644735317 at bison> jamesp at wacsvax.uwa.oz (James Pinakis) writes:
>I'm trying to write programs which communicate via IP datagrams using the
>raw socket interface in SunOS 4.0.3. .
>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.
Yes. What happens is : the ipintr() [IP input] routines subtract the header length
from the total length field before switching the packet up to the higher layer
protocol (normally tcp or udp). In the case of a raw socket it just gets
handed to the raw socket processing routines which eventually pass it up to the
user process.
> Also, it appears the HEADER CHECKSUM contains
>zero.
In 4.0.3, thats what will happen.
In 4.1, you should get the correct header checksum provided the
packet hasnt been fragmented and reassembled.
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?
This is "normal". However, there seems to be
no reason why the total length field should be changed for a raw IP socket.
That should probably be regarded as a bug. Its less clear whether the
checksum should be passed up as is [ There doesnt seem to be any reason
why the checksum should be recomputed for a fragmented/reassembled packet].
Now if you really want raw packets, use NIT :-)
Abhijit Khale akhale at parc.xerox.com akhale at jerico.usc.edu
Computer Science Lab, Xerox PARC University of Southern California
More information about the Comp.unix.wizards
mailing list