Digital Communication Systems ECS 452 Asst. Prof. Dr. Prapun Suksompong [email protected] 5. Channel Coding (A Revisit)

Office Hours: BKD, 4th floor of Sirindhralai building Monday 14:00-16:00 Thursday 10:30-11:30

1 Friday 12:00-13:00 Review of Section 3.6  We mentioned the general form of channel coding over BSC.  In particular, we looked at the general form of block .  (n,k) codes: n-bit blocks are used to conveys k-info-bit block over BSC.  Assume n > k  Rate: .  We showed that the minimum distance decoder is the same as the ML decoder.  This chapter: less probability analysis; more on explicit codes.

2 GF(2)  The construction of the codes can be expressed in matrix form using the following definition of addition and multiplication of bits:

 These are modulo-2 addition and modulo-2 multiplication, respectively.  The operations are the same as the exclusive-or (XOR) operation and the AND operation.  We will simply call them addition and multiplication so that we can use a matrix formalism to define the .  The two-element set {0, 1} together with this definition of addition and multiplication is a number system called a or a Galois field, and is denoted by the label GF(2). 3 GF(2)  The construction of the codes can be expressed in matrix form using the following definition of addition and multiplication of bits:

 Note that x  0  x x 1  x xx  0

The above property implies x  x Something that when added with x, gives 0. 4 Channel

X BSC Y

 Again, to transmit k information bits, the channel is used n times.

b Encoder x BSC y 1 k 1 n y  xe

Error pattern Its nonzero elements mark the 5 positions of transmission error in y Linear Block Codes  Definition:  is a binary if and only if  forms

a vector (sub)space (over GF(2)). In case you forgot about the concept of vector space,…  Equivalently, this is the same as requiring that f and  then  

 Note that any (non-empty) linear code  must contain 0.

 Ex. The code that we considered in HW4 is  00000,01000,10001,11111 Is it a linear code?

6 Linear Block Codes  Why linear block codes are popular?  Linearity  easier implementation and analysis  Performance of the class of linear block codes is similar to performance of the general class of block codes.  Can limit out study to the subclass of linear block codes without sacrificing system performance.

 Next: Matrix representation

7 Matrix representation of Linear Block Codes  g   1   Generator matrix:  g  G   2  k mod-2 summation    xbG bj g   j  g  j1 k  kn Any codeword can be expressed as a linear combination of the rows of G  Repetition code: G  11 1 k 1 xbGbb b R   nn  Single-parity-check code: GI1  ; T   kk   k  kk xbG b ; bj  R   nk1 8  j1  parity bit Vectors representing 3-bit codewords

Triple-repetition code Parity-check code

9 Related Idea: Even Parity vs. Odd Parity  Parity bit checking is used occasionally for transmitting ASCII characters, which have 7 bits, leaving the 8th bit as a parity bit.  Two options:  Even Parity: Added bit ensures an even number of 1s in each codeword.  A: 10000010 Note: The generator matrix on the previous page produces even parity.  Odd Parity: Added bit ensures an odd number of 1s in each codeword.  A: 10000011  If an odd number of bits (including the parity bit) are transmitted incorrectly, the parity bit will be incorrect, thus indicating that a parity error occurred in the transmission.

10  Suitable for detecting errors; cannot correct any errors Error Detection  Two types of error control: 1. error detection 2. error correction  Error detection: the determination of whether errors are present in a received word.  An error pattern is undetectable if and only if it causes the received word to be a valid codeword other than that which was transmitted.  Ex: In single-parity-check code, error will be undetectable when the number of bits in error is even.

11 Error Correction  In FEC (forward error correction) system, when the decoder detects error, the arithmetic or algebraic structure of the code is used to determine which of the valid code words is most likely to have been sent, given the erroneous received word.

 It is possible for a detectable error pattern to cause the decoder to select a codeword other than that which was actually transmitted. The decoder is then said to have

12 committed a decoder error. Square array for error correction by parity checking.  The codeword is formed by arranging k message bits in a square array whose rows and columns are checked by parity bits.  A transmission error in one message bit causes a row and column parity failure with the error at the intersection, so single errors can be corrected.

13 [Carlson & Crilly, p 594] Weight and Distance  The weight of a codeword or an error pattern is the number of nonzero coordinates in the codeword or the error pattern.  The weight of a codeword is commonly written as .  The between two n-bit blocks is the number of coordinates in which the two blocks differ.

 The minimum distance (dmin) of a block code is the minimum Hamming distance between all distinct pairs of codewords. HW3 Q2a:

14 Minimum distance: Two important facts

 For any linear block code, the minimum distance (dmin) can be found from minimum weight of its nonzero codewords.  So, instead of checking 2 pairs, simply check the weight of 2 the 2 codewords.

 A code with minimum distance dmin can

 detect all error patterns of weight w ≤ dmin-1.  correct all error patterns of weight w ≤ .

the floor function

15 Minimum distance is an important quantity

 To be able to detect all w-bit errors, we need 1.  With such a code there is no way that w errors can change a valid codeword into another valid codeword.  When the receiver observes an illegal codeword, it can tell that a transmission error has occurred.

 To be able to correct all w-bit errors, we need 21.  This way, the legal codewords are so far apart that even with w changes the original codeword is still closer than any other codeword.

16 Example Consider the code  0000000000, 0000011111, 1111100000, and 1111111111  Is it a linear code?

 dmin =

 It can detect (at most) ___ errors.

 It can correct (at most) ___ errors.

