473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Calculating CheckSum for Raw UDP packet

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
Nov 15 '05 #1
1 12113
Nevermind. I got this figured out. "C# Network Programming" by Richard
Blum is an awesome book! I love it. :-)
"Terry" <ch**********@hotmail.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Astroman | last post by:
Hi guys and girls. This is my first time posting here so go easy :) . I was wondering if someone could please interpret how this csum() function works in the following C code. I know that the...
15
by: ValK | last post by:
Hello, Iā€™m working with handheld device that communicates with windows service thru the serial port. Transaction between device and my application looks like this: Handshaking: Device sends ...
3
by: Protoman | last post by:
How would I make a program to calculate a checksum? I have the code to sum up the digits, but what then? Here's the digit summer: template <unsigned int I> int SumDigits() {...
2
by: rdherric | last post by:
Hello -- I have code that sends an SNMP packet using the Socket.SendTo method. When we sniff the packets using Ethereal, the UDP header checksum appears to be all right, but the IP header...
0
by: bndifek | last post by:
Hi I have a problem with raw socket. I want send SYN packet but I have a problem with checksum. When I send the packet to second komputer I see it in ethereal on the second computer( on the close...
1
by: Alex | last post by:
Hi, Is there anyway to calculate a checksum (MD5, CRC32, etc) of files using VB2005? What we need is a simple program that can go through a directory and store the path and file name, checksum,...
5
by: =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?= | last post by:
Hi, how can I calculate the checksum (CRC-16) from the byte I retrieve from a hardware device through the RS232 serial port? Christian
2
by: alvinlim | last post by:
Hi, is anyone who can help me with my program? which i'm trying to calculate the checksum of the data packet 01 01 01 00 00 that is total of 5 bytes. My program is as below Option Explicit Dim i...
3
by: Adriano | last post by:
Hello. I have a situation where need to calculate a checksum of some byte array. Here's the sample output from server: 2008-09-30 11:35:00 `SC`00541.00TJ123456PPC 00000000DLGLGN...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.