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!

2
  • yes, they are in the same LAN. if they are not in the same LAN, why it is correct?
    – user138126
    Mar 19, 2013 at 13:52
  • Did you hear the joke about UDP? Nevermind, you wouldn't get it... :P May 2, 2013 at 18:58

3 Answers 3

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.

2
  • 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
    Mar 19, 2013 at 13:59
  • 1
    ah, OK, the kernel just gives a dirty number on the packet before it sends the checksum to the NIC.
    – user138126
    Mar 19, 2013 at 14:56
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.
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .