You are on page 1of 6

CRC GENERATOR

GROUP MEMBERS:
 IRFAN JUNAID (13005162002)
 KANDUNURU GOWTHAM
(130051601033)
 RAMKUMAR(130051602006)
CRC GENERATOR
 A cyclic redundancy check (CRC) is an error-detecting
code commonly used in digital networks and storage devices to
detect accidental changes to raw data. Blocks of data entering these
systems get a short check value attached, based on the remainder of
a polynomial division of their contents

 On retrieval, the calculation is repeated and, in the event the check


values do not match, corrective action can be taken against data
corruption.

 CRCs are so called because the check (data verification) value is


a redundancy (it expands the message without adding information)
and the algorithm is based on cyclic codes. CRCs are popular
because they are simple to implement in binary hardware, easy to
analyze mathematically, and particularly good at detecting common
errors caused by noise in transmission channels.

 Because the check value has a fixed length, the function that
generates it is occasionally used as a hash function.

 The CRC was invented by W. Wesley Peterson in 1961; the 32-bit


CRC function of Ethernet and many other standards is the work of
several researchers and was published in 1975
Example
WORKING:
 Data is transmitted over imperfect links - errors may occur on the way.
Imagine you want to make sure the received information is the same as the
transmitted one without wasting too much bandwidth, how would you do
that?

 You could transmit every piece of information twice and if on the receiving
end you see that the first one is different to the second one you know an
error has occurred and you need to request the data again - but this would be
very wasteful, it would effectively cut your bandwidth in half.

 Now, what if you could calculate some value that is much smaller than the
data itself yet is depen😂dent on it? So if the data changed along the way
(due to error), the calculated value would no longer "match" the data and
you would know an error has occurred. Is there such a calculation?

 What about simple division and taking a remainder as this value?


 Say I want to transmit an information/number 1,000. I divide it by chosen
number - like 6 for instance ... that gives me 166 and a remainder of 4. I take
the remainder as my check value which is much smaller than the information
I'm actually transmitting so I'm not wasting too much bandwidth and I
transmit 1,000 followed by 4. A receiver gets it, takes the number 1,000
divides it by 6 and if the remainder is 4 then it assumes that no error has
occurred.
 If an error had occurred and it would receive 998 instead of 1,000 due to
error on the link - it would divide it by 6, get a remainder of 2 which does
not match 4 and viola it knows an error has occurred. That is the basic
principle of CRC.
PROGRAM:
#include <stdio.h>

#include <conio.h>

#include <string.h>

int main() {

int i,j,keylen,msglen;

char input[100], key[30],temp[30],quot[100],rem[30],key1[30];

clrscr();

printf("Enter Data: ");

gets(input);

printf("Enter Key: ");

gets(key);

keylen=strlen(key);

msglen=strlen(input);

strcpy(key1,key);

for (i=0;i<keylen-1;i++) {

input[msglen+i]='0';

for (i=0;i<keylen;i++)

temp[i]=input[i];

for (i=0;i<msglen;i++) {

quot[i]=temp[0];

if(quot[i]=='0')

for (j=0;j<keylen;j++)

key[j]='0'; else

for (j=0;j<keylen;j++)

key[j]=key1[j];

for (j=keylen-1;j>0;j--) {

if(temp[j]==key[j])

rem[j-1]='0'; else

rem[j-1]='1';

}
rem[keylen-1]=input[i+keylen];

strcpy(temp,rem);

strcpy(rem,temp);

printf("\nQuotient is ");

for (i=0;i<msglen;i++)

printf("%c",quot[i]);

printf("\nRemainder is ");

for (i=0;i<keylen-1;i++)

printf("%c",rem[i]);

printf("\nFinal data is: ");

for (i=0;i<msglen;i++)

printf("%c",input[i]);

for (i=0;i<keylen-1;i++)

printf("%c",rem[i]);

getch();

return 0;

OUTPUT:

You might also like