Reed–Solomon error correction
From Wikipedia, the free encyclopedia
Reed–Solomon error correction is an errorcorrecting code that works by oversampling a polynomial constructed from the data. The polynomial is evaluated at several points, and these values are sent or recorded. Sampling the polynomial more often than is necessary makes the polynomial overdetermined. As long as it receives "many" of the points correctly, the receiver can recover the original polynomial even in the presence of a "few" bad points.
Reed–Solomon codes are used in a wide variety of commercial applications, most prominently in CDs, DVDs and Bluray Discs, in data transmission technologies such as DSL & WiMAX, in broadcast systems such as DVB and ATSC, and in computer applications such as RAID 6 systems.
Contents[hide] 
[edit] Overview
Reed–Solomon codes are block codes. This means that a fixed block of input data is processed into a fixed block of output data. In the case of the most commonly used R–S code (255, 223) – 223 Reed–Solomon input symbols (each eight bits long) are encoded into 255 output symbols.
 Most R–S errorcorrecting code schemes are systematic. This means that some portion of the output codeword contains the input data in its original form.
 A Reed–Solomon symbol size of eight bits forces the longest codeword length to be 255 symbols.
 The standard (255, 223) Reed–Solomon code is capable of correcting up to 16 Reed–Solomon symbol errors in each codeword. Since each symbol is actually eight bits, this means that the code can correct up to 16 short bursts of error.
The Reed–Solomon code, like the convolutional code, is a transparent code. This means that if the channel symbols have been inverted somewhere along the line, the decoders will still operate. The result will be the complement of the original data. However, the Reed–Solomon code loses its transparency when the code is shortened (see below). The "missing" bits in a shortened code need to be filled by either zeros or ones, depending on whether the data is complemented or not. (To put it another way, if the symbols are inverted, then the zero fill needs to be inverted to a ones fill.) For this reason it is mandatory that the sense of the data (i.e., true or complemented) be resolved before Reed–Solomon decoding.
[edit] Definition
[edit] Overview
The key idea behind a Reed–Solomon code is that the data encoded is first visualized as a Gegenbauer polynomial. The code relies on a theorem from algebra that states that any k distinct points uniquely determine a univariate polynomial of degree, at most, k − 1.
The sender determines a degree k − 1 polynomial, over a finite field, that represents the k data points. The polynomial is then "encoded" by its evaluation at various points, and these values are what is actually sent. During transmission, some of these values may become corrupted. Therefore, more than k points are actually sent. As long as sufficient values are received correctly, the receiver can deduce what the original polynomial was, and hence decode the original data.
In the same sense that one can correct a curve by interpolating past a gap, a Reed–Solomon code can bridge a series of errors in a block of data to recover the coefficients of the polynomial that drew the original curve.
[edit] Mathematical formulation
Given a finite field F and polynomial ring F[x], let n and k be chosen such that . Pick n distinct elements of F, denoted . Then, the codebook C is created from the tuplets of values obtained by evaluating every polynomial (over F) of degree less than k at each x_{i}; that is,
C is a [n,k,n − k + 1] code; in other words, it is a linear code of length n (over F) with dimension k and minimum Hamming distance n − k + 1.
A Reed–Solomon code is a code of the above form, subject to the additional requirement that the set must be the set of all nonzero elements of the field F (and therefore, n =  F  − 1).
[edit] Remarks
For practical uses of Reed–Solomon codes, it is common to use a finite field F with 2^{m} elements. In this case, each symbol can be represented as an mbit value. The sender sends the data points as encoded blocks, and the number of symbols in the encoded block is n = 2^{m} − 1. Thus a Reed–Solomon code operating on 8bit symbols has n = 2^{8} − 1 = 255 symbols per block. (This is a very popular value because of the prevalence of byteoriented computer systems.) The number k, with k < n, of data symbols in the block is a design parameter. A commonly used code encodes k = 223 eightbit data symbols plus 32 eightbit parity symbols in an n = 255symbol block; this is denoted as a (n,k) = (255,223) code, and is capable of correcting up to 16 symbol errors per block.
The set {x_{1},...,x_{n}} of nonzero elements of a finite field can be written as {1,α,α^{2},...,α^{n − 1}}, where α is a primitive nth root of unity. It is customary to encode the values of a Reed–Solomon code in this order. Since α^{n} = 1, and since for every polynomial p(x), the function p(αx) is also a polynomial of the same degree, it then follows that a Reed–Solomon code is cyclic.
[edit] Reed–Solomon codes as BCH codes
Reed–Solomon codes are a special case of a larger class of codes called BCH codes. An efficient error correction algorithm for BCH codes (and therefore Reed–Solomon codes) was discovered by Berlekamp in 1968.
To see that Reed–Solomon codes are special BCH codes, it is useful to give the following alternate definition of Reed–Solomon codes.^{[1]}
Given a finite field F of size q, let n = q − 1 and let α be a primitive nth root of unity in F. Also let be given. The Reed–Solomon code for these parameters has code word (f_{0},f_{1},...,f_{n − 1}) if and only if α,α^{2},...,α^{n − k} are roots of the polynomial
 p(x) = f_{0} + f_{1}x + ... + f_{n − 1}x^{n − 1}.
