When data travels between devices, corruption can happen due to noise, interference, timing errors, or synchronization issues.
That’s why error detection and handling is a core feature of almost ALL communication protocols.
This part explains how protocols detect, report, and recover from errors, using clear examples and ASCII diagrams.
1. Why Errors Happen in Communication
Common causes:
- Electrical noise in wires
- Crosstalk between signals
- Clock mismatch
- Packet collision
- Signal attenuation (long distance)
- EMI (Electromagnetic Interference)
- Buffer overflow in receivers
2. Types of Errors
| Error Type | Description | Example |
|---|---|---|
| Single-bit error | Only 1 bit flips | 1010 → 1000 |
| Burst error | Multiple consecutive bits corrupted | 1010110 → 1110100 |
| Packet loss | Entire packet missing | No data received |
| Out-of-order | Packets received in wrong order | 1,3,2,4 |
| Duplicate packets | Same data repeated | 2,2,3,4 |
3. Common Error Detection Techniques
3.1 Parity Bit (Simple, used in UART, RAM)
Adds 1 extra bit to make total number of 1s either EVEN or ODD.
Example (Even parity):
Data: 1010 -> 2 ones (even) -> Parity = 0<br>Sent: 10100<br>Pros: Simple
Cons: Detects only single-bit errors
3.2 Checksum (Used in IP, TCP, UDP)
Adds all bytes and keeps the sum.
Example:
0x10
+ 0x22
------
0x32 -> checksum sent
Receiver:
- Calculates again
- Compares with checksum
Pros: Can detect some burst errors
Cons: Not very strong compared to CRC
3.3 CRC (Cyclic Redundancy Check) – Used in Ethernet, USB, PCIe
Most powerful and widely used.
Treats data as a polynomial, divides by a generator polynomial, and sends the remainder.
ASCII Representation:
[Data Bits] / [Generator Polynomial] = Remainder (CRC)
Pros: Detects burst errors up to 32 bits (CRC-32)
Cons: Requires more hardware/software logic
4. Error detection and Handling Approaches
| Approach | What Happens |
|---|---|
| Error Detection only | Receiver discards data |
| Error Correction (FEC) | Receiver fixes data using math (e.g., Hamming code) |
| Retransmission (ARQ) | Receiver requests sender to re-send |
5. Automatic Repeat Request (ARQ)
Used in TCP, Wi-Fi, LTE, etc.
5.1 Stop-and-Wait ARQ
Sender --> Frame 1 --> Receiver
Sender <-- ACK 1 ---- Receiver
Simple but slow (waits every time)
5.2 Go-Back-N ARQ
Sends multiple frames without waiting but if one fails, go back and resend all after that frame.
1 2 3 X 5
^
error at 4
Resend: 4,5
5.3 Selective Repeat ARQ
Only resend the corrupted frame.
Most efficient but complex.
1 2 3 X 5
^
error at 4
Resend: 4 only
6. ACK and NACK Mechanism
| Term | Meaning |
|---|---|
| ACK | Acknowledged – OK |
| NACK | Not Acknowledged – Something went wrong |
Some protocols don’t use NACK — only timeouts.
7. Timeouts and Retries
If no ACK within time, the sender retransmits.
Sender: Frame 1
(wait...)
No ACK
Resend Frame 1
8. Sequence Numbers (Important!)
Used to:
- Detect lost packets
- Prevent duplicates
- Maintain order
Example:
Frame 1 → ACK 1
Frame 2 → ACK 2
If ACK doesn’t match, something went wrong.
9. Flow Control vs Error Control
| Term | Purpose |
|---|---|
| Flow Control | Prevents overwhelming receiver (speed matching) |
| Error Control | Handles data corruption or loss |
Often both exist in protocols (e.g., TCP).
10. Where These Techniques Are Used (Real Protocol Examples)
| Protocol | Error Technique |
|---|---|
| UART | Parity |
| Ethernet | CRC |
| USB | CRC + Retries |
| SPI | Usually none (assumes perfect wires) |
| I2C | ACK/NACK |
| PCIe | CRC + Retry |
| TCP/IP | Checksum + Sequence + ACK + Retransmission |
| Satellite/5G | FEC + ARQ (Hybrid) |
11. ASCII Summary Table
+------------------+-------------------+----------------------+
| Layer | Error Technique | Action |
+------------------+-------------------+----------------------+
| Physical | None/Parity | Hardware fix |
| Data Link (Ethernet)| CRC + Retry | Frame resend |
| Network (IP) | Checksum only | Drop packet |
| Transport (TCP) | Checksum + ARQ | Retransmit, reorder |
| Application | App-specific | Retry or notify user |
+------------------+-------------------+----------------------+

