UDP checksum inconsistency between sender and receiver

1

I want to write a program to generate udp checksum.

to validate my progra, I need some real data. I send a udp packet from one machine to another machine, the packet can be correctly received by the udp server. I captured the packet using tcp dump on both machines

from the udp client machine, the udp packet and pseudo IPV4 header bytes are(HEX format):

pseudo header
src dst ip:    8a60c948 8a60c96d
proto_num len: 0011 0016

UDP header:    83d87d000016 a79e 
      data:    49276d206e6f 742068657265210a

on the udp server machine(receiver):

pseudo header
src dst ip:        8a60c948 8a60c96d
proto_num and len: 0011 0016

UDP header:        83d87d000016 c2c5 
      data:        49276d206e6f 742068657265210a

the checksum should be calculated over

8a60c9488a60c96d0011001683d87d000016000049276d206e6f742068657265210a

where the checksum field is replaced by 0x0000

but we see that the checksum is changed from 0xa79e on the client to 0xc2c5 on the server side. why this change happens? and which is the correct udp header checksum? thanks!

user138126

Posted 2013-03-19T13:45:16.790

Reputation: 215

yes, they are in the same LAN. if they are not in the same LAN, why it is correct? – user138126 – 2013-03-19T13:52:01.167

Did you hear the joke about UDP? Nevermind, you wouldn't get it... :P – Canadian Luke – 2013-05-02T18:58:05.567

Answers

2

Some Network Interface Cards (NIC) will "help" you by changing the checksum for you. It is called "Checksum Offloading". A search on that term will help.

kmort

Posted 2013-03-19T13:45:16.790

Reputation: 1 609

but the problem is NIC just does the work instead of CPU, it doesn't change the calculation algorithm. So, the same data should deliver the same checksum, am I right? – user138126 – 2013-03-19T13:59:54.777

1ah, OK, the kernel just gives a dirty number on the packet before it sends the checksum to the NIC. – user138126 – 2013-03-19T14:56:01.523

0

Try using "tcpdump -K" or similar per your tcpdump man page:

-K            Don't attempt to verify IP, TCP, or UDP checksums.  This is use-
              ful for interfaces that perform some or all  of  those  checksum
              calculation  in  hardware; otherwise, all outgoing TCP checksums
              will be flagged as bad.

Nevin Williams

Posted 2013-03-19T13:45:16.790

Reputation: 3 725

0

I catch udp check sum in sender and receiver machine with netfilter in layer3. In side sender, udp checksum doesn't include payload data. In side receiver, udp checksum include payload data. This is reason why udp checksum inconsistency.

xuan11290

Posted 2013-03-19T13:45:16.790

Reputation: 1