With this definition, it is immediately seen that a Reed–Solomon code is a polynomial code, and in particular a BCH code. The generator polynomial g(x) is the minimal polynomial with roots α,α^{2},...,α^{n − k}, and the code words are exactly the polynomials that are divisible by g(x).
[edit] Equivalence of the two formulations
At first sight, the above two definitions of Reed–Solomon codes seem very different. In the first definition, code words are values of polynomials, whereas in the second, they are coefficients. Moreover, the polynomials in the first definition are required to be of small degree, whereas those in the second definition are required to have specific roots.
The equivalence of the two definitions is proved using the discrete Fourier transform. This transform, which exists in all finite fields as well as the complex numbers, establishes a duality between the coefficients of polynomials and their values. This duality can be approximately summarized as follows: Let p(x) and q(x) be two polynomials of degree less than n. If the values of p(x) are the coefficients of q(x), then (up to a scalar factor and reordering), the values of q(x) are the coefficients of p(x). For this to make sense, the values must be taken at locations x = α^{i}, for , where α is a primitive nth root of unity.
To be more precise, let
 ,
and assume p(x) and q(x) are related by the discrete Fourier transform. Then the coefficients and values of p(x) and q(x) are related as follows: for all , f_{i} = p(α^{i}) and .
Using these facts, we have: is a code word of the Reed–Solomon code according to the first definition
 if and only if p(x) is of degree less than k (because are the values of p(x)),
 if and only if v_{i} = 0 for i = k,...,n − 1,
 if and only if q(α^{i}) = 0 for i = 1,...,n − k (because q(α^{i}) = nv_{n − i}),
 if and only if is a code word of the Reed–Solomon code according to the second definition.
