CRC algorithm
11:45:00 PM vikas 0 Comments Category : 'c'/Other Program
WAP in C/C++ to
implement CRC algorithm.
THEORY & CONCEPT-:
A CRC
is an error-detecting code. Its computation
resembles a long division operation in which the quotient is
discarded and the remainder becomes the result, with the important distinction
that the arithmetic used is the carry-less arithmetic of a finite
field. The length of the remainder is always less than or equal to the
length of the divisor, which therefore determines how long the result can be.
The definition of a particular CRC specifies the divisor to be used, among
other things.
Although CRCs can be
constructed using any finite field, all commonly used CRCs employ the finite
field GF(2),
the field of two elements, usually called 0 and 1, comfortably matching
computer architecture. The rest of this article will discuss only these binary
CRCs, but the principles are more general.
An important reason for the
popularity of CRCs for detecting the accidental alteration of data is their
efficiency guarantee. Typically, an n-bit CRC, applied to a data block of
arbitrary length, will detect any single error burst
not longer than n bits (in other words, any single alteration that spans no
more than n bits of the data), and will detect a fraction 1-2-n of
all longer error bursts. Errors in both data transmission channels and magnetic
storage media tend to be distributed non-randomly (i.e. are
"bursty"), making CRCs' properties more useful than alternative
schemes such as multiple parity checks.
The simplest error-detection
system, the parity
bit, is in fact a trivial CRC: it uses the two-bit-long divisor 11.
CRCs are not, by themselves,
suitable for protecting against intentional alteration of data (for example, in
authentication applications for data security), because their convenient
mathematical properties make it easy to compute the CRC adjustment required to
match any given change to the data.
