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

Computer Hardware and Data Communication (CND)22634

Practical9: Correct the error in a given data stream by applying the different
error correction methods

Error is a condition when the receiver’s in format on does not match with the sender’s
information. During transmission, digital signal suffer from noise that can introduce errors 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.To avoid this, error detecting codes are used which are additional data
added to a given digital message to detect any error that has occur red during transmission of
the message. At the receiver, the detected error is corrected. Error correction is the detection
of errors and reconstruction of the original error free data.

Whenever a message is transmitted, it may get scrambled by noise and the data may get
corrupted. Two methods of error correction are:
1. Reverse error correction (REC).
2. Forward error correction (FEC)

In Reverse error correction, the receiver requests for the retransmission of the code word
whenever it detects an error after that the receiver locates the error by analyzing the
received code and reverses the erroneous bits.

In Forward Error correction the code set is so designed that it is possible for the receiver to
detect and correct error as well by itself.

Hamming code is a set of error-correction codes that can be used to detect and correct the
errors that can occur when the data is moved or stored from the sender to the receiver.

ProgrammingCode:

#include<stdio.h> #include<conio.h>
voidmain(){
intdata[7],rec[7],i,c1,c2,c3,c;
printf("thisworksformessageof4bitsinsize\nentermessagebitonebyone:"); scanf("%d%d%d
%d",&data[0],&data[1],&data[2],&data[4]); data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4]; data[3]=data[0]^data[1]^data[2];
printf("\ntheencodedbitsaregivenbelow:\n"); for(i=0;i<7;i++){
printf("%d",data[i]);
}
printf("\nenterthereceiveddatabitsonebyone:"); for(i=0;i<7;i++){
scanf("%d",&rec[i]);
}
c1=rec[6]^rec[4]^rec[2]^rec[0];
c2=rec[5]^rec[4]^rec[1]^rec[0];
c3=rec[3]^rec[2]^rec[1]^rec[0];
c=c3*4+c2*2+c1; if(c==0){
printf("\ncongratulationsthereisnoerror:");
}else{
printf("\nerrononthepostion:%d\nthecorrectmessageis\n",c); if(rec[7-
c]==0) rec[7-c]=1;else rec[7-c]=0; for(i=0;i<7;i++){
printf("%d",rec[i]);
}
}
getch();
}

Screen shots of the output:


Conclusion:
We understand different error detection methods.

Class: EJ6IA
Student Name: Enrollment No: Roll No:
Barkatulla Syed 1905680184 19201A0056

You might also like