This shows that the two definitions are equivalent.
[edit] Properties of Reed–Solomon codes
The errorcorrecting ability of any Reed–Solomon code is determined by n − k, the measure of redundancy in the block. If the locations of the errored symbols are not known in advance, then a Reed–Solomon code can correct up to (n − k) / 2 erroneous symbols, i.e., it can correct half as many errors as there are redundant symbols added to the block. Sometimes error locations are known in advance (e.g., “side information” in demodulator signaltonoise ratios)—these are called erasures. A Reed–Solomon code (like any MDS code) is able to correct twice as many erasures as errors, and any combination of errors and erasures can be corrected as long as the relation is satisfied, where E is the number of errors and S is the number of erasures in the block.
The properties of Reed–Solomon codes make them especially wellsuited to applications where errors occur in bursts. This is because it does not matter to the code how many bits in a symbol are in error—if multiple bits in a symbol are corrupted it only counts as a single error. Conversely, if a data stream is not characterized by error bursts or dropouts but by random single bit errors, a Reed–Solomon code is usually a poor choice.
Designers are not required to use the "natural" sizes of Reed–Solomon code blocks. A technique known as “shortening” can produce a smaller code of any desired size from a larger code. For example, the widely used (255,223) code can be converted to a (160,128) code by padding the unused portion of the block (usually the beginning) with 95 binary zeroes and not transmitting them. At the decoder, the same portion of the block is loaded locally with binary zeroes. The DelsarteGoethalsSeidel^{[2]} theorem illustrates an example of an application of shortened Reed–Solomon codes.
In 1999 Madhu Sudan and Venkatesan Guruswami at MIT, published “Improved Decoding of Reed–Solomon and AlgebraicGeometry Codes” introducing an algorithm that allowed for the correction of errors beyond half the minimum distance of the code. It applies to Reed–Solomon codes and more generally to algebraic geometry codes. This algorithm produces a list of codewords (it is a listdecoding algorithm) and is based on interpolation and factorization of polynomials over GF(2^{m}) and its extensions.
[edit] History
The code was invented in 1960 by Irving S. Reed and Gustave Solomon, who were then members of MIT Lincoln Laboratory. Their seminal article was entitled "Polynomial Codes over Certain Finite Fields." When it was written, digital technology was not advanced enough to implement the concept. The first application, in 1982, of RS codes in massproduced products was the compact disc, where two interleaved RS codes are used. An efficient decoding algorithm for largedistance RS codes was developed by Elwyn Berlekamp and James Massey in 1969. Today RS codes are used in hard disk drive, DVD, telecommunication, and digital broadcast protocols.
[edit] Applications
[edit] Data storage
Reed–Solomon coding is very widely used in mass storage systems to correct the burst errors associated with media defects.
Reed–Solomon coding is a key component of the compact disc. It was the first use of strong error correction coding in a massproduced consumer product, and DAT and DVD use similar schemes. In the CD, two layers of Reed–Solomon coding separated by a 28way convolutional interleaver yields a scheme called CrossInterleaved Reed Solomon Coding (CIRC). The first element of a CIRC decoder is a relatively weak inner (32,28) Reed–Solomon code, shortened from a (255,251) code with 8bit symbols. This code can correct up to 2 byte errors per 32byte block. More importantly, it flags as erasures any uncorrectable blocks, i.e., blocks with more than 2 byte errors. The decoded 28byte blocks, with erasure indications, are then spread by the deinterleaver to different blocks of the (28,24) outer code. Thanks to the deinterleaving, an erased 28byte block from the inner code becomes a single erased byte in each of 28 outer code blocks. The outer code easily corrects this, since it can handle up to 4 such erasures per block.
The result is a CIRC that can completely correct error bursts up to 4000 bits, or about 2.5 mm on the disc surface. This code is so strong that most CD playback errors are almost certainly caused by tracking errors that cause the laser to jump track, not by uncorrectable error bursts.^{[3]}
Another product which incorporates Reed–Solomon coding is Nintendo's eReader. This is a videogame delivery system which uses a twodimensional "barcode" printed on trading cards. The cards are scanned using a device which attaches to Nintendo's Game Boy Advance game system.
Reed–Solomon error correction is also used in parchive files which are commonly posted accompanying multimedia files on USENET. The Distributed online storage service Wuala also makes use of Reed–Solomon when breaking up files.
[edit] Data transmission
Specialized forms of Reed–Solomon codes specifically CauchyRS and VandermondeRS can be used to overcome the unreliable nature of data transmission over erasure channels. The encoding process assumes a code of RS(N,K) which results in N codewords of length N symbols each storing K symbols of data, being generated, that are then sent over an erasure channel.
Any combination of K codewords received at the other end is enough to reconstruct all of the N codewords. The code rate is generally set to 1/2 unless the channel's erasure likelihood can be adequately modelled and is seen to be less. In conclusion N is usually 2K, meaning that at least half of all the codewords sent must be received in order to reconstruct all of the codewords sent.
Reed–Solomon codes are also used in xDSL systems and CCSDS's Space Communications Protocol Specifications as a form of Forward Error Correction.
[edit] Mail encoding
Paper bar codes such as PostBar, MaxiCode, Datamatrix and QR Code use Reed–Solomon error correction to allow correct reading even if a portion of the bar code is damaged.
[edit] Satellite transmission
One significant application of Reed–Solomon coding was to encode the digital pictures sent back by the Voyager space probe.
Voyager introduced Reed–Solomon coding concatenated with convolutional codes, a practice that has since become very widespread in deep space and satellite (e.g., direct digital broadcasting) communications.
Viterbi decoders
tend to produce errors in short bursts. Correcting these burst errors
is a job best done by short or simplified Reed–Solomon codes.
Modern versions of concatenated Reed–Solomon/Viterbidecoded convolutional coding were and are used on the Mars Pathfinder, Galileo, Mars Exploration Rover and Cassini missions, where they perform within about 1–1.5 dB of the ultimate limit imposed by the Shannon capacity.
These concatenated codes are now being replaced by more powerful turbo codes where the transmitted data does not need to be decoded immediately.
[edit] Sketch of the error correction algorithm
The following is a sketch of the main idea behind the error correction algorithm for Reed–Solomon codes.
By definition, a code word of a Reed–Solomon code is given by the sequence of values of a lowdegree polynomial over a finite field. A key fact for the error correction algorithm is that the values and the coefficients of a polynomial are related by the discrete Fourier transform.
The purpose of a Fourier transform is to convert a signal from a time domain to a frequency domain or vice versa. In case of the Fourier transform over a finite field, the frequency domain signal corresponds to the coefficients of a polynomial, and the time domain signal correspond to the values of the same polynomial.
As shown in Figures 1 and 2, an isolated value in the frequency domain corresponds to a smooth wave in the time domain. The wavelength depends on the location of the isolated value.
Conversely, as shown in Figures 3 and 4, an isolated value in the time domain corresponds to a smooth wave in the frequency domain.

