Experiment 09
Implementation and Testing of Error Detection using Parity Checking and Checksums
Add a parity bit or a checksum to your data, introduce bit errors in the channel, and see whether the receiver detects them.
Aim
To implement and test error detection using even and odd parity checking and a ones’-complement checksum, by introducing bit errors in the channel and checking whether the receiver detects them.
Learning objectives
- Generate even and odd parity bits for a data word.
- Check the parity of a received frame and decide whether an error occurred.
- Show that single parity detects every odd number of bit errors but misses even numbers of errors.
- Generate a checksum by ones’-complement addition with end-around carry, and verify it at the receiver.
- Identify an error pattern that a checksum cannot detect.
Brief theory
- Noise in a channel can change bits (0 → 1 or 1 → 0). Error detection adds redundant bits so the receiver can tell that something went wrong and ask for the data again.
- Even parity: the parity bit is chosen so that the total number of 1s (data + parity) is even. Odd parity: the total number of 1s is odd. Example: data 1011001 has four 1s, so the even parity bit is 0 and the odd parity bit is 1.
- The receiver counts the 1s. If the count does not have the agreed parity, an error is detected. A single parity bit detects any odd number of bit errors (1, 3, …) but cannot detect an even number (2, 4, …), because these leave the parity unchanged.
- Checksum: the data is divided into k words of n bits. The sender adds the words using ones’-complement arithmetic (any carry out of the leftmost bit is added back to the rightmost bit, the end-around carry). The checksum is the complement of this sum and is sent with the data.
- The receiver adds all the words including the checksum, in the same way, and complements the result. If the result is 0 (all zeros), the data is accepted; otherwise an error is detected. The checksum misses errors that cancel out, for example the same bit position flipping 0 → 1 in one word and 1 → 0 in another.
Instructions for students
Expected learning outcome
You will be able to calculate parity bits and checksums by hand, verify them at the receiver, and explain which error patterns each method can and cannot detect.
Part 1 · Parity checking
Sender
Channel (click any bit to flip it)
Receiver
Trials
| # | Parity | Transmitted | Received | Bit errors | Receiver decision |
|---|---|---|---|---|---|
| Each change in the channel adds a row. | |||||
Part 2 · Checksum (ones’-complement, 8-bit words)
Sender: ones’-complement addition
| Step | Operation | Binary |
|---|---|---|
| Press Generate checksum. | ||
Channel (click any bit of the data or the checksum to flip it)
Receiver: add all words including the checksum
Observations
Readings fill in by themselves when you complete the guided steps in the simulation. They also appear under My observations beside the steps as you work. You can click any reading below and type your own.
| No. | What to observe | Expected result | Your observation | Status |
|---|
Result
Even and odd parity detected all single-bit errors but missed 2-bit errors. The ones’-complement checksum detected the injected errors except when errors in two words cancelled each other.
Quiz
Choose one answer for each question, then press Check answers. Your score is also recorded in the Observations tab.