0% found this document useful (0 votes)
0 views2 pages

exp11DCN

The document contains a C program that implements the Cyclic Redundancy Check (CRC) for error detection in transmitted data. It prompts the user to input data and a generating polynomial, performs CRC calculations, and checks for errors in the received data. The program outputs the padded data, CRC value, and whether an error was detected in the transmission.

Uploaded by

dailyuse973
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

exp11DCN

The document contains a C program that implements the Cyclic Redundancy Check (CRC) for error detection in transmitted data. It prompts the user to input data and a generating polynomial, performs CRC calculations, and checks for errors in the received data. The program outputs the padded data, CRC value, and whether an error was detected in the transmission.

Uploaded by

dailyuse973
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CRC EXP 11

#include<stdio.h>
#include<string.h>
#define N strlen(gen_poly)
char data[28];
void crc();
char check_value[28];
char gen_poly[10];
int data_length,i,j;
void XOR()
{
for(j=1;j<N;j++)
check_value[j]=((check_value[j]==gen_poly[j]?'0':'1'));
}
void receiver()
{
printf("Enter the received data");
printf("\n...............\n");
printf("Data recieved:%s" ,data);
crc();
for(i=0;(i<N-1)&&(check_value[i]!='1');i++);
if(i<N-1)
printf("\n Error Detected\n");
else
printf("\n No Error Detected");
}
void crc()
{
for(i=0;i<N;i++)

check_value[i]=data[i];
do
{
if(check_value[0]=='1')
XOR();
for(j=0;j<N;j++)
check_value[j]=check_value[j+1];
check_value[j]=data[i++];
}while(i<=data_length+N-1);
}
CRC EXP 11
int main()
{
printf("\n Enter data to be transmitted");
scanf("%s",data);
printf("\n enter the Generating polynomial");
scanf("%s",gen_poly );
data_length=strlen(data);
for(i=data_length;i<data_length+N-1;i++)
data[i]='0';
printf("\n..................\n");
printf("\n Data padded with n-1 zeros :%s",data);
printf("\n...................\n");
crc();
printf("\n CRC or chrck value is :%s",check_value);
for(i=data_length;i<data_length+N-1;i++);
data[i]=check_value[i-data_length];
printf("\n...................\n");
printf("\n Final data to be sent:%s",data);
printf("\n.................\n");
receiver();
return 0;
}

You might also like