Calculating CheckSum for Raw UDP packet

T

Terry

I'm trying to calculate the checksum for UDP packet. The algorithm itself
is not difficult (lots of examples out there), but what I'm having the most
trouble with is determining the byte order that multibyte values need to be
in. The RFC's for the IP header and UDP protocol do not specify whether the
multibyte values need to be stored in host or network byte order.

Also, the verbage of the description for constructing the pseudoheader used
to calculate the UDP checksum is a bit confusing.

First the IP header. Do "length" and "header checksum" need to be stored in
the IP header in network or host order?

Second, the pseudo UDP header for calculating checksum as specified by RFC
768 (http://www.faqs.org/rfcs/rfc768.html). The way I interpret this is to
take the specified fields from the IP header, to construct a pseudo header.
Then, attach the UDP packet (source and dest port, size, checksum and data)
to the end of this pseudo header and use this entire block to calculate the
checksum. But, one of the fields in the pseudo header is "UDP length". Is
this length the same as the length used in the IP header or the length of
the "pseudo header" and UDP header and data?

After checksums are calculated, are they supposed to be stored in network or
host byte order?

Thanks,
Terry
 
T

Terry

Nevermind. I got this figured out. "C# Network Programming" by Richard
Blum is an awesome book! I love it. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top