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

EXP6

CN EXPERIMENT 6 SEM 5

Uploaded by

Kratos grime
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 views8 pages

EXP6

CN EXPERIMENT 6 SEM 5

Uploaded by

Kratos grime
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/ 8

Course: Computer Network Lab

PART A

(PART A: TO BE REFFERED BY STUDENTS)

Experiment No. 06

A.1 Objective:

Implementation of a Cyclic Redundancy Code (CRC) generator and checker using any higher level
language

A.2 Prerequisite:
• Knowledge about PAN, LAN and NW Elements.
• Knowledge of Programming Languages.
• Binary arithmetic’s.
• Error types and their detection and correction.
• Concept of Programming, Analysis, Design, Simulation and Modelling

A.3 Outcome:
After successful completion of this experiment students will be able to

• Ability to select the proper NW Elements required to design NWs.


• Thorough understanding of DLL.
• Error detection methodologies and their implementation.
• Hard coding by applying their programming skills.

A.4 Theory/Tutorial:
The Cyclic Redundancy Check algorithm checks for errors and verifies the accuracy of the data
delivered by the sender. CRC requires a generator polynomial in order to compute the check value using
binary division in addition to the data that has to be transferred. To ensure that the data is genuine, the
check value or CRC is sent with it to the recipient.

The degree of the polynomial can be used as the bit locations to represent the data that will be conveyed
to the recipient in polynomial form.

Binary data can also be used to represent the generating polynomial. The degree of the data polynomial
must be less than the degree of the generator polynomial and must be larger than 0. Based on the degree
of the generating polynomial, the CRC may be divided into several standards. Using a generator
polynomial of degree 8 for the CRC-8 standard and degree 16 for the CRC-16 standard.
An example generator polynomial is of the form like x3 + x + 1. This generator polynomial represents
key 1011. Another example is x2 + 1 that represents key 101.

n : Number of bits in data to be sent from sender side. k : Number of bits in the key obtained

from generator polynomial.

Sender Side (Generation of Encoded Data from Data and Generator Polynomial (or Key)):

1. The binary data is first augmented by adding k-1 zeros in the end of the data
2. Use modulo-2 binary division to divide binary data by the key and store remainder of division.
3. Append the remainder at the end of the data to form the encoded data and send the same
Receiver Side (Check if there are errors introduced in transmission)
Perform modulo-2 division again and if the remainder is 0, then there are no errors.
Modulo 2 Division:
The process of modulo-2 binary division is the same as the familiar division process we use for
decimal numbers. Just that instead of subtraction, we use XOR here.
• In each step, a copy of the divisor (or data) is XORed with the k bits of the dividend (or
key).
• The result of the XOR operation (remainder) is (n-1) bits, which is used for the next step
after 1 extra bit is pulled down to make it n bits long.
• When there are no bits left to pull down, we have a result. The (n-1)-bit remainder which is
appended at the sender side

References:

• https://www.javatpoint.com/computer-network-error-detection

PART B

(PART B : TO BE COMPLETED BY STUDENTS)


B.1 Document created by the student:

#include<stdio.h>
#include<string.h>
// length of the generator polynomial
#define N strlen(gen_poly)
// data to be transmitted and received
char data[28];
// CRC value
char check_value[28];
// generator polynomial
char gen_poly[10];
// variables
int data_length,i,j;
// function that performs XOR operation
void XOR(){
// if both bits are the same, the output is 0
// if the bits are different the output is 1
for(j = 1;j < N; j++)
check_value[j] = (( check_value[j] == gen_poly[j])?'0':'1');
}
// Function to check for errors on the receiver side
void receiver(){
// get the received data
printf("Enter the received data: ");
scanf("%s", data);
// Cyclic Redundancy Check
crc();
// Check if the remainder is zero to find the error
for(i=0;(i<N-1) && (check_value[i]!='1');i++);
if(i<N-1)
{
printf("\n\n Error detected\n");
printf(" ************\n");
}
else
{
printf("\n\n No error detected\n");
printf(" ***************\n");
}
}
void crc(){
// initializing check_value
for(i=0;i<N;i++)
check_value[i]=data[i];
do{
// check if the first bit is 1 and calls XOR function
if(check_value[0]=='1')
XOR();
// Move the bits by 1 position for the next computation
for(j=0;j<N-1;j++)
check_value[j]=check_value[j+1];
// appending a bit from data
check_value[j]=data[i++];
}while(i<=data_length+N-1);
// loop until the data ends
}
int main()
{
printf("\nEnter data to be transmitted: ");
scanf("%s",data);
printf("\n Enter the Generating polynomial: ");
// get the generator polynomial
scanf("%s",gen_poly);
// find the length of data
data_length=strlen(data);
// appending n-1 zeros to the data
for(i=data_length;i<data_length+N-1;i++)
data[i]='0';
printf("\n ");
// print the data with padded zeros
printf("\n Data padded with n-1 zeros : %s",data);
// Cyclic Redundancy Check
crc();
// print the computed check value
printf("\n CRC or Check value is : %s",check_value);
// Append data with check_value(CRC)
for(i=data_length;i<data_length+N-1;i++)
data[i]=check_value[i-data_length];
// printing the final data to be sent
printf("\n Final data to be sent : %s",data);
printf("\n \n");
// Calling the receiver function to check errors
receiver();
return 0;
}

