Held Friday, February 18, 2000
Overview
Today we continue our discussion of error detection and
error correction.
Notes
- I will be out of town all next week on a family emergency. On Monday,
Mr. Stone will discuss processes in Unix and how to manage them in C.
On Wednesday and Friday, Mr. Walker will
provide a more in-depth view of Unix sockets. I probably won't
return your assignment 2's until after I return.
- New Assignments:
- Assignment 3:
Reusing Linked Lists
- Assignment 4::
The Data-Link Layer
- Read Section 1 of Stevens.
- Start reading Section 2 of Stevens.
Contents
Summary
- Framing, revisited
- Error-detecting codes
- Error-correcting codes
- How does the recipient know that the frame it received is correct?
- What kinds of errors can we get?
- Bits can flip
- Can bits be lost?
- Is it usally single bits or sequences of bits?
- The sender could send two copies. If they didn't match, the
recipient could assume they were incorrect.
- Of course, if the same bit is flipped in both copies, there's
no way to detect the error.
- There is also a lot of overhead, since we're sending two bits
for every bit of real information.
- A simple solution is to use a parity bit. Every n
bits, you count up the number of 1's and add a 1 or a 0 depending on
whether the count is even or odd.
- A single parity bit catches only one odd numbers of one-bit errors.
- In particular, it misses two one-bit errors.
- It may be helpful to use two-dimensional parity, in which
you arrange your data in a grid and compute parity for each row and
each column.
- This technique always catches three or few one-bit errors. (Proof?)
- It is also likely to catch more errors.
- A better technique is to use a cyclic redundancy check.
We treat the data as an n-degree polynomial.
- For example, 1001 is x^{3} + 1
- Similarly, 100100 is x^{5} + x^{2}
- We choose a special k-degree polynomial for this technique.
- (The technique requires k check bits.)
- Smart mathematicians come up with t hose polynomials.
- The algorithm:
- Add k 0's to the end of the data.
- Divide by the special polynomial. The remainder must have
degree k-1 or less.
- Subtract the remainder from the extended data.
- The result must be divisible by the special polynomial.
- The recipient can divide by the special polynomial. If the
result is non-0, the data were corrupted.
- Since the remainder has k or fewer bits, the subtraction
does not affect the original n bits.
- This catches:
- Single-bit errors, provided the polynomial contains both
a degree-k term and degree -0 term.
- Any two one-bit errors, provided the polynomial contains at
least three terms.
- Any odd number of one-bit errors, as long as x+1 divides
the polynomial.
- Burst errors of less than k bits
- Can you explain why?
- Here are the most common CRC polynomials
- CRC-8: x^{8} +
x^{2} +
x^{1} +
1
- CRC-10: x^{10} +
x^{9} +
x^{5} +
x^{4} +
1
- CRC-12: x^{12} +
x^{11} +
x^{3} +
x^{2} +
1
- CRC-16: x^{16} +
x^{15} +
x^{2} +
1
- CRC-CCITT: x^{16} +
x^{12} +
x^{5} +
1
- Note: all CRC calculations are done with XOR, bit shifts, and
similarly simple operations. This means that we can (and should)
implement it all in hardware!
- What do we do once we've detected an error?
- Inform the sender to get another copy
- Hope that there's enough information to resolve the error.
- Peterson and Davie tell us that it's not worth the overhead for
error-correcting codes. However, it's worth spending a little
time on them.
- The most common error-correcting codes rely on what is called
the Hamming distance.
- The Hamming distance of two bit equal-length bit strings is
the number of bits you have to flip to convert one string to
the other.
- We'll draw a graph and a chart for three-bit strings.
- To correct one bit errors, we choose a set of strings such that
no two strings have a Hamming distance less than three
- Each represents some sequence of bits. If there are
four codes, we can represent pairs of bits.
- Convert from the sequence to the code.
- Send the code.
- Decode. If you don't have the original string, use the closest
one.