TITLE: Lab #7- Implementation of error detection & correction methods in C
Objective:
To implement CRC encoding at
the Sender, and CRC decoding at the Receiver
In
C, write a function MakeCRC, which takes in 2 parameters Divisor and
Dividend, and returns a Remainder.
At the Sender, provide the Divisor and Dividend according to Figure 10.15.
Check that MakeCRC returns the correct remainder, to be appended to the Dataword.
At the Receiver, enter the Dataword, as the Dividend to the MakeCRC function.
If no error is detected, the Remainder (also known as the Syndrome) is 000. Else, an error has been detected.
Inject error(s) into the Dataword received by the Receiver:-
single-bit (isolated) errors
At the Sender, provide the Divisor and Dividend according to Figure 10.15.
Check that MakeCRC returns the correct remainder, to be appended to the Dataword.
At the Receiver, enter the Dataword, as the Dividend to the MakeCRC function.
If no error is detected, the Remainder (also known as the Syndrome) is 000. Else, an error has been detected.
Inject error(s) into the Dataword received by the Receiver:-
single-bit (isolated) errors
-
burst (consecutive) errors
Is
the Receiver able to detect the errors?
Send the data - 1001000 - using
the divisor - 1000.
Inject single-bit error(s) into
the Dataword received by the Receiver.
Is the Receiver able to detect
the errors? Why?
Answer:-
#include<stdio.h>
#include<string.h>
int
dividend[7]={1,0,0,1,0,0,0};
int
divisor[4]={1,0,1,1};
int
dividend1[7];
void
makecrc(){
int
len1=(sizeof(dividend)/sizeof(int));
int
len2=(sizeof(divisor)/sizeof(int));
//printf("%d",len2);
int
i;
for(i=0;i<len2;i++){
if(dividend[i]==1)
{
int
j;
for(j=0;j<len2;j++){
dividend[i+j]=dividend[i+j]^divisor[j];
//printf("%d\n",dividend[i+j]);
}
}
else{ int
j;
for(j=0;j<len2;j++){
dividend[i+j]=dividend[i+j]^0;
//printf("%d\n",dividend[i+j]);
}
}
}
//return
dividend;
}
void
sender(){
int
len1=(sizeof(dividend)/sizeof(int));
int
len2=(sizeof(divisor)/sizeof(int));
int
i;
for(i=0;i<len1;i++)
dividend1[i]=dividend[i];
makecrc();
for(i=0;i<len2;i++)
dividend[i]=dividend1[i];
//dividend[0]=0;(For
inserting single bit error )
/*for(i=3;i<=5;i++)(For
inserting burst Error )
dividend[i]=0;*/
printf("The
new dividend!");
for(i=0;i<len1;i++)
printf("%d",dividend[i]);
printf("\n");
}
void
receiver(){
int
len1=(sizeof(dividend)/sizeof(int));
int
len2=(sizeof(divisor)/sizeof(int));
int
i,c=0;
makecrc();
for(i=len2;i<len1;i++){
if(dividend[i]!=0)
break;
else
c=1;
}
if(c==1)
printf("No
Error DEtected!\n");
else
printf("Error
Detected! \n");
}
int
main(){
printf("Calling
the sender Function.....\n");
sender();
printf("Calling
the receiver Function\n");
receiver();
/*int
i;
makecrc();
for(i=4;i<7;i++)
printf("%d
",dividend[i]);
printf("\n");*/
return
0;
}
Checking
without error:-
Yes,it
can identify both single bit error as well as burst error.
Checking
with Singlebit error:-
Checking
with Burst error:-
Comments
Post a Comment