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

CRC Error Detection Short

The document outlines the implementation of CRC error detection in Java, detailing a brief algorithm that includes appending zeros, dividing by a generator using XOR, and checking for errors upon data reception. It provides a minimal Java program that demonstrates these steps, including methods for XOR operation and modular division. The sample output shows a successful transmission and error detection result.

Uploaded by

vishnuai4568
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 views2 pages

CRC Error Detection Short

The document outlines the implementation of CRC error detection in Java, detailing a brief algorithm that includes appending zeros, dividing by a generator using XOR, and checking for errors upon data reception. It provides a minimal Java program that demonstrates these steps, including methods for XOR operation and modular division. The sample output shows a successful transmission and error detection result.

Uploaded by

vishnuai4568
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

Aim:

Implement CRC error detection in Java.

Algorithm (Brief):

1. Append zeros to data.

2. Divide by generator using XOR.

3. Append remainder (CRC) to data.

4. Receiver divides received data.

5. If remainder is 0 -> No error; else -> Error detected.

Java Program (Minimal):

import [Link];

public class CRC {

static String xor(String a, String b) {

StringBuilder res = new StringBuilder();

for (int i = 1; i < [Link](); i++)

[Link]([Link](i) == [Link](i) ? '0' : '1');

return [Link]();

static String mod2div(String data, String div) {

int len = [Link]();

String temp = [Link](0, len);

for (int i = len; i < [Link](); i++)

temp = xor(([Link](0) == '1' ? div : "0".repeat(len)), temp) + [Link](i);


return xor(([Link](0) == '1' ? div : "0".repeat(len)), temp);

public static void main(String[] args) {

Scanner s = new Scanner([Link]);

String data = [Link](), div = [Link]();

String crc = mod2div(data + "0".repeat([Link]() - 1), div);

String tx = data + crc;

[Link]("Tx: " + tx);

String rx = [Link]();

[Link](mod2div(rx, div).contains("1") ? "Error" : "No Error");

Sample Output:

Tx: 11010011101100100

No Error

Result:

CRC successfully detects errors in received data.

You might also like