[net.lan] Ethernet CRC calculation/generation

lindahl@waltz.UUCP (01/02/85)

>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));
;===================================================================

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

darrelj@sdcrdcf.UUCP (Darrel VanBuer) (01/06/85)

Ethernet II uses a 32 bit CRC (the experimental 3 MB Ethernet uses a 16 bit
CRC)
-- 
Darrel J. Van Buer, PhD
System Development Corp.
2500 Colorado Ave
Santa Monica, CA 90406
(213)820-4111 x5449
...{allegra,burdvax,cbosgd,hplabs,ihnp4,orstcs,sdcsvax,ucla-cs,akgua}
                                                            !sdcrdcf!darrelj
VANBUER@USC-ECL.ARPA