Rectangular Codes Rule: take intersection of row-column parity error(s) – single error correction (double error detection) m1 n1 message bits x column parity bits row parity bits excess bit redundancy 1 1 1 n 1 m 1 (n 1)( m 1) x corner bit (use even parity checking) If n = m (square): (n − 1)² message bits + (2n − 1) check bits = n² total Example: n = 11, 21% overhead 3.2 Triangular Codes Rule: intersection of parity errors – single error correction (no double error detection). A single parity error implies the error was on the diagonal itself. n1 message bits x x diagonal parity checks n1 excess bit redundancy 2 n 1 both row and column sum to even parity (see book) n(n − 1)/2 message bits + n check bits = n(n + 1)/2 total 3.3 Hyper-dimensional Codes Arrange the bits in a cube, and include check bits not in every linear dimension, but every plane. So we get three edges of check bits, which intersect in a single point. Total of n³ = (3n − 2) check bits + message. excess bit redundancy ~ 3 / n² Four-dimensional: check over hyperplanes (cubes) excess bit redundancy ~ 4 / n³ k=1 b b b b k=2 k=3 3.3 cont. Hypercubes More generally, consider a k-dimensional n-cube. There are n (k−1) dimension hyperplanes in each of the k directions (each are parity checked), for a total of n × k bits. Overhead is hence ~ nk / nk = k / nk−1. So keeping m = nk fixed, overhead is ~ k∙k√m. This has a minimum when its (natural) logarithm does: log k + (ln m) / k. Taking derivatives: 1/k − (ln m)/k² = 0 implies k = ln m is the optimal dimension, making n = e. This is almost the highest dimensional space possible, since n must be at least two. So try using a k-dimensional 2-cube, with n = 2k bits. One parity check in each direction means each of the k different ways of splitting the cube has even parity. 3.3 cont. Hamming Code Design a code so the sequence of parity error bits (called syndrome) address (point to) the erroneous bit. All zero’s is no error. If we number the parity checks pm, ..., p1, where pi = (1 for an error / 0 for no error), then they can point to 2m 1 erroneous bits. If we use a total of n bits, we must have n ≤ 2m 1 to correct an error in any possible location. Clearly, each parity check pi must sum over all positions i in the string such that the jth bit of i is one: In order for x1, …, xn to be a valid code word, it must include both message bits and the proper check bits. The most convenient choice is to locate them at positions 2j-1 in the word x1, …, xn according to the formula: x2j-1 = ∑ {xi : i = (bm… b1)two & bj = 1} mod 2 3.4 Example n = 7, m = 3; parity bit positions: 1, 2, 4. 7 3 = 4 message bits at positions 3, 5, 6, 7. positions x1 x2 x3 x4 x5 x6 x7 message - - 1 - 0 1 1 Codeword sent 0 1 1 0 0 1 1 0 0 1 1 error Codeword received 0 p1 = x 1 + x 3 + x 5 + x 7 = 1 p2 = x 2 + x 3 + x 6 + x 7 = 1 x 1 0 Turn 90 (011)two p3 = x 4 + x 5 + x 6 + x 7 = 0 error in position 3 Alternatively 1 = x2 → 0 1 0 1 = x6 → 1 1 0 1 = x7 → 1 1 1 0 1 1 3.4 Hamming distance Let x ( x1 ,, xn ) and y ( y1 ,, yn ) be binary wor ds. n Then d ( x , y ) xi yi is called the Hamming distance. i 1 This is the number of places that they differ (same as L0 norm in F2). Any metric must satisfy : A. d (x, x) 0 B. d ( x , y ) d ( y, x ) C. d ( x, y) d ( y, z ) d ( x , z ) The minimum distance between allowable code words is: 1 For uniqueness 2 single-error detection 3 single-error correction 4 double-error detection corresponds to performance of code 5 double-error correction The sphere of radius r about x is Sr ( x ) y d ( x , y ) r . n n n r n It' s volume S0 S1 Sr 1 1 2 r i 0 i 3.6 Sphere packing For single error correction, with minimum distance = 3, the spheres of radius one around each code word must not overlap: k = # of message bits 2 k nm n = total number of bits m = # of check bits Total volume 2n # code words n 1 2m Sphere volume n 1 double error correction has non-overlapping spheres of radius 2: 2 nm 2n n(n 1) “Density” corresponds 1 2 m to efficiency of code n(n 1) 2 1 n 2 When equality is achieved, the code is said to be “perfect”. E.g. double-error correcting with m = 12, n = 90. 3.6 Double – Error Detection Hamming code would cause 3 errors in a doubleerror situation. But if we add an extra parity check bit over the entire word we can detect double errors: x0 x1, …, xn Algebraic approach x0 = ∑ {xi : i = 1 … n} mod 2 Hamming syndrome extra check meaning 0 0 correct 0 1 error in x0 i≠0 1 error in xi ≠0 0 double error Geometric approach – In the original code, points of distance 3 from each other have a different # of 1’s in them (mod 2) since they differ in 3 positions, so their extra parity checks will be set differently, and now they will differ in 4 positions! 3.7 Hamming Codes on Words Think of doing parity checks over entire words, using a logical sum. 0 0 0 represents no parity error a check = anything else represents a parity error The same syndrome technique locates the erroneous word. Any of the parity check failure words could now be added to the erroneous word to correct it. parity bit character Consider the ASCII code with each 8-bit word having a parity bit, and for each block of words, a checksum word. The parity check within a word locates the erroneous word, and the check sum bits locate the erroneous bit. ASCII code words x This is equivalent to a rectangular code checksum word x 3.8