17 Hamming codes  One of the earliest codes studied in .  Named after Richard W. Hamming  The IEEE Richard W. Hamming Medal, named after him, is an award given annually by Institute of Electrical and Electronics Engineers (IEEE), for "exceptional contributions to information sciences, systems and technology“.  Sponsored by Qualcomm, Inc  Some Recipients:  1988 - Richard W. Hamming  1997 -Thomas M. Cover  1999 - David A. Huffman  2011 -Toby Berger  The simplest of a class of (algebraic) error correcting codes that can correct one error in a block of bits

18 Hamming codes

19 [https://www.youtube.com/watch?v=cBBTWcHkVVY] Hamming (7,4) code

In the video, the codeword is constructed from the data by p1

d1 d2 where d4 p2 d3 p3

20 Generator matrix: a revisit  Fact: The 1s and 0s in the jth column of G tells which positions of the data bits are combined (⊕) to produce the jth bit in the codeword.  For the in the previous slide,

x  pd11 pd 2 2 pdd 33 4

11    00  dddd  123410    10 

21 G

Systematic Encoding  Code constructed with distinct information bits and check bits in each codeword are called systematic codes.  Message bits are “visible” in the codeword.  Popular forms of G: GI P xGb bb bP I  knkk 1 2 k  knkk 

 xx1 2  xnk bb1 2  bk xnk 1 xnk 2 xn

GI P xGb b b  b  IP  k knk 1 2 k  k knk 

 b12b  bk xk1 xk 2  xn x x x 22 1 2 k Parity check matrix  T Key property: GH  0knk  For the generators matrices we discussed earlier, the corresponding parity check matrix can be found easily: GP  I HI PT  knkk  nk 

I Check: GHT  P I P P 0  knk -P

GIP HPI T  k knk  nk  23 Hamming codes: Parameters  number of parity bits   

 dmin = 3.  Error correcting capability:

24 Construction of Hamming Codes  Here, we want Hamming code whose . 1. Parity check matrix H:  Construct a matrix whose columns consist of all nonzero binary m-tuples.  The ordering of the columns is arbitrary. However, next step is easy when the columns are arranged so

that HI   m P  . 2. Generator matrix G:  HI P  TT  When  m  , we have GPIPI   kk    .

25 Example: (7,4) Hamming Codes

1000111 H  01 01 011   0011101

0111000 1010100 G    1100010   1110001

26 Syndrome Table Decoding When is observed at the decoder, decoding is performed by 1. Compute the syndrome vector: . 2. Find the corresponding error pattern for , and subtracting the error pattern from .  Note that   .

h1     n h2 TT T T Hvvv 12 n  seHe v   j j   j1 h   nk nk n Linear combination of the columns of H 27 Example: (7,4) Hamming Codes

1000111 H  01 01 011 Syndrome decoding table:   0011101 Error pattern e Syndrome = eH T n T (0,0,0,0,0,0,0) (0,0,0) seHe j vj j1 (0,0,0,0,0,0,1) (1,1,1)

Linear (0,0,0,0,0,1,0) (1,1,0) combination of the columns of H (0,0,0,0,1,0,0) (1,0,1) (0,0,0,1,0,0,0) (0,1,1) Note that for an error pattern with a single one in the jth (0,0,1,0,0,0,0) (0,0,1) coordinate position, the (0,1,0,0,0,0,0) (0,1,0) syndrome is the same as the jth column of H. (1,0,0,0,0,0,0) (1,0,0) 28 Hamming Codes: Decoding Algorithm

1. Compute the syndrome for the received word. If , then go to step 4. 2. Determine the position j of the column of H that is the transposition of the syndrome. 3. Complement the jth bit in the received word. 4. Output the resulting codeword and STOP.

29 Hamming Codes: The original method  Encoding  The bit positions that are powers of 2 (1, 2, 4, 8, 16, etc.) are check bits.  The rest (3, 5, 6, 7, 9, etc.) are filled up with the k data bits.  Each check bit forces the parity of some collection of bits, including itself, to be even (or odd).  To see which check bits the data bit in position i contributes to, rewrite i as a sum of powers of 2. A bit is checked by just those check bits occurring in its expansion  Decoding  When a codeword arrives, the receiver initializes a counter to zero. It then examines each check bit at position i (i = 1, 2, 4, 8, ...) to see if it has the correct parity.  If not, the receiver adds i to the counter. If the counter is zero after all the check bits have been examined (i.e., if they were all correct), the codeword is accepted as valid. If the counter is nonzero, it contains the position of the incorrect bit.

30 Hamming codes are “perfect”!  A Hamming sphere of radius r centered at a codeword x is a collection of all possible (n-bit) vectors that are at a Hamming distance from x.   Let be the number of vectors in a Hamming sphere with radius r.  is the “volume” of the Hamming sphere with radius r. 

31 and Perfect Code  Hamming bound: Any t-error correcting code must have the number m of parity bits that satisfies log .  Proof:  Key Idea: If the code is to correct up to t errors, then the code must have the property that all the 2k Hamming spheres of radius t centered at the codewords are nonoverlapping. programs/sphere-packing/ http://alecjacobson.com/  Definition: A block code is perfect if it satisfies the Hamming bound with equality.  In such a code the Hamming spheres (about all the codewords) not only are nonoverlapping but they exhaust all the 2n possibilities. 32 Hamming codes are “perfect”!  Perfect codes exist in only a comparatively few cases.  All odd-length binary repetition codes are perfect.

 No even-length binary repetition code can be perfect.  Hamming code family is the only family of binary, single- error correcting perfect linear block codes.

33 Reference  Section 13.2 in [C&C]

30