From owner-freebsd-hackers Mon Jan 17 8:39:41 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from whizzo.transsys.com (whizzo.TransSys.COM [144.202.42.10]) by hub.freebsd.org (Postfix) with ESMTP id 32ECB14C89 for ; Mon, 17 Jan 2000 08:39:28 -0800 (PST) (envelope-from louie@whizzo.transsys.com) Received: from whizzo.transsys.com (localhost.transsys.com [127.0.0.1]) by whizzo.transsys.com (8.9.3/8.9.1) with ESMTP id LAA18994; Mon, 17 Jan 2000 11:39:14 -0500 (EST) (envelope-from louie@whizzo.transsys.com) Message-Id: <200001171639.LAA18994@whizzo.transsys.com> X-Mailer: exmh version 2.1.1 10/15/1999 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: inbox/freebsd-hackers To: Charles Youse Cc: freebsd-hackers@FreeBSD.ORG From: "Louis A. Mamakos" Subject: Re: PR kern/15656 References: In-reply-to: Your message of "Mon, 17 Jan 2000 10:37:21 EST." Mime-Version: 1.0 Content-Type: text/plain Date: Mon, 17 Jan 2000 11:39:14 -0500 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > In this PR, regarding IP header checksums, it's stated that a checksum of > 0 is specified by the standard to be transmitted as all-1s (0xFFFF). (A > checksum of all 0s is taken to mean that the transmitting host did not > calculate a checksum.) > > Can anyone find a reference to this in the official docs, or perhaps find > an explanation why we do indeed send 0'ed checksums? I've replicated this > behavior on both 3.4-STABLE and 4.0-CURRENT, i386 and alpha. This behavior is certainly in RFC-791, which describes IP. Note that since the checksum is computed using 1's complement arithmetic, all-1's is a represetation of -0, which has the same arithmetic properties as the encoding of +0. In this application, the +0 encoding denotes "no checksump", which as far as I know, is only an option for the UDP checksum. An excerpt of RFC-791 says: ------------------------------------------------------------------------ Header Checksum: 16 bits A checksum on the header only. Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed. The checksum algorithm is: The checksum field is the 16 bit one's complement of the one's complement sum of all 16 bit words in the header. For purposes of computing the checksum, the value of the checksum field is zero. This is a simple to compute checksum and experimental evidence indicates it is adequate, but it is provisional and may be replaced by a CRC procedure, depending on further experience. ------------------------------------------------------------------------ So, if you implemented as it is described, computing a sum of the packet contents who's result is 0x0000 would then be complemented to 0xFFFF for inclusion in the packet header. A one's complement sum of values who's value is zero should always produce a +0 (all zero bits) rather than a -0 (all one bits), At least all right-thinking 1's complement hardware of the era (DEC, UNIVAC, etc) worked that way. louie To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message