[e2e] UDP length field

Bill Sommerfeld sommerfeld at orchard.arlington.ma.us
Wed Apr 11 11:02:26 PDT 2001


> 	Why does UDP have a length field?

Same reason tcp does: to preserve an end-to-end length in the presence
of fragmentation.

The ip packet length is the length of a particular fragment, and may
have been set by a router which fragmented the packet.

The udp length appears only in the first fragment and describes the
fully assembled datagram.

> Finally, the RFCs seem silent on the following question:
> 
> 	What should an end-receiver do when the lengths mismatch?  Is
> this up to the implementation?

There's something of a grey area here.

At each layer, you obviously drop a packet if it's shorter than what a
header says it should be.

At the IP layer, you pretty much have to trim the packet if it's
longer than the header length since common lower layers (most notably
ethernet) have relatively large minimum packet sizes.

Once you get into UDP, the implementations I've worked on then compare
the packet's length to the udp header length (and don't look at the ip
header's packet length field length again).  When the packet's too
long for the udp header, some truncate, while others drop.

					- Bill



More information about the end2end-interest mailing list