3 Experiment 3: Cyclic Redundancy Check (CRC) : 3.1 Objective
3 Experiment 3: Cyclic Redundancy Check (CRC) : 3.1 Objective
(CRC)
3.1 Objective
The objective of this lab is to understand and implement Cyclic Redundancy
Check (CRC) for error detection in data transmission. This experiment will
help you learn how CRC is computed and how it helps in detecting errors in
transmitted messages.
3.2 Theory
Cyclic Redundancy Check (CRC) is a technique used to detect errors in data
transmission. It is based on dividing the input data by a known generator
polynomial, then appending the remainder (CRC code) to the message. At
the receiving end, the same polynomial is used to check if the message is
error-free.
The generator polynomial is chosen as a divisor, and the message is di-
vided by it using modulo-2 division. The remainder of this division becomes
the CRC code, which is appended to the original data before transmission.
4. On the receiver’s side, perform the same division to check for errors.
9
4
10
free
40 return ( received . substr ( dataLen - genLen + 1) ==
string ( genLen - 1 , ’0 ’) ) ;
41 }
42
43 int main () {
44 string message , generator ;
45
52 // Compute CRC
53 string crc = computeCRC ( message , generator ) ;
54 string encodedMessage = message + crc ;
55
11
.\ n " ;
76 } else {
77 cout << " Error ␣ detected ␣ in ␣ received ␣ message .\ n " ;
78 }
79
80 return 0;
81 }
3.3.2 Explanation:
- The **sender side** computes the CRC checksum by performing modulo-2
division on the data and appends it to the original data for transmission. -
The **receiver side** performs the same modulo-2 division on the received
data (including the CRC checksum) and checks whether the remainder is
zero. If the remainder is zero, the data is valid; otherwise, it indicates an
error in the transmission.
**Output:**
Simulating transmission...
No errors detected in received message.
3.4 Conclusion
This implementation demonstrates how CRC can effectively detect errors in
transmitted messages. It is widely used in communication protocols, storage
devices, and embedded systems to ensure data integrity. The error detection
process works by verifying if the received data, including the appended CRC
12
checksum, results in a remainder of zero after modulo-2 division. If the
remainder is non-zero, an error has occurred in the transmission.
13