Skip to main content

Implementation of error detection & correction methods in C

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
  • 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

Popular posts from this blog

how to Install Numpy, Pandas and matplotlib on ubuntu 18.04 and Linux Mint

Install Python, NumPy,Matplotlib for Python 3 on Ubuntu 18.04, Linux Mint, Debian Linux. This is a short article about installing Numpy, Pandas , Matplotlib, Python3 on the latest Ubuntu 18.04 LTS, Linux Mint, Debian Linux which comes with Python 3.6.5. Let’s start by making sure we have an updated system: 1 sudo apt update 2 sudo apt upgrade Now, let’s install NumPy, Pandas,Matplotlib : sudo apt-get install python-pip sudo pip install numpy sudo pip install pandas sudo pip install matplotlib Test numpy : Open up a Terminal in Your Linux Operating System by running the following: python3 At the Terminal, type the following: >>> import numpy as np >>> np.__version__ '1.13.3'   Test Pandas : Open up a Terminal in Your Linux Operating System by running the following: python3 At the Terminal, type the following: >>> import pandas as pd >>> pd.__version__ '0.22.0'   Test Matpl...

SQL Alias With Example

SQL Alias An Alias is a shorthand for a table or column name. Aliases reduce the amount of typing required to enter a query. Complex queries with aliases are generally easier to read. Aliases are useful with JOINs and aggregates: SUM, COUNT, etc. An Alias only exists for the duration of the query. Alias Column Syntax SELECT column_name AS alias_name FROM table_name; Alias Table Syntax   SELECT column_name(s) FROM table_name AS alias_name; SQL Alias Examples 1) Example of Alias column    mysql> select name as alias_name from person; +-----------------+ | alias_name      | +-----------------+ | subham ball     | | jit             | | sajal           | | sourav biswas   | | sajal           | | chayan das...

What is Spiral Model

What is Spiral Model ? spiral model : The Spiral Model was first invented  by Berry Bohem in 1986. The Spiral Model is more emphasis placed on risk Analysis . Each phase of Spiral Model begin with a Design goal and ends with the Client Reviewing the progress . The Spiral Model has Four phases -  i) Planning (Design)                                                            ii) Risk Analysis                                                                   iii) Engineering           ...