TCP checksum

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I'm developing my own TCP stack for ATMEGA32 and I'm having a problem with calculating the TCP checksum. According to the information I gathered from the internet, the TCP checksum is calculated based on the IP pseudoheader (that is source IP, destination IP, protocol (0x06 for TCP) and overall packet length) and complete TCP header together with data to be sent. The checksum is one's complement of sum of all 16-bit words. I'm almost sure it is calculated correctly as it works ok for
the IP header. Do you have any suggestions on what can I be doing wrong? Do I have to convert all header data to network byte order before calculating the checksum (I'm doing it this way now)?

Thanks in advance

Chris

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not really any need to guess is there? Just read about it
http://www.faqs.org/rfcs/rfc1071.html
or find some implementation to look at.
/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Google "ethernut" which will lead you to an AVR implementation of TCP/IP then nick their checksum routine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem was with the data order:) - I failed to convert one of the header fields to network byte order. Thanks for your hints. A calculator seems to be the best tool in cases like this:)