Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: Notesfiles $Revision: 1.6.2.17 $; site waltz.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!inuxc!pur-ee!uiucdcs!waltz!lindahl
From: lindahl@waltz.UUCP
Newsgroups: net.lan
Subject: Re: Ethernet CRC calculation/generation
Message-ID: <28400002@waltz.UUCP>
Date: Wed, 2-Jan-85 05:26:00 EST
Article-I.D.: waltz.28400002
Posted: Wed Jan  2 05:26:00 1985
Date-Received: Sat, 5-Jan-85 02:40:35 EST
References: <128@oblio.UUCP>
Lines: 54
Nf-ID: #R:oblio:-12800:waltz:28400002:000:2398
Nf-From: waltz!lindahl    Jan  2 04:26:00 1985


>I am looking for a routine, written in C, that can calculate and/or 
>generate the CRC field of the ethernet packet.  I need this to 
>verify that the hardware is doing it correctly in a 
>diagnostic.  All the mathematical definitions look like
>'greek' to me and I would rather not have to figure it out.
>
>Thanx in advance.

>Monte Pickard
Counterpoint Computers
..!ucbvax!hplabs!oblio!monte
/* ---------- */

Since I don't have my XEROX ETHERNET book handy, I don't remember if 
ETHERNET uses a 16-bit CRC. If it does, however, I can point you to 
an entry in NET.SOURCES which includes a C program. I have included a portion
of the header so you can locate it there. Hope it helps ... (I'll double
check the ETHERNET spec when I get it unpacked -- I moved recently). 

==============================================================================


     The following are translations of byte-wise CRC-16 calculation
     algorithms given the the June 83 issue of IEEE Micro.  Included
     are an on-the-fly 8086 assembler version, a C table driven version
     and a C program to produce the table as well as the table itself.
     I have tested these against each other and am fairly certain they
     work.  If they don't, I apologize now -- please send me your fixes.

;===================================================================
;
; CRC -- calculates CRC checksum on string of bytes
;  on the stack -- length of string, string offset
;  returns -- 16 bit CRC-16 value in AX, BX.
;             other data regs. garbled NOTE IF CI CHANGES C COMPILER
;
; Programmer: Bryan Bingham	8 Nov 1983
; System: CompuPro 8086/8085
;
; This code is intended to be called by a C program compiled with the CI-86
; compiler, the format of the directives is suggested by CI cvtobj document.
; It has no seperate data segment, it uses just registers.  The algorithm
; comes from "Byte-wise CRC Calculations" by Aram Perez, IEEE Micro June
; 1983 pp.40-50 and uses several tricks based on the 8080/8086 design.
; I suggest getting that paper if you want to understand what is happening
; because I did not try to fully document the thing here, and the comments
; here only make sense after you read the paper.
;
; Called from C as crc(buf, strlen(buf));
;===================================================================

------------------------------------------------------------------------