From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1437 invoked by alias); 30 Oct 2007 03:02:40 -0000 Received: (qmail 1377 invoked by uid 22791); 30 Oct 2007 03:02:38 -0000 X-Spam-Check-By: sourceware.org Received: from londo.lunn.ch (HELO londo.lunn.ch) (80.238.139.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 30 Oct 2007 03:02:35 +0000 Received: from lunn by londo.lunn.ch with local (Exim 3.36 #1 (Debian)) id 1ImhN4-00068t-00; Tue, 30 Oct 2007 04:02:26 +0100 Date: Tue, 30 Oct 2007 03:02:00 -0000 From: Andrew Lunn To: ariga masahiro Cc: ecos-discuss@ecos.sourceware.org Message-ID: <20071030030226.GC16889@lunn.ch> Mail-Followup-To: ariga masahiro , ecos-discuss@ecos.sourceware.org References: <001301c81091$1d11b060$1c0110ac@ariga> <4715F2D0.7080704@mlbassoc.com> <000c01c81151$9add59c0$1c0110ac@ariga> <47173F99.80405@mlbassoc.com> <000601c8120c$667aa3c0$1c0110ac@ariga> <47187EEB.5020109@mlbassoc.com> <000501c8154d$ecc04db0$1c0110ac@ariga> <000301c816ab$6acbf7f0$1c0110ac@ariga> <000a01c81a9e$6b8c2240$1c0110ac@ariga> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000a01c81a9e$6b8c2240$1c0110ac@ariga> User-Agent: Mutt/1.5.16 (2007-06-11) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] Can't Connect,TCP CHECKSUM INCORRECT X-SW-Source: 2007-10/txt/msg00146.txt.bz2 On Tue, Oct 30, 2007 at 11:41:48AM +0900, ariga masahiro wrote: > Hello, > > I am the same person who sent the mailing list titled > "What functions should I call in ethernet drv ?". > At that time I was helped by your advices. > I was very much obliged. > > I am sorry to say that I am encountered another trouble > and I ask you again your help. > > Since then I continued to test transmission between host and target. > host(Client) : 172.16.1.28 : nc_test_master > target(Server): 172.16.1.200 : nc_test_slave > > UDP packets look like correctly transmitted between both terminals. > > But when host tries to connect to target in TCP, > always happens connection error(timeout). > Below is host's output on cygwin shell. > > $ ./nc_test_master.exe 172.16.1.200 > Start Network Characterization - MASTER > ================== No load, master at 100% ======================== > Start TCP echo [64,10240] - no delays > Can't connect to slave: Connection refused > Can't connect to slave: Connection refused > Can't connect to slave: Connection refused > > I sent also Etherreal packets captutre log file(text-gz format). > \TCP-checksum-log\DEBUG-00-prescale-20\EtherReal-log-txt\etherreal-TCP-2.txt > DEBUG=00,CYGHWR_HAL_SH_RTC_PRESCALE=20(CYGNUM_HAL_RTC_PERIOD=14745) >> From here on,I refer to this file as er.txt. > > When host send SYN packet to target(er.txt,line 89), > target tried to reply SYN-ACK but resulted [CHECKSUM INCORRECT]. > Target's TCP packets almost always [CHECKSUM INCORRECT]. > I also noticed Seq, Ack,and Win numbers all suspicious. > When Ack-number looks proper,CHECKSUM INCORRECT not occurs, but never > connected. > > I traced TCP checksum routine,and I am not sure they are correct. > I set break at 735 line in tcp_output() function in > packages\net\bsd_tcpip\current\src\sys\netinet\tcp_output.c > > 730: #endif /* INET6 */ > 731: { > 732: m->m_pkthdr.csum_flags = CSUM_TCP; > 733: m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); > 734: if (len + optlen) > 735: th->th_sum = in_addword(th->th_sum, > 736: htons((u_short)(optlen + len))); > Then jumped to > packages\net\bsd_tcpip\current\src\sys\netinet\in_cksum.c(200): > in_addword(u_short a, u_short b) > > 199: u_short > 200: in_addword(u_short a, u_short b) > 201: { > 202: u_int32_t sum = a + b; > 203: > 204: ADDCARRY(sum); > 205: return (sum); > 206: } > > ADDCARRY is defined as below in in_cksum.c(76) > > #define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) > > Now this looks not doing one's complement sum for me. > Is this really correct function ? Something to consider. This code works for many people on lots of differ net hardware, big endian and little endian. This is also taken directly from FreeBSD which has many more uses than eCos. So it is very unlikely to be a bug in something like this. It is much more likely you have a configuration problem for your hardware or a bug in your new code for the hardware dependant part of the device driver. > Our most serious concern is, my concoction in driver source to accommodate > to target's hardware pecuriality > is affecting those misbehaviour. > As I said in last mail, our company's target board was hardware wired to > retreive data in BigEndian. What is probably a better idea is to get your hardware engineer to fix your board so the ethernet device is using the correct endianness. This should not be too hard, maybe replace a pull up resister with a patch wire to ground etc... Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss