TCP checksums are evaluated by attaching a pseudo header in the start of the TCP segment which u are going to be sent. Actually that pseudo header is like this... struct pseudohdr { struct in_addr source_address; // 32 bit netid/hostid struct in_addr dest_address; // 32 bit netid/hostid unsigned char place_holder; unsigned char protocol; unsigned short length; struct tcphdr tcp; } phdr; where the protocol is IPPROTO_TCP , place holder is zero and length is htons(sizeof(struct tcphdr)); After this u can directly compute this checksum by of this function which does exactly as what has been explained in comer or anyother book (e.g W.R.Stevens) int in_chksum(u_short *ptr, int nbytes) // where ptr is the pointer to the tcp segment prefixed // with pseudo header and nbytes is // sizeof(tcpsegment+pseudoheader); by tcpsegment I // mean tcpdata + tcpheader; { long sum; u_short oddbyte; // 16 bit u_short answer; sum=0; while(nbytes > 1) { sum += *ptr++; nbytes -= 2; } if (nbytes == 1) { oddbyte = 0; *((u_char *)&oddbyte) = *(u_char *)ptr; sum+= oddbyte; } sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); answer =~sum; return(answer); } --- Bill Geissler <billgeissler@yahoo.com> wrote: > > How is the checksum for the data field in a TCP > packet > computed, and how is that checksum incorporated into > the checksum field in the TCP header? > > I see a number of checksum routines, and, frankly, > I'm > getting confused. > > Any help would be appreciated. > > Bill > > __________________________________________________ > Do You Yahoo!? > Yahoo! Auctions - buy the things you want at great > prices > http://auctions.yahoo.com/ > - > : send the line > "unsubscribe linux-net" in > the body of a message to majordomo@vger.kernel.org __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org