CRC Checksum 2
CRC Checksum 2
Question:
1. Implement a C program that performs CRC encoding and verification. The program should:
• Take a binary data string and a binary key (polynomial) as input from the user.
• Output the calculated remainder and the generated codeword (data + remainder).
• Simulate a receiver: accept an encoded codeword from the user, verify the received
codeword by checking if the remainder is zero, and print a message indicating whether
the received codeword is correct or contains errors.
Requirements:
• Print remainder after CRC calculation.
• Print the generated codeword (data + remainder).
• Accept the encoded codeword at the receiver end, verify it, and print if the codeword is
valid or contains errors.
2. Write a C/C++ program to implement a generalized checksum-based error detection
mechanism for an arbitrary-length binary string. The program should follow these steps:
• Accept a binary string of arbitrary length from the user.
i. The length can be any multiple of 4 bits.
ii. If the string length is not a multiple of 16 bits, it should be padded with zeros
to make it a multiple of 16.
• Divide the binary string into 16-bit chunks.
• Calculate the checksum:
i. Sum all the 16-bit chunks. Handle any overflow by wrapping around the carry.
ii. Use the one's complement of the sum as the checksum.
• Append the checksum to the original binary string to create an encoded codeword
(with the checksum at the end).
• Simulate the receiver:
i. Accept the received codeword from the user, which includes the original data
and the checksum.
ii. Divide the received codeword into 16-bit chunks (including the checksum).
iii. Recalculate the checksum to verify the received codeword.
iv. If the checksum verification results in all ones (1111111111111111), the
message is correct; otherwise, an error has occurred.
• Implement error simulation:
i. Introduce an option for the user to simulate an error by flipping a random bit
in the codeword before sending it to the receiver for validation.
• Print appropriate messages at both the sender and receiver sides:
i. At the sender side, print the calculated checksum and the encoded codeword.
ii. At the receiver side, print whether the received message is correct or contains
errors.