From owner-freebsd-net Wed Nov 15 6:36:20 2000 Delivered-To: freebsd-net@freebsd.org Received: from whizzo.transsys.com (whizzo.TransSys.COM [144.202.42.10]) by hub.freebsd.org (Postfix) with ESMTP id E991D37B479; Wed, 15 Nov 2000 06:36:17 -0800 (PST) Received: from whizzo.transsys.com (localhost.transsys.com [127.0.0.1]) by whizzo.transsys.com (8.11.0/8.11.0) with ESMTP id eAFEaHG65417; Wed, 15 Nov 2000 09:36:17 -0500 (EST) (envelope-from louie@whizzo.transsys.com) Message-Id: <200011151436.eAFEaHG65417@whizzo.transsys.com> X-Mailer: exmh version 2.1.1 10/15/1999 To: Ruslan Ermilov Cc: Charles Mott , Archie Cobbs , net@FreeBSD.ORG, Ari Suutari X-Image-URL: http://www.transsys.com/louie/images/louie-mail.jpg From: "Louis A. Mamakos" Subject: Re: libalias: Incremental Update of Internet Checksum References: <200011150315.eAF3FIG60231@whizzo.transsys.com> <20001115100407.D36400@sunbay.com> In-reply-to: Your message of "Wed, 15 Nov 2000 10:04:07 +0200." <20001115100407.D36400@sunbay.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 15 Nov 2000 09:36:17 -0500 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > On Tue, Nov 14, 2000 at 10:15:18PM -0500, Louis A. Mamakos wrote: > > > > Arithmetically, a value of 0xffff is identical to 0x0000 since they > > both represent the value of zero when using a one's complement binary > > representation of values. > > > Except you can't actually receive the value of 0xffff in a checksum field. > One's complement sum is guaranteed to be non-zero except if all items are > zeroes. Since IP Protocol field is a non-zero value that participates in > all checksums (IP, TCP, UDP, ICMP), the checksum value (which is a one's > complement of a one's complement sum) is guaranteed to be non-0xffff. For other than UDP, it really doesn't make a difference if the value of the checksum field is 0x0000 (+0) or 0xffff (-0); they both have the (1's complement arithmetic) value of zero. > > It turns that this property is used in some network protocols (e.g., UDP) > > to distinguish between a checksum value that's computed as zero (represented > > as 0xffff in the packet) from a packet which has no computed checksum at all. > > This was done in the dark ages when it was deemed "too expensive" to > > compute a checksum. > > > >From the above it follows that UDP should better be using 0xffff rather than > 0x0 to indicate that a packet has no computed checksum. It is quite possible > that the computed checksum will have a zero value, in which case the receiving > UDP module will consider such a packet as with no computed checksum, which is > wrong. But the checksum is supposed to be the one's complement of the checksum of the payload (which is computed using one's complement arithmetic). If you compute a checksum, and the value is zero, you insert the complemented value (0xffff) into the packet. louie To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message