In a Reed–Solomon code, the frequency domain is divided into two regions as shown in Figure 5: a left (lowfrequency) region of length k, and a right (highfrequency) region of length n − k. A data word is then embedded into the left region (corresponding to the k coefficients of a polynomial of degree at most k − 1), while the right region is filled with zeros. The result is Fourier transformed into the time domain, yielding a code word that is composed only of low frequencies. In the absence of errors, a code word can be decoded by reverse Fourier transforming it back into the frequency domain.
Now consider a code word containing a single error, as shown in red in Figure 6. The effect of this error in the frequency domain is a smooth, singlefrequency wave in the right region, called the syndrome of the error. The error location can be determined by determining the frequency of the syndrome signal.
Similarly, if two or more errors are introduced in the code word, the syndrome will be a signal composed of two or more frequencies, as shown in Figure 7. As long as it is possible to determine the frequencies of which the syndrome is composed, it is possible to determine the error locations. Notice that the error locations depend only on the frequencies of these waves, whereas the error magnitudes depend on their amplitudes and phase.
The problem of determining the error locations has therefore been reduced to the problem of finding, given a sequence of n − k values, the smallest set of elementary waves into which these values can be decomposed. It is known from digital signal processing that this problem is equivalent to finding the roots of the minimal polynomial of the sequence, or equivalently, of finding the shortest linear feedback shift register (LFSR) for the sequence. The latter problem can either be solved inefficiently by solving a system of linear equations, or more efficiently by the BerlekampMassey algorithm.

[edit] See also
 Forward error correction
 BCH code
 Lowdensity paritycheck code
 Chien search
 Datamatrix
 Tornado codes
 Finite ring
[edit] References
 ^ Lidl, Rudolf; Pilz, Günter (1999). Applied Abstract Algebra (2nd ed.). Wiley. p. 226.
 ^ "Kissing Numbers, Sphere Packings, and Some Unexpected Proofs", Notices of the American Mathematical Society, Volume 51, Issue 8, 2004/09. Explains the DelsarteGoethalsSeidel theorem as used in the context of the error correcting code for compact disc.
 ^ K.A.S. Immink, Reed–Solomon Codes and the Compact Disc in S.B. Wicker and V.K. Bhargava, Edrs, Reed–Solomon Codes and Their Applications, IEEE Press, 1994.
 F. J. MacWilliams and N. J. A. Sloane, The Theory of ErrorCorrecting Code, New York: NorthHolland Publishing Company, 1977.
 Irving S. Reed and Xuemin Chen, ErrorControl Coding for Data Networks", Boston: Kluwer Academic Publishers, 1999.
[edit] External links
 MIT OpenCourseWare 6.451  Principles of Digital Communication II  Lecture 10 on Reed Solomon Codes
 Schifra Open Source C++ Reed–Solomon Codec
 A collection of links to books, online articles and source code
 Henry Minsky's RSCode library, Reed–Solomon encoder/decoder
 A Tutorial on Reed–Solomon Coding for FaultTolerance in RAIDlike Systems
 A Tutorial on Reed–Solomon Codes
 A thesis on Algebraic softdecoding of Reed–Solomon codes. It explains the basics as well.
 Matlab implementation of errorsanderasures ReedSolomon decoding
 FEC (Forward Erasure Encoding) Open Source Library (with Python bindings)
 Use ReedSolomon codes to shield your files from bad sectors