On 03/13/2013 01:46 PM, Jorgen Grahn wrote:
> On Tue, 2013-03-12, Josef Moellers wrote:
> ...
>> I've found it myself: The TCP header checksum must include parts of the
>> IP Header! Thus, my checksum was bad and the TCP layer discarded the RST
>> packet.
>
> 'tcpdump -v' would have told you this, at least on the side receiving
> the RST. That side would also have recorded a bad checksum discard in
> 'netstat -s'.
I used wireshark, but it only said:
Checksum: 0xf89a [validation disabled]
[Good Checksum: False]
[Bad Checksum: False]
I now (since yesterday afternoon ;-) have Fall/Stevens "TCP/IP
Illustrated 2nd Ed" and it says "The TCP Checksum field covers the TCP
header and data and *some fields in the IP header*, using a
pseudo-header computation ...". I should have taken that more serious
and should have read the RFC more thoroughly. I have added this code
fragement:
checksum = 0;
checksum = update_checksum(checksum, my_IP[0], my_IP[1]);
checksum = update_checksum(checksum, my_IP[2], my_IP[3]);
checksum = update_checksum(checksum, source_IP[0], source_IP[1]);
checksum = update_checksum(checksum, source_IP[2], source_IP[3]);
checksum = update_checksum(checksum, hi8(PROT_TCP), lo8(PROT_TCP));
checksum = update_checksum(checksum, hi8(5*4), lo8(5*4));
setup_TCP_header(destination_port, /* Source Port */
source_port, /* Destination Port */
acknowledgement_number, /* Sequence Number */
sequence_number, /* Acknowledgement Number */
RST | ACK, /* Flags */
checksum); /* No data */
-eoc-
I'll keep "tcpdump" in mind and use it when I take the next steps:
connection establishment and then data transfers. I gather that
maintaining the sequence numbers (seq and ack) will be tricky.
Thanks again,
Josef