cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2938
Views
0
Helpful
3
Replies

UDP checksum : does it include the length?

Kevin Dorrell
Level 10
Level 10

This question does not fit in any forum section because it is on general networking theory.

The UDP checksum covers the UDP/IP pseudo-header, the UDP header, and the user data padded to a 16-bit boundary. The UDP/IP pseudo-header includes the UDP length. The UDP header also includes the UDP length. The checksum is a 16-bit 1's complement.

Does that mean that the UDP length is effectively not included in the checksum calculation?

The other strange thing about the UDP checksum is that according to the RFC, it is optional. Is this so in real life?

Kevin Dorrell

Luxembourg

3 Replies 3

Harold Ritter
Spotlight
Spotlight

I don't think this prevents any way the validation of the udp length correctness. If the UDP length was changed between the source and destination, the checksum discrenpency would just be double what it would be if we only included the length value once.

As for the RFC saying that the UDP checksum is optional, It seems like an RFC compliant stack would not perform checksum validation against a udp packet with a checksum value of all zero.

Hope this helps,

Regards,
Harold Ritter, CCIE #4168 (EI, SP)

Harold,

At first sight, I didn't agree with you about " ... If the UDP length was changed between the source and destination, the checksum discrenpency would just be double what it would be if we only included the length value once. .. ". I reasoned like this: the checksum is a 1's complement, so if you include a field twice in the calculation, the net effect of the field is zero. So you can change the field as much as you like, and it wouldn't make a ha'p'orth of difference.

This is what I think now: as far as the transmitter is concerned, the two fields (real and pseudo) come from the same place: the length of the user datagram data. But as far as the receiver is concerned, they come from different places: the real field from the UDP header is explicit, and the pseudo field is calculated from the IP packet length (IP octets 2+3), minus 4 * IP-HLEN. So if you wanted to fiddle the UDP length, you would also have to fiddle the IP header octets 2+3, and therefore also IP header octets 10+11, and therefore also ....

I suppose this hinges on how the UDP header checksum algorithm is implemented in the receiver. If it does it the lazy way, and constructs the pseudo-header using the length explicitly declared in the UDP header, then there is no check on the length at all. If it calculates it from the IP header, then the UDP length is validated. So I can only speculate whether this is a potential problem.

Thanks for your thoughts.

Kevin Dorrell

Luxembourg

I'm five years too late, but maybe a reply will be worth it for anyone else who stumbles onto this thread.

A quick example shows that two length fields don't cancel each other out.  Make the (unrealistic, but good enough) assumption that all pseudoheader fields are 0, besides the length fields, which are 8.  Do the one's complement sum over this pseudoheader, and you'll get 16.  If both the length fields were 9, you'd get 18.

I think you may be confused about what a one's complement sum is.  This Wikipedia page explains.

Neal