views:

231

answers:

1

i am using raw sockets to create my own socket. i need to set the tcp_checksum.
i have tried a lot of references but all are not working (i am using wireshark for testing).
could you help me please.
by the way, i read somewhere that if you set tcp_checksum=0. then the hardware will calculate the checksum automatically for you. is this true? i tried it, but in wireshark the tcp_checksum gives a value of 0X000 and says tcp offload. i also read about tcp offloading, and didn't understand, is it only that wireshark cannot check an offloaded tcp checksum, but there is a correct one??

EDIT: i realized that if you set tcpChecksum to 0, then the network card will set it and not the operating system. i was testing using wireshark and a virtual machine, so this explains why the checksum is 0x000 (since the packet is not even passing to the network card.)
but i am still curious about calculating the tcp_checksum manually... any help or links?

+2  A: 

This article tries to explain how it's done.

Another place worth taking a look at is for Linux kernel sources, start from the file net/ipv4/tcp__ipv4.c

Kimvais
The Linux is a great source of knowledge for this type of information. Also look into the specs for TCP http://www.rfc-editor.org/rfc/rfc793.txt
Rickard von Essen
Good point about the RFC (how come I forgot it this time) - one thing however - the tools.ietf.org HTML pages are much nicer place to read them on: http://tools.ietf.org/html/rfc793#section-3.1
Kimvais