Wa0006.
Wa0006.
DOP: Grade:
DOS:
---------------------------------------------------------------------------------------------------
EXPERIMENT NO. 4
Theory:
Error Correction:
Error correction is the process of not only detecting the presence of errors in transmitted or stored
data but also determining the exact number of bits that have been corrupted and identifying their
specific locations. Unlike error detection, which only signals the presence of errors, error
correction allows the system to reconstruct the original data without requiring retransmission. This
is achieved using advanced techniques such as Hamming codes, Reed-Solomon codes, and
convolutional codes, which incorporate redundancy into the data to facilitate both error detection
and correction. These methods enable reliable communication and data storage, particularly in
environments where retransmission is costly or impossible, such as deep-space communication,
wireless networks, and memory storage systems.
Difference between Error Detection and Error Correction:
Error detection and error correction are two key processes in ensuring data integrity during
transmission or storage. Error detection focuses solely on identifying whether an error has
occurred, without determining its exact location or the number of corrupted bits. It uses techniques
like parity checks, checksums, and cyclic redundancy checks (CRC) to signal the presence of
errors. In contrast, error correction goes a step further by not only detecting errors but also
determining their exact location and correcting them without requiring retransmission. Techniques
such as Hamming codes, Reed-Solomon codes, and BCH codes enable this process by adding
redundancy to the data. While error detection has lower overhead and is useful when
retransmission is possible, error correction requires more computational resources and is preferred
in scenarios where retransmission is costly or impractical, such as deep-space communication and
memory storage.
Cyclic Redundancy Check (CRC) is an error-detection technique used to identify errors in digital
data during transmission or storage. It works by generating a short, fixed-length checksum (CRC
code) based on the data using polynomial division. The sender appends this CRC code to the data
before transmission. At the receiver’s end, the same polynomial division is performed, and if the
computed CRC does not match the received CRC, it indicates that an error has occurred.
CRC is widely used in network communications, storage devices, and file integrity verification
due to its efficiency in detecting common transmission errors, such as bit flips and burst errors.
However, while CRC can detect errors, it does not correct them; instead, it signals the need for
retransmission if an error is found.
Append Zeros – Add (n-1) zeros to the data, where n is the divisor length.
Binary Division – Divide the modified data by the generator polynomial using XOR.
Get CRC Checksum – The remainder from the division is the CRC code.
Append CRC to Data – Replace the appended zeros with the remainder and transmit.
Receiver Checks for Errors – Divides the received message by the same polynomial.
#include <stdio.h>
#include <string.h>
#define N strlen(gen_poly)
char data[28];
char check_value[28];
char gen_poly[10];
int data_length, i, j;
void crc();
void XOR();
void receiver();
void XOR() {
for (j = 1; j < N; j++)
check_value[j] = ((check_value[j] == gen_poly[j]) ? '0' : '1');
}
void receiver() {
printf("Enter the received data: ");
scanf("%s", data);
printf("\n-----------------------------\n");
printf("Data received: %s", data);
crc();
printf("\nCRC or Check value is : %s", check_value);
if (i < N - 1)
printf("\nError detected\n\n");
else
printf("\nNo error detected\n\n");
}
void crc() {
for (i = 0; i < N; i++)
check_value[i] = data[i];
do {
if (check_value[0] == '1')
XOR();
check_value[j] = data[i++];
} while (i <= data_length + N - 1);
}
int main() {
printf("Sender's Side:\n");
printf("\nEnter data to be transmitted: ");
scanf("%s", data);
data_length = strlen(data);
printf("\n----------------------------------------");
printf("\nData padded with n-1 zeros : %s", data);
printf("\n----------------------------------------");
crc();
printf("\n----------------------------------------");
printf("\nFinal data to be sent : %s", data);
printf("\n----------------------------------------\n");
printf("Receiver's Side:\n");
receiver();
return 0;
}
Output:
Without Errors:
With Errors:
Conclusion:
The experiment successfully implemented a Cyclic Redundancy Check (CRC) program in C to
detect errors in data transmission by generating and verifying a CRC checksum using a given
generator polynomial. This demonstrated the effectiveness of CRC in identifying errors, ensuring
data integrity in digital communication and storage systems.