Docsity

Linear Block Codes, Rectangular Codes, and Hamming Codes: MIT 6.02 Notes, Lecture notes of Communications Engineering

Partial preview of the text

Download Linear Block Codes, Rectangular Codes, and Hamming Codes: MIT 6.02 Notes and more Lecture notes Communications Engineering in PDF only on Docsity!

6.02 F^

6.02 Fall 2012^ Lecture #4 • Linear block codes • Rectangular codes • Hamming codes

all 2012^

Lecture 4, Slide

Single Link Communication Model End-host

6.02 Fall 2012 Lecture 4, Slide #

Original source Source coding(if needed) Digitize Source binary digits(“message bits”) Bit stream

Receiving app/user Source decoding Render/display,etc. correction)(bit error^ ChannelCoding^ Bits^ samplesMapperXmit+ (Voltages)Signalsover DemappersamplesRecv+^ Bit stream physical link (reducing orbit errors)Decodingremoving^ Channel

computers Bits

6.02 Fall 2012^

Lecture 4, Slide #

If d is the minimum Hamming distance betweencodewords, we can: •^ detect^ all

patterns of up to t bit errorsif and only if^ d ≥ t+

-^ correct^ all

patterns of up to t bit errorsif and only if^ d ≥ 2t+

-^ detect^ all

patterns of up to t

bit errorsD^ while correcting all patterns of t

(

Linear Block Codes

Block code:

k^ message bits encoded to

n^ code bits

i.e., each of

k^ 2 messages encoded into a unique

n-bit

codeword via a

linear transformation. Key property:

Sum of any two codewords is

also^ a

codeword^ 

necessary and sufficient for code to be linear. (n,k)^ code has rate

k/n. Sometime written as

(n,k,d) , where

d^ is the minimum

Hamming Distance of the code. 6.02 Fall 2012^

Lecture 4, Slide #

(n,k) Systematic Linear Block Codes • Split data into^

k -bit blocks

-^ Add ( n-k ) parity bits to each block using (

n-k ) linear

equations, making each block

n^ bits long

-^ Every linear code can be represented by an equivalentsystematic form --- ordering is not significant, directinclusion of k message bits in n-bit codeword is. •^ Corresponds to using invertible transformations onrows and permutations on columns of G to get •^ G = [I | A] --- identity matrix in the first k columns^ 6.02 Fall 2012^

Lecture 4, Slide # Message bits^ kn-k Parity bitsn

6.02 Fall 2012^

Lecture 4, Slide #

Example: Rectangular Parity Codes

DDP^1 21 DD^3 4 P^ P^3

P^ is parity bit^1 for row #

Idea: start with rectangulararray of data bits, add paritychecks for each row andcolumn.^ Single-bit error indata will show up as parity

P^2 (n,k,d)=?

errors in a particular rowand column, pinpointing the

P^ is parity bit^4

bit that has the error.

for column #

0 1 1^

0 1 1^

0 1 1

1 1 0^

1 0 0^

1 1 1

1 0^

1 0^

1 0

Parity for each row

Parity check fails for

Parity check only fails

and column is^

row #2 and column #

for row #

correct^ ⇒^ no errors

⇒^ bit D^ is incorrect^4

⇒^ bit P^2

is incorrect

Matrix Notation

Task: given k-bit message, compute n-bit codeword.

We can

use standard matrix arithmetic (modulo 2) to do the job.

For

example, here’s how we would describe the (9,4,4) rectangularcode that includes an overall parity bit.^1

0 0 0 1 0

1 0 1 0 1 0 0 1 0

⎥ 0 1 1 DDDD [^ ]^1 2 3

⎥ =^ D^ D^ D^

D [ P^ P^ P^ P

P^ ]

0 0 1 0 0 1

(^1) ⎥ (^1 0 ) 2 3 4 1

2 3 4 5 ⎥ 0 0 0 1 0 1

0 1 1 6.02 Fall 2012^

Lecture 4, Slide # ⎤ ⎦ ⎡ ⎢ ⎢•⎢ ⎢ ⎣ 1×k k×n^

1×n

message^

generator^

code word

vector^

matrix^

vector

The generator matrix,

G=^ kxn^

I^ Ak × k^ k ×

( n − k^ )

⎡ ⎢^ ⎣

D ⋅^ G =^1 xk^ kxn^

C^1 xn

Decoding Rectangular Parity Codes Receiver gets possibly corrupted word,

w.

Calculates all the parity bits from the data bits.If no parity errors, return

rc^ bits of data. Single row or column parity bit error

^ rc^ data

bits are fine, return themIf parity of row

x^ and parity of column

y^ are in

error, then the data bit in the

( x , y )^ position is wrong; flip it and return the

rc^ data bits All other parity errors are

uncorrectable

.^ Return

the data as-is, flag an “uncorrectable error” 6.02 Fall 2012^

Lecture 4, Slide #

How Many Parity Bits Do Really We Need? •^ We have^ n-k

parity bits, which collectively can represent^^2

n-k^ possibilities

-^ For^ single-bit error

correction, parity bits need to represent two sets of cases:^ –^ Case 1: No error has occurred (1 possibility)^ –^ Case 2: Exactly one of the code word bits has anerror ( n^ possibilities, not

k )

-^ So we need

n-k n+1 ≤ 2 n ≤ 2

n-k^ – 1

-^ Rectangular codes satisfy this with big margin ---inefficient 6.02 Fall 2012^

Lecture 4, Slide #

Hamming Codes

-^ Hamming codes correct single errors with theminimum number of parity bits:

n-k^ n = 2 – 1

-^ (7,4,3) •^ (15,11,3)m^ m •^ (2^ –1,^

-1-m,3)

-^ --- “perfect codes” (but not best!) 6.02 Fall 2012^

Lecture 4, Slide #

Logic Behind Hamming Code Construction •^ Idea: Use parity bits to cover each axis of thebinary vector space^ –^ That way, all message bits will be covered with a

unique

combination of parity bits 6.02 Fall 2012^

Lecture 4, Slide #

Index^1

3 4

5 6 7 Binary^001 010 index^

011 100

101 110 111 (7,4)^ P1^ P2 code

D1^ P^

D2^ D3^ D4 P with binary index 00 1

1 covers

P^ = D^ +D+D^1 1

4 P^ = D^ +D+D^2 1

D 4 with binary index 01 1

1

P= D^ +D+D^3 2

D 4 with binary index 10 2

1 Dwith binary index 11^4

1

6.02 Fall 2012^

Lecture 4, Slide #

Syndrome Decoding: Idea • After receiving the possibly corrupted message (use’ to indicate possibly erroneous symbol), compute a syndrome^ bit (E^ ) for each parity biti • If all the E^ are zero: no errorsi^ • Otherwise use the particular combination of the E

i

E^ = D’^ + D’^1 1 to figure out correction

+ D’+ P’ 2 4 1

E^ = D’^ + D’^2

+ D’+ P’ 3 4 2

E^ = D’^ + D’^3

+ D’+ P’ 3 4 3

0 = D+D+D^1

+P^4

0 = D+D+D^1

+P^4

0 = D+D+D^2

+P^4

Index^1

3 4 5

6 7 Binary^001 010 index^

011 100 101

110 111 (7,4)^ P1^ P2^ code

D1^ P3^ D^

D3^ D

Elementary Combinatorics • Given n objects, in how many ways can we choosem of them?If the ordering of the m selected objects matters, thenn(n-1)(n-2) … (n-m+1) = n!/(n-m)!If the ordering of the m selected objects doesn’tmatter, then the above expression is too large by afactor m!, so^ ⎛ n^

⎞^ n! “n choose m” =

⎜^ ⎟ = m (⎝⎠^

n^ −^ m )! m! 6.02 Fall 2012^

Lecture 4, Slide #

Error-Correcting Codes occur in many

other contexts too

-^ e.g., ISBN numbers for books,0-691-12418-3(Luenberger’s

Information Science

)

-^ 1D^ + 2D^1

+3D+…+10D 2 3

= 0 mod 11 10 Detects single-digit errors, and transpositions 6.02 Fall 2012^

Lecture 4, Slide #