B.2 Observations and learning:

We get the transmitted data by using the Cyclic Redundancy checker in high level language.

The truth table of an XOR gate is given below:

B.3 Conclusion:

We learned about Cyclic Redundancy checker and XOR operation and implementation.
B.4 Question of Curiosity

1. What is an error? Name the types of error?


Ans - A condition when the receiver's information does not match with the sender's
information. During transmission, digital signals suffer from noise that can
introduceerrors in the binary bits travelling from sender to receiver. That means a 0
bit may change to 1 or a 1 bit may change to 0.

Types of Errors

There may be three types of errors:


Single bit error

In
a frame, there is only one bit, anywhere though, which is corrupt.
Multiplebits error

Frame is received with more than one bits in corrupted state. Burst error

Frame contains more than1 consecutive bits corrupted.

2. Single bit error is found in parallel transmission. Give valid reason.


Ans - Reason: In parallel transmission, each bit has its dedicated channel (wire). If a
single bit experiences an error, it occurs independently on its respective channel,
making it easier to identify and correct. Parallel transmission allows for the detection
and correction of single-bit errors due to the individualized nature of each bit's
transmission path.

3. Burst error is normally found in serial transmission. Give reason.


Ans - Reason: In serial transmission, multiple bits are sent sequentially over a single
channel. External factors, such as noise or interference, can affect multiple
consecutive bits, leading to burst errors. The continuous stream of bits amplifies the
impact of disturbances, making burst errors more common in serial transmission.
4. What are even and odd parity? State the limitation of Single parity check and Two-
dimensional parity check.
Ans - Even Parity: Ensures the total number of set bits (1s) in a binary sequence,
including the parity bit, is even.

- Odd Parity: Ensures the total number of set bits in a binary sequence, including the
parity bit, is odd.

- Limitation of Single Parity Check: Detects but cannot correct errors; limited to
detecting odd numbers of errors.

- Limitation of Two-Dimensional Parity Check: Effective for detecting errors within


each row and column but limited in detecting errors that span both rows and columns.

In short, even and odd parity define whether the total number of set bits is even or
odd. Single parity check detects but doesn't correct errors, while two-dimensional
parity check is limited in detecting certain error patterns.

5. What are the redundant bit Generator and error Checker?


Ans - Redundant Bit Generator: Adds extra bits (parity bits) to a data sequence for
error detection or correction.

- Error Checker: Verifies the integrity of transmitted data by checking the redundancy
(parity) bits and identifying errors if present.

In short, the redundant bit generator adds extra bits for error detection, and the error
checker verifies data integrity by examining these redundancy bits.
6. State the working of CRC error detection method with example of your own?
Ans - A cyclic redundancy check (CRC) is an error-detecting code
commonly used indigital 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.

CRC Generator-

● CRC generator is an algebraic polynomial represented as a bit pattern.


● Bit pattern is obtained from the CRC generator using the following rule
The power of each term gives the position of the bit and the
coefficient gives the value of the bit.

Example

Consider the CRC generator is x7 + x6 + x4 + x3 + x +

1. Thecorresponding binary pattern is obtained as

Thus, for the given CRC generator, the corresponding binary pattern is 11011011.

7. Which method is used for Forward error correction?


Ans - Method for Forward Error Correction:
- Hamming Code A block error-correcting code that adds redundant bits to data for
error detection and correction.
In short, Hamming Code is commonly used for Forward Error Correction.

You might also like