Lab P4
Lab P4
Problem
Solution Steps
Steps:
Example:
Dividend (initial): 110100111011000000000000110100111011000000000000
Divisor (aligned): 1000100000010000110001000000100001
XOR operation: 010110111010000000000000010110111010000000000000
Shift divisor: Repeat until remainder is 16 bits
• Received Message:
110100111011000110100110010110110100111011000110100110010110
• Perform binary division by the same polynomial.
• If the remainder is 00000000, the data is error-free.
// Compute CRC
int crc = computeCRC(dataBytes);
System.out.printf("Computed CRC: %04X%n", crc);
// Compute CRC-16-CCITT
public static int computeCRC(byte[] data) {
int crc = 0xFFFF; // Initial CRC value