Excerpt
CRC provides a simple yet effective method to validate frame data integrity during transmission by appending a checksum and verifying on receipt.
Maintaining the integrity of data during transmission over networks is vital. Cyclic Redundancy Check or CRC plays a key role in detecting errors and corruption. This post explains how CRC verifies whether the data contents received match the original contents using a simple yet powerful technique.
Understanding CRC
CRC stands for Cyclic Redundancy Check. It is a common error-detecting code used in digital communications and storage devices to detect accidental changes in data.
The key idea behind CRC is to treat the data bit sequence as a large binary number. This data is divided by a predetermined generator polynomial using modulo 2 division. The remainder of this division becomes the CRC code which gets appended to the data.
On the receiving end, the same division process is repeated. If the newly calculated CRC matches the received CRC, the data is deemed intact. Any changes would modify the remainder, indicating corruption.
Calculation of CRC
Here is a simplified example of how a CRC value is computed:
- Let the data bit sequence be 10010101
- Choose a generator polynomial - say, 1001
- Perform modulo 2 binary division of data by polynomial 10010101 / 1001 = Quotient:10011, Remainder: 110
- The remainder 110 becomes the CRC code
- This 3-bit CRC is appended to the original data 10010101110
- The combined bit stream is transmitted
At the receiver:
- Extract the received data bits 10010101110
- Separate the data 10010101 and CRC 110
- Divide data by generator polynomial 10010101 / 1001 = Quotient:10011, Remainder: 110
- Compare the calculated remainder to the received CRC If both match, the data is considered error-free
Checking Data Integrity
In networks, the data being transmitted is formatted into frames or packets. The CRC bits are inserted into the frame structure before transmitting.
For example, a frame with Flags, Data, and FCS including CRC may look like:
FLAG | DATA | CRC | FLAG
The receiver extracts the DATA and CRC portions from the frame and independently calculates the CRC on the data to verify integrity.
Receiver’s Verification
The receiver performs the following steps:
- Receive the frame and extract data and received CRC
- Calculate CRC on extracted data using the same polynomial
- Compare the calculated CRC to the extracted CRC
- If equal - data is intact
- If unequal - data is corrupted
This CRC comparison reliably detects any changes to the data during transmission.
Determining Data Integrity
If the CRC values match, the receiver can trust the data is unchanged from the source. The CRC has verified integrity.
However, a mismatch between the calculated and received CRC indicates the data has been altered. The CRC has detected corruption.
The receiver then discards the frame and requests retransmission to get an intact copy of the data.
Limitations of CRC
While highly effective, CRC cannot detect all errors. Specific patterns of bit flips can go undetected though the chances are very low.
For noisy channels, combining CRC with other checksums provides additional protection. Cryptographic hashes also help against deliberate tampering vs just random errors.
So CRC alone is not foolproof but goes a long way in verifying data integrity efficiently.
Conclusion
In summary, CRC provides a lightweight and powerful method to validate correctness of transmitted data. By appending a CRC to the frame and cross-checking on the receiving end, accidental changes to the data can be reliably detected. This allows critical data to be exchanged intact over error-prone networks. The simplicity yet effectiveness of CRC has made it an indispensable component of digital communication systems.