EECS 122: Introduction to Computer Networks Error Detection and Reliable Transmission
Download ReportTranscript EECS 122: Introduction to Computer Networks Error Detection and Reliable Transmission
EECS 122: Introduction to Computer Networks
Error Detection and Reliable Transmission
Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley Berkeley, CA 94720-1776 Katz, Stoica F04
High Level View
Goal: transmit correct information Problem: bits can get corrupted - Electrical interference, thermal noise Solution - Detect errors - Recover from errors • Correct errors • Retransmission already done this Katz, Stoica F04
2
Overview
Error detection & recovery Reliable Transmission Katz, Stoica F04
3
Error Detection
Problem: detect bit errors in packets (frames) Solution: add extra bits to each packet Goals: - Reduce overhead, i.e., reduce the number of redundancy bits - Increase the number and the type of bit error patterns that can be detected Examples: - Two-dimensional parity - Checksum - Cyclic Redundancy Check (CRC) - Hamming Codes Katz, Stoica F04
4
Two-dimensional Parity
Add one extra bit to a 7 parity) bit code such that the number of 1’s in the resulting 8 bits is even (for even parity, and odd for odd Add a parity byte for the packet Example: five 7-bit character packet, even parity
0110100 1011010 0010110 1110101 1001011 1000110 0 1 1 0 1 1
Katz, Stoica F04
5
How Many Errors Can you Detect?
All 1-bit errors Example: error bit
0110100 1011010 00 0 0110 1110101 1001011 1000110 0 1 1 0 1 1
odd number of 1’s Katz, Stoica F04
6
How Many Errors Can you Detect?
All 2-bit errors Example: error bits
0110100 1011010 00 0 011 1 1110101 1001011 1000110 1 0 1 1 0 1
odd number of 1’s on columns Katz, Stoica F04
7
How Many Errors Can you Detect?
All 3-bit errors Example: error bits
0110100 1011010 00 0 011 1 11 0 0101 1001011 1000110 1 0 1 1 0 1
odd number of 1’s on column Katz, Stoica F04
8
How Many Errors Can you Detect?
Most 4-bit errors Example of 4-bit error that is not detected: error bits
0110100 1011010 00 0 011 1 11 0 010 0 1001011 1000110 0 1 1 0 1 1
How many errors can you correct?
Katz, Stoica F04
9
Checksum
Sender: add all words of a packet and append the result (checksum) to the packet Receiver: add all words of a packet and compare the result with the checksum Can detect all 1-bit errors Example: Internet checksum Use 1’s complement addition Katz, Stoica F04
10
1’s Complement Revisited
Negative number –x is x with all bits inverted When two numbers are added, the carry-on is added to the result Example: -15 + 16; assume 8-bit representation 15 = 00001111 -15 = 11110000 + 16 = 00010000 1 00000000 + 1 00000001 -15+16 = 1 Katz, Stoica F04
11
Cyclic Redundancy Check (CRC)
Represent a (n+1)-bit message as an n-degree polynomial M(x) - E.g., 10101101 M(x) = x 7 + x 5 + x 3 + x 2 + x 0 Choose a divisor k-degree polynomial C(x) Compute reminder R(x) of M(x)*x k such that / C(x), i.e., compute A(x)
M(x)*x k = A(x)*C(x) + R(x)
, where degree(R(x)) < k Let
T(x) = M(x)*x k – R(x) = A(x)*C(x)
Then - T(x) is divisible by C(x) - First n coefficients of T(x) represent M(x) Katz, Stoica F04
12
Cyclic Redundancy Check (CRC)
Sender: - Compute and send T(x), i.e., the coefficients of T(x) Receiver: Let T’(x) be the (n+k)-degree polynomial generated from the received message If C(x) divides T’(x) no errors; otherwise errors Note: all computations are modulo 2 Katz, Stoica F04
13
Arithmetic Modulo 2
Like binary arithmetic but without borrowing/carrying from/to adjacent bits Examples: 101 + 010 111 101 + 001 100 1011 + 0111 1100 101 010 111 101 001 100 1011 0111 1100 Addition and subtraction in binary arithmetic modulo 2 is equivalent to XOR a b a b 0 0 1 1 0 1 0 1 0 1 1 0 Katz, Stoica F04
14
Some Polynomial Arithmetic Modulo 2 Properties
If C(x) divides B(x), then degree(B(x)) >= degree(C(x)) Subtracting/adding C(x) from/to B(x) modulo 2 is equivalent to performing an XOR on each pair of matching coefficients of C(x) and B(x) - E.g.: B(x) = x 7 + x 5 + x 3 + x 2 + x 0 (10101101) C(x) = x 3 + x 1 + x 0 (00001011) B(x) - C(x) = x 7 + x 5 + x 2 + x 1 (10100110) Katz, Stoica F04
15
Example (Sender Operation)
Send packet 110111; choose C(x) = 101 - k = 2, M(x)*x K 11011100 Compute the reminder R(x) of M(x)*x k / C(x) 101) 11011100 101 111 101 101 101 100 101 1 R(x) Compute T(x) = M(x)*x k - R(x) 11011100 xor 1 = 11011101 Send T(x) Katz, Stoica F04
16
Example (Receiver Operation)
Assume T’(x) = 11011101 C(x) divides T’(x) no errors Assume T’(x) = 110 0 1101 Reminder R’(x) = 1 error!
101) 11001101 101 110 101 111 101 101 101 1 R’(x) Note: an error is not detected iff C(x) divides T’(x) – T(x) Katz, Stoica F04
17
CRC Properties
Detect all single-bit errors if coefficients of x k x 0 of C(x) are one and Detect all double-bit errors, if C(x) has a factor with at least three terms Detect all number of odd errors, if C(x) contains factor (x+1) Detect all burst of errors smaller than k bits Katz, Stoica F04
18
Code words
Combination of the n payload bits and the k check bits as being a n+k bit code word For any error correcting scheme, not all n+k bit strings will be valid code words Errors can be detected if and only if the received string is not a valid code word Example: even parity check only detects an odd number of bit errors Katz, Stoica F04
19
Hamming Distance
Given code words A and B, the Hamming distance between them is the number of bits in A that need to be flipped to turn it into B E.g., H(011101,000000) = 4 If all code words are at least d Hamming distance apart, then up to d-1 bit errors can be detected Katz, Stoica F04
20
Error Correction
If all the code words are at least a hamming distance of 2
d
+1 apart then up to
d
bit errors can be corrected Just pick the codeword closest to the one received!
How many bits are required to correct
d
bits in the payload?
errors when there are
n
Example: or 100).
d
=1: Suppose
n
=3. Then any payload can be transformed into 3 other payload strings (e.g., 000 into 001, 010 Need at least two extra bits to differentiate between 4 possibilities In general need at least k ≥ log 2 (n+1) bits A scheme that is optimal is called a perfect parity code Katz, Stoica F04
21
Perfect Parity Codes
Consider a codeword of n+k bits b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11… Parity bits are in positions 2 0 , 2 1 , 2 2 ,2 3 ,2 4 … b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11… A parity bit in position 2 h , checks all data bits b p such that if you write out p in binary, the h th place in p’s binary representation is a one Katz, Stoica F04
22
Example: (7,4)-Parity Code
n=4, k=3 - Corrects one error - log 2 (1+n) = 2.32 code k = 3, perfect parity Position Check:b 1 Check:b 2 Check:b 4 data payload = 1010 - For each error there is a unique combination of checks that fail - E.g., 3 rd bit is in error,:10 0 0 both b 2 and b 4 fail (single case in which only b 2 and b 4 fail) Position Check:b 1 Check:b 2 Check:b 4 b 1 1 x b 2 10 x b 3 b 4 b 5 b 6 b 7 11 100 101 110 111 x x x x x x x x x x b 1 1 1 b 2 10 0 1 b 4 0 1 0 11 100 101 110 111 1 0 0 1 1 0 1 1 0 0 Katz, Stoica F04
23
Overview
Error detection & recovery Reliable transmission Katz, Stoica F04
24
Reliable Transmission
Problem: obtain correct information once errors are detected Solutions: - Use error correction codes • E.g. perfect parity codes, erasure codes (see next) - Use retransmission (we have studied this already) Algorithmic challenges: - Achieve high link utilization, and low overhead Katz, Stoica F04
25
Error correction or Retransmission?
Error Correction requires a lot of redundancy Wasteful if errors are unlikely Retransmission strategies are more popular As links get reliable this is just done at the transport layer Error correction is useful when retransmission is costly (satellite links, multicast) Katz, Stoica F04
26
Content Encoding Received Content
(*Michael Luby slide)
Erasure Codes
Encoding
n blocks
Transmission Decoding
original n blocks n+k blocks >= n blocks Katz, Stoica F04
27
Example: Digital Fountain
Use erasure codes for reliable data distribution Intuition: - Goal is to fill the cup - Full cup = content recovered (*Michael Luby slide) Katz, Stoica F04
28
Erasure Coding Approaches
Reed-Solomon codes -Complex encoding/decoding algorithm and analysis Tornado codes -Simple encoding/decoding algorithm -Complexity and theory in design and analysis LT codes -Simpler design and analysis (*Michael Luby slide) Katz, Stoica F04
29
LT encoding
Content Choose 2 random content symbols XOR content symbols
2
Choose degree Insert header, and send Degree 3 4 1 2 Prob 0.055
0.3
0.1
0.08
Degree Dist.
(*Michael Luby slide) 100000 0.0004
Katz, Stoica F04
30
LT Encoding
Content Choose 1 random content symbol Copy content symbol
1
Choose degree Insert header, and send Degree 3 4 1 2 Prob 0.055
0.3
0.1
0.08
Degree Dist.
(*Michael Luby slide) 100000 0.0004
Katz, Stoica F04
31
LT Encoding
Content Choose 4 random content symbols XOR content symbols
4
Choose degree Insert header, and send Degree 3 4 1 2 Prob 0.055
0.3
0.1
0.08
Degree Dist.
(*Michael Luby slide) 100000 0.0004
Katz, Stoica F04
32
LT Decoding
Content (unknown) 1.
2.
Collect enough encoding symbols and set up graph between encoding symbols and content symbols to be recovered Identify encoding symbol of degree 1. STOP if none exists 3.
Copy value of encoding symbol into unique neighbor, XOR value of newly recovered content symbol into encoding symbol neighbors and delete edges emanating from content symbol 4. Go to Step 2.
(*Michael Luby slide) Katz, Stoica F04
33
LT Encoding Properties
Encoding symbols generated independently of each other Any number of encoding symbols can be generated on the fly Reception overhead independent of loss patterns - The success of the decoding process depends only on the degree distribution of received encoding symbols.
- The degree distribution on received encoding symbols is the same as the degree distribution on generated encoding symbols.
(*Michael Luby slide) Katz, Stoica F04
34
What Do You Need To Know?
Understand - 2-dimensional parity - CRC - Hamming codes Tradeoff between achieving reliability via retransmission vs. error correction Katz, Stoica F04
35