Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

8. For a given data, use CRC-CCITT polynomial to obtain the CRC code.

Verify
the program for the cases a. Without error b. With error

Description:
The cyclic redundancy check, or CRC, is a technique for detecting errors in digital data,
but not for making corrections when errors are detected. It is used primarily in data
transmission.

In the CRC method, a certain number of check bits, often called a checksum, are appended
to the message being transmitted. The receiver can determine whether or not the check bits
agree with the data, to ascertain with a certain degree of probability whether or not an
error occurred in transmission.

If an error occurred, the receiver sends a "negative acknowledgement" (NAK) back to the
sender, requesting that the message be retransmitted. The technique is also sometimes
applied to data storage devices, such as a disk drive. In this situation each block on the
disk would have check bits, and the hardware might automatically initiate a reread of the
block when an error is detected, or it might report the error to software. The material that
follows speaks in terms of a "sender" and a "receiver" of a "message," but it should be
understood that it applies to storage writing and reading as well.

Algorithm
1. Start
2. Enter the message to be transmitted
3. Append the message with 16(since it is 16-bit CRC) 0`s (i.e. if you input 5 digit message,
the appended message should be 21-bits.)
4. XOR appended message and transmit it.(Here, you compare with an already existing
string such as10001000000100001 and replace the bits the same way XOR operation
works)
5. Verify the message that is received is the same as the one sent.
6. End
#include<stdio.h>
#include<string.h>
int error;
char i[200],o[200],g[200];
int crc(char i[200],char o[200],int mode);
void main()
{
char r[200];
printf("\n enter the message in binary");
scanf("%s",i);
crc(i,o,1);
printf("\n the crc code is %s%s",i,o+strlen(i));
printf("\n enter the recieved message");
scanf("%s",r);
if(!crc(r,o,0))
printf("\n error free message\n");
else
printf("\n error in message\n");
getch();
}
int j,k;
char g[200]={"1101"};
strcpy(o,i);
if(mode)
strcat(o,"000");
for(j=0;j<strlen(i);j++);
if(o[j]=='1')
for(k=0;k<strlen(g);k++);
if(o[j+k]=='1'&& g[k]=='1')||(o[j+k]=='0'&& g[k]=='0'))
o[j+k]='0';
else
o[j+k]='1';
for(j=0;j<strlen(o);j++);
{
error=0;
if(o[j]=='1')
{
error=1;
break;
}
}
if(error==1)
return 1;
else
return 0;

Output:

You might also like