From owner-freebsd-net Wed Nov 15 6:27: 3 2000 Delivered-To: freebsd-net@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 12CE637B479 for ; Wed, 15 Nov 2000 06:26:53 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.0/8.11.0) id eAFEQFr03423; Wed, 15 Nov 2000 16:26:15 +0200 (EET) (envelope-from ru) Date: Wed, 15 Nov 2000 16:26:15 +0200 From: Ruslan Ermilov To: Julian Elischer Cc: Charles Mott , Archie Cobbs , net@FreeBSD.ORG, Ari Suutari Subject: Re: libalias: Incremental Update of Internet Checksum Message-ID: <20001115162615.A3145@sunbay.com> Mail-Followup-To: Julian Elischer , Charles Mott , Archie Cobbs , net@FreeBSD.ORG, Ari Suutari References: <20001113103852.E34671@sunbay.com> <3A126F63.8EB0D49@elischer.org> <20001115150433.A98014@sunbay.com> <3A1295DE.6930D125@elischer.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3A1295DE.6930D125@elischer.org>; from julian@elischer.org on Wed, Nov 15, 2000 at 05:55:42AM -0800 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Wed, Nov 15, 2000 at 05:55:42AM -0800, Julian Elischer wrote: > Ruslan Ermilov wrote: > > > > On Wed, Nov 15, 2000 at 03:11:31AM -0800, Julian Elischer wrote: > > > Ruslan Ermilov wrote: > > > > > > > Here's the version I wrote some years ago.. > > > > > > #define FIXSUM16(c, op, np) \ > > > do { \ > > > (c) -= (u_int16_t) ~*((u_int16_t *) (op)); \ > > > if ((c) < 0) { \ > > > (c) += 0xffff; \ > > > } \ > > > (c) -= (u_int16_t) *((u_int16_t *) (np)); \ > > > if ((c) < 0) { \ > > > (c) += 0xffff; \ > > > } \ > > > } while (0) > > > > > > it replaces the 16 bit word at *op with the new value at *np and updates > > > the checksum c > > > > > The above is the implementation of 4th equation from RFC 1624, right? > > But we are talking about the version that allows updating of N 16-bit > > words, not exactly one word. > > I can't remember which it was, but I also had a version that did N > words.. > the same math applies though.. > you just do it in a loop :-) > > I wrote this myself but read the RFCs > does it pass your test cases? > I will try your one-word version, but it would be really nice if you have found the N-word version, so I could test it further. I am mostly interested in how to convert two's complement subtraction to one's complement subtraction. I went further, and wrote another test program that demonstrates that both implementation for formula 4 I posted at the very beginning, and the current version in libalias(3) produce wrong results in some cases. By "wrong" here I mean really wrong results, not the 0 -> 0xffff case. See my next posting... -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message