0% found this document useful (0 votes)
19 views4 pages

CN Lab 11

The document outlines the implementation of the Cyclic Redundancy Check (CRC) error-correcting code using various polynomials. It includes objectives, algorithms for both sender and receiver sides, programming code, and a set of viva questions to assess understanding of CRC concepts. Key topics covered include the role of CRC in error detection, the use of polynomial division, and comparisons with other error detection methods.

Uploaded by

katopi3865
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)
19 views4 pages

CN Lab 11

The document outlines the implementation of the Cyclic Redundancy Check (CRC) error-correcting code using various polynomials. It includes objectives, algorithms for both sender and receiver sides, programming code, and a set of viva questions to assess understanding of CRC concepts. Key topics covered include the role of CRC in error detection, the use of polynomial division, and comparisons with other error detection methods.

Uploaded by

katopi3865
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/ 4

Name:- Niyati Saran

Roll No.:- 2200290130121

Computer Networks Lab-8


Problem:
Implement the error correcting code Cyclic Redundancy Check (CRC) of data link layer using
various polynomials like CRC-CRC 12, CRC 16 and CRC CCIPP.

Objectives:
1. Understand the CRC method
2. Implement the polynomial CRC
3. Calculate the checksum of given input
4. Understand the error in transmission

Apparatus/Tools/Equipments/Components: C Compiler
Algorithm:
Checksum Algorithm (Sender Side)

1. Divide the data into equal segments (e.g., 8 or 16 bits each).


2. Add all the segments using binary addition.
3. If there is a carry, add the carry back to the result.
4. Take the 1's complement of the result — this is the checksum.
5. Send the original data + checksum to the receiver.

Checksum Algorithm (Receiver Side)

1. Divide the received data into the same size segments (including the checksum).
2. Add all the segments using binary addition.
3. If there is a carry, add the carry back to the result.
4. Take the 1's complement of the result.
5. If the result is all 0s, then no error; otherwise, error detected.

Programming Code for CRC:


#include<stdio.h>
#include<string.h>
int divrlen,divlen,i,j;
char divisor[100],div[100],divcp[100];
int main()
{
printf("Enter divisor : ");
scanf("%s",&divisor);
printf("Enter Dividend : ");
scanf("%s",&div);
divrlen=strlen(divisor);
divlen=strlen(div);
strcpy(divcp,div);
for(i=0;i<divrlen-1;i++)
{
div[divlen+i]='0';
}
div[divlen+i]='\0';
divlen=strlen(div);
i=0;
while(1)
{
if(div[i]=='0')
i++;
else if(divlen-i>=divrlen)
{
for(j=0;j<divrlen;j++)
{
div[i++]=(div[i]==divisor[j])?'0':'1';
}
i=i-divrlen;
}
else
break;
}
printf("\nRemainder = %s\n\n",div);
printf("Data sent = %s",divcp);
for(i=divlen-divrlen+1;i<divlen;i++)
{
printf("%c",div[i]);
}
return 0;
}
Output:

Viva Questions:

 What is CRC and why is it used in networking?


Explain its role in error detection.

 What is the basic working principle of CRC?


Mention the use of polynomial division and remainder.
 What is a generator polynomial in CRC?
Describe how it's used as the divisor in modulo-2 division.

 How is CRC different from checksum and parity bits?


Compare in terms of accuracy and technique.

 Why is modulo-2 arithmetic used in CRC calculations?


Explain why XOR is used instead of regular subtraction.

 What happens to the data before the CRC is calculated?


Discuss appending zero bits (length of generator - 1).

 What does the receiver do with the CRC value?


Explain how it checks for errors using the same generator.

 Can CRC detect all types of errors? If not, what are its limitations?
Talk about burst errors and multiple-bit errors.

 Give an example of data and a generator polynomial, and explain how CRC is
calculated.
Be ready to work through a small example like: Data = 1101, Generator = 1011.

 Why is CRC considered more reliable than parity checking?


Discuss how it detects more complex error patterns.

You might also like