From owner-freebsd-net Wed Sep 11 11:14:54 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EC7D837B400 for ; Wed, 11 Sep 2002 11:14:49 -0700 (PDT) Received: from smtpout.mac.com (smtpout.mac.com [204.179.120.89]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8DF1B43E6A for ; Wed, 11 Sep 2002 11:14:49 -0700 (PDT) (envelope-from justin@mac.com) Received: from smtp-relay03.mac.com (smtp-relay03-en1 [10.13.10.222]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id g8BIEnKw002502 for ; Wed, 11 Sep 2002 11:14:49 -0700 (PDT) Received: from asmtp01.mac.com (asmtp01-qfe3 [10.13.10.65]) by smtp-relay03.mac.com (8.12.1/8.12.1/1.0) with ESMTP id g8BIEmKN016674 for ; Wed, 11 Sep 2002 11:14:48 -0700 (PDT) Received: from grinch ([12.234.224.67]) by asmtp01.mac.com (Netscape Messaging Server 4.15) with ESMTP id H2ADCN00.GOG for ; Wed, 11 Sep 2002 11:14:47 -0700 Date: Wed, 11 Sep 2002 11:14:46 -0700 Subject: Re: computing the Ack Seq. No. Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v482) From: "Justin C. Walker" To: net@FreeBSD.ORG Content-Transfer-Encoding: 7bit In-Reply-To: <200209111750.g8BHoBZf032104@vashon.polstra.com> Message-Id: <5A3F3774-C5B2-11D6-A7E3-00306544D642@mac.com> X-Mailer: Apple Mail (2.482) Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Wednesday, September 11, 2002, at 10:50 AM, John Polstra wrote: > In article , > soheil h wrote: >> hi list >> I wrote the code below and it doesn't work correctly >> please tell me what is wrong >> int len, tlen; >> tcpiphdr ti, ti_send; >> int hlen; >> int acklen; >> /* >> the hlen is ip header hlen >> */ >> .... >> /* the ip->ip_len is ntohs'ed by NTOHS in io_input() */ >> len = ti->ti_len; >> tlen = ti->ti_off << 2; >> acklen = len - hlen - tlen; >> ti_send->ti_ack = htonl(ntohl(ti->ti_seq) + acklen ); >> /* this field is incorrect and i don't know why */ > > If the TH_SYN flag is set in the received packet, you must increment > the ack by 1. Likewise, if the TH_FIN flag is set, you must increment > the ack by 1. In other words, each of those flags counts the same as > a byte of data, as far as the ack calculation is concerned. Also, it's not clear to me why you include the IP header length in the count of acknowledged TCP bytes. Perhaps I missunderstand your code... Regards, Justin -- Justin C. Walker, Curmudgeon-At-Large * Institute for General Semantics | When LuteFisk is outlawed | Only outlaws will have | LuteFisk *--------------------------------------*-------------------------------* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message