0% found this document useful (0 votes)
248 views5 pages

Experiment 5 CRC

The document describes an experiment to write a C program for CRC error detection. It explains that CRC is a checksum algorithm used to detect errors in transmitted data by attaching a checksum to the data. The program code segment shows how to implement CRC error detection by performing long division of the message and CRC key, with the remainder bits appended to the message as a checksum. The program is run successfully to demonstrate CRC error detection.

Uploaded by

shriomom.24
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)
248 views5 pages

Experiment 5 CRC

The document describes an experiment to write a C program for CRC error detection. It explains that CRC is a checksum algorithm used to detect errors in transmitted data by attaching a checksum to the data. The program code segment shows how to implement CRC error detection by performing long division of the message and CRC key, with the remainder bits appended to the message as a checksum. The program is run successfully to demonstrate CRC error detection.

Uploaded by

shriomom.24
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/ 5

EXPERIMENT 5:

Aim: Write a C Program for CRC Error Detection.

Apparatus: Turbo C3

Introduction:

Basic approach used for error detection is the use of redundancy bits, where additional bits
are added to facilitate detection of errors.

Some popular techniques for error detection are:


1. Longitudinal Redundancy Check
2. Vertical Redundancy Check
3. Checksum
4. Cyclic Redundancy Check

CRC (Cyclic Redundancy Check):

CRC (Cyclic Redundancy Check) is a checksum algorithm to detect inconsistency of data,


e.g. bit errors during data transmission. A checksum, calculated by CRC, is attached to the
data to help the receiver to detect such errors. CRC is based on division.

Advantages: Cyclic codes have a very good performance in detecting single-bit errors,
double errors, an odd number of errors.

Disadvantages: CRC is not suitable for protecting against intentional alteration of data, and
overflow of data is possible in CRC.

Program Code:

#include <stdio.h>

#include <conio.h>

#include <string.h>

void 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();

Result: In this way we have executed a C Program for CRC Error Detection.

Conclusion: Hence a C Program for CRC Error Detection is being executed successfully.

Output:
Q. Answer the following questions:-

1) what is CRC?

……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
…………………………………………………………………………………..

2) what is VRC?

……………………………………………………………………………………
……………………………………………………………………………………
…………………………………….……………………………………………
……………………………………………………………………………………

3) Explain importance of CRC?

……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………

4) what is LRC?

……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………

5) The message 10011101 is to be transmitted using CRC polynomial x^3+1


to protect if from error.

……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………

You might also like