error detection/correction code -...

37
Error Detection/Correction Code

Upload: others

Post on 26-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 2: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

강의의 목표

Error Detection/Correction의 기본 원리를 이해한다.

에러 검출 및 정정을 위한 Encoding/Decoding의 개념 이해

Parity Bit 기법을 이해한다.

Hamming Distance의 의미를 이해한다.

Error Detection/Correction Code 이론과 관련한 수학적 기초 개념을 이해

한다.

Field / Finite (Galois) Field

Modulo-2 Operation / Field of Polynomials

Vector Space

CRC (Cyclic Redundancy Code) 동작 방식을 이해하고 처리할 수 있다.

Hamming Code의 동작 방식을 이해하고 처리할 수 있다.

Channel Coding이 해결하려는 문제를 이해한다.

교재 Chapter 6. Digital Data Communication Techniques2

Page 3: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Let

𝒏 bit Codeword = 𝒌 bit Data + (𝒏 − 𝒌) bit Codebits

Legal codewords & Illegal codewords

No error : Legal codeword (Corresponding) Legal codeword

Error

• Legal codeword --> Illegal codeword (Detectable Error)

• Legal codeword --> Legal codeword (Undetectable Error)

Error Detection

(𝒏, 𝒌)

Legal Codewords

Illegal Codewords

A

B

C

A

Source Data

Codewords

2𝑘

2𝑛

3

Page 4: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Error Detection Process

4

Page 5: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Parity Code

Parity Code

Value of parity bit is such that character has

even (even parity) or odd (odd parity) number of ones

𝑛 = 𝑘 + 1, 𝑛, 𝑘 → (𝑘 + 1, 𝑘)

Even Parity Example

0010101 00101011, 0011110 00111100 : # of 1s even

Odd Parity Example

0010101 00101010, 0011110 00111101 : # of 1s odd

Parity Code는 1bit Error를 Detect할 수 있음

Even Parity의 경우 모든 Legal Codeword는 1의 개수가 짝수

만약 수신한 Codeword의 1의 개수가 홀수라면?

Error가 Parity Bit에서 발생하여도 Detect 할 수 있는가?

5

Page 6: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Error Correction using Parity Code

9 bits (𝑘 = 9)의 원본 데이터(𝑑1𝑑2 ⋯𝑑9)에 대해 (𝑝1𝑝2 ⋯𝑝6)의 6bits

Parity 구하자. 𝑛, 𝑘 = (15,9)

Even Parity / ⊕ − XOR

15bits의 Codeword에서 최대 1 bit의 Error가 발생할 수 있다고 할 때

수신한 정보가 다음과 같을 때 에러 발생 여부, 복원 여부를 확인하라.

𝑑1 𝑑2 𝑑3 𝑝1 = 𝑑1⨁𝑑2⨁𝑑3

𝑑4 𝑑5 𝑑6 𝑝2 = 𝑑4⨁𝑑5⨁𝑑6

𝑑7 𝑑8 𝑑9 𝑝3 = 𝑑7⨁𝑑8⨁𝑑9

𝑝4 = 𝑑1⨁𝑑4⨁𝑑7 𝑝5 = 𝑑2⨁𝑑5⨁𝑑8 𝑝6 = 𝑑3⨁𝑑6⨁𝑑9

1 0 1 0

1 1 1 1

1 0 0 0

1 0 0

1 1 1 1

0 0 0 0

1 0 1 0

0 1 0

1 1 0 0

1 0 1 1

0 1 1 0

0 0 0

6

Page 7: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Hamming Distance

𝑡 > 1 bits 이상의 Error Detection/Correction ?

Example

Hamming Distance 𝑑(𝑊1,𝑊2)

between two 𝑛-bits binary sequence 𝑊1 and 𝑊2 is the number of bits in which 𝑊1 and

𝑊2 disagree.

Ex) 𝑊1=011011, 𝑊2=110001 𝑑 𝑊1,𝑊2 = 𝜔(𝑊𝑖 ⊕ 𝑊𝑗)

Channel

Encoder Decoder

{10~19}

You can use only 4 basic arithmetic operations (+,-,*,/) for the encoder/decoder.

𝑥𝑠

𝑥𝑟 = 𝑥𝑠 ± 𝛼, 0 ≤ 𝛼 < 4, 𝛼 > 0 → ErrorCan transmit any integer but may experience error.

𝑥𝑟

Values you want to send.

𝑣𝑠 𝑣𝑟

7

Page 8: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Hamming Distance

For codewords 𝑊1,𝑊2, … ,𝑊𝑠 and 𝑑𝑚𝑖𝑛 = min𝑑(𝑊𝑖 , 𝑊𝑗)

if 𝑑𝑚𝑖𝑛 ≥ 2𝑡 + 1 then (1~𝑡) bits error can be corrected

if 𝑑𝑚𝑖𝑛 ≥ 2𝑡 then (1~𝑡 − 1) bits error can be corrected

• 𝑡 bits error can be detected, but not corrected generally

Example

1) Parity Code의 Hamming Distance ?

2) 오른쪽 표와 같은 Code의 Hamming Distance ?

• 𝑑 𝑊𝑖 ,𝑊𝑗 = 𝜔(𝑊𝑖 ⊕ 𝑊𝑗) ; 𝜔( )는 bit string 내의 1의 개수

• 00100 이란 Codeword를 수신한 경우 ?

d=4

d=5

Data Block Codeword

00 00000

01 00111

10 11001

11 11110

8

Page 9: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Algebraic Structures – Sets with Operations

Algebra

< 𝐾, 𝑜𝑝1, 𝑜𝑝2, … , 𝑜𝑝𝑛 > : 𝐾 – a set of data, 𝑜𝑝1 - operator : 𝐾𝑖 → 𝐾

Example) (ℝ,+,−,×,÷)

Binary Algebra Semigroup / Monoid / Group

< 𝐾,⊕ > : ⊕ - One binary operator : 𝐾2 → 𝐾

Example) (ℤ,+)

Ring :

< 𝐾,⊕,⊗> : ⊕,⊗ - Two binary operators,

Example) (ℤ,+,×)

9

Page 10: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Classification / Properties

Semigroup

Monoid

Group

< 𝐾, > Properties

1) Closure

2) Associativity

3) Identity

4) Inverse

5) Commutative

6) Distributive

(1),(2)

(3)

(4)

AbelianSemigroup

AbelianMonoid

AbelianGroup

(5)

(5)

(5)

Ring

Ring with Unity

< 𝐾,⊕,⊗>

(1),(2),(6)

(3)

CommutativeRing

Commutative Ring with Unity

Field

(5)

(5)

(3)

(4)

10

Page 11: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Galois Fields / Finite Fields

Field ?

It is an algebraic structure with notions of addition, subtraction, multiplication,

and division satisfying the appropriate abelian group equations and distributive law.

• 실수 집합에서와 같은 사칙 연산이 가능한 구조

• ℝ is a Field, an Infinite Field

• Subtraction : The addition of the + inverse, Division : The multiplication of the × inverse

Galois/Finite Field

Main Applications : Cryptography and Coding Theory

ℤ/𝑝ℤ, ℤ𝑝

The Integers Modulo 𝒑

Example) ℤ5

• 17 ≡ 2(𝑚𝑜𝑑 5)

• 2 + 4 (mod 5) ?

• 2 x 4 (mod 5) ?

• 2 – 4 (mod 5) ?

• 2 / 4 (mod 5) ?

+ 0 1 2 3 4

0 0 1 2 3 4

1 1 2 3 4 0

2 2 3 4 0 1

3 3 4 0 1 2

4 4 0 1 2 3

X 0 1 2 3 4

0 0 0 0 0 0

1 0 1 2 3 4

2 0 2 4 1 3

3 0 3 1 4 2

4 0 4 3 2 1

11

Page 12: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Examples - ℤ2, ℤ4

ℤ2 - 다음 표를 채우고 Galois Field 여부를 판정하라.

Modulo-2 Operation에서 덧셈은 XOR와 같다.

ℤ4 - 다음 표를 채우고 Galois Field 여부를 판정하라.

ℤ𝑝 : 𝑝 가 Prime Number 인 경우 Galois Field

+ 0 1

0

1

X 0 1

0

1

+ 0 1 2 3

0

1

2

3

X 0 1 2 3

0

1

2

3

12

Page 13: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Field of Polynomials

𝐺𝐹𝑝[𝑥] : All polynomials whose coefficients are in the field ℤ𝑝

𝐺𝐹2 𝑥 ∶ Possible Coefficients : 0, 1 (∈ ℤ2)

Examples) 𝑥3 + 𝑥 + 1, 𝑥5 + 𝑥2 + 𝑥

Representing Polynomial using Binary Codes (vice versa)

• 𝑥3 + 𝑥 + 1 1011

• 𝑥5 + 𝑥2 + 𝑥 100110

• 1001001

We can represent all binary codes using 𝐺𝐹2[𝑥]

Finite Field for the Polynomials ?

For set ℤ congruent modulo 𝑝 (prime number)

For set 𝐺𝐹2[𝑥] congruent modulo 𝑝(𝑥) ?

13

Page 14: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

𝐺𝐹2[𝑥] arithmetic

Modulo 2 arithmetic

Uses binary addition with no carries, which is just exclusive-OR (XOR)

operation.

Example) (𝑥3+𝑥2 + 𝑥 + 1) + 𝑥3 + 𝑥 = 𝑥2 + 1

𝑥3 + 𝑥2 + 𝑥 + 1 × 𝑥 + 1 = 𝑥4 + 1

𝐴 𝑥 ⨁0 = ; 𝐴 𝑥 ⨁𝐴 𝑥 =

Polynomial Division Modulo Operation

𝑎(𝑥)/𝑏(𝑥) ⇒ 𝑎 𝑥 = 𝑏 𝑥 𝑞 𝑥 + 𝒓(𝒙)

• The degree of 𝑟(𝑥) < The degree of 𝑞(𝑥)

Example) (𝑥3 + 𝑥 + 1)/(𝑥2 + 𝑥 + 1) ⇒ (𝑥3 + 𝑥 + 1)= 𝑥2 + 𝑥 + 1 𝑥 + 1 + 𝑥

자연수 집합에 대해 Modulo 3을 하듯이

Polynomial 집합 𝐺𝐹2[𝑥]에 대해 Modulo 𝑥2 + 𝑥 + 1 ?

1111+1010

1111 11

14

Page 15: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

𝐺𝐹2 𝑥 /𝑝(𝑥)

For Deg(𝑝(𝑥)) = 2

Possible remainders : 0, 1, 𝑥, 𝑥 + 1

⊕ : 𝑎 𝑥 + 𝑏(𝑥) – modulo 2 arithmetic

⨂ : 𝑎 𝑥 × 𝑏 𝑥 mod 𝑝(𝑥)

𝑝 𝑥 = (𝑥2 + 𝑥 + 1)

𝑝 𝑥 = (𝑥2 + 1)

⊕ 0 1 𝑥 𝑥 + 1

0 0 1 𝑥 𝑥 + 1

1 1 0 𝑥 + 1 𝑥

𝑥 𝑥 𝑥 + 1 0 1

𝑥 + 1 𝑥 + 1 𝑥 1 0

⊗ 0 1 𝑥 𝑥 + 1

0 0 0 0 0

1 0 1 𝑥 𝑥 + 1

𝑥 0 𝑥 𝑥 + 1 1

𝑥 + 1 0 𝑥 + 1 1 𝑥

⊕ 0 1 𝑥 𝑥 + 1

0 0 1 𝑥 𝑥 + 1

1 1 0 𝑥 + 1 𝑥

𝑥 𝑥 𝑥 + 1 0 1

𝑥 + 1 𝑥 + 1 𝑥 1 0

⊗ 0 1 𝑥 𝑥 + 1

0 0 0 0 0

1 0 1 𝑥 𝑥 + 1

𝑥 0 𝑥 1 𝑥 + 1

𝑥 + 1 0 𝑥 + 1 𝑥 + 1 0

15

Page 16: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

CRC (Cyclic Redundancy Check)

Standard method : Simple, Good Performance

Modulo 𝑝(𝑋) on 𝐺𝐹2[𝑋]

Symbols

𝐷(𝑋) : 𝑘 bits source data – 원본 데이터

𝑃(𝑋) : predetermined polynomial with degree 𝑛 − 𝑘

𝑅 𝑋 : FCS (Frame Check Sequence) –에러 처리를 위한 부가 정보

𝑇(𝑋) : Transmitted Data, 𝐸(𝑋) : Error, 𝑇𝐸(𝑋) : Received Data

𝑋𝑛−𝑘 ⋅ 𝐷 𝑋 = 𝑃 𝑋 ⋅ 𝑄 𝑋 + 𝑅 𝑋

예) 𝑃 𝑋 = 𝑋3 + 𝑋 + 1 1011, 𝐷 𝑋 = 1001, 𝑘 = 4, 𝑛 = 7

𝑋3 ⋅ 𝐷 𝑋 = 1001000 = 𝑃 𝑋 ⋅ 𝑄 𝑋 + 𝑅 𝑋 = 𝑃 𝑋 ⋅ 𝑄 𝑋 + 110

𝑋𝑛−𝑘 ⋅ 𝐷 𝑋 + 𝑅 𝑋 = 𝑃 𝑋 ⋅ 𝑄 𝑋 + 𝑅 𝑋 + 𝑅 𝑋 = 𝑃 𝑋 ⋅ 𝑄(𝑋)

𝑇 𝑋 = 𝑋𝑛−𝑘 ⋅ 𝐷 𝑋 + 𝑅(𝑋)

𝑇𝐸 𝑋 = 𝑇 𝑋 + 𝐸(𝑋) 16

Page 17: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

CRC Example

𝑃 𝑋 = 𝑋5 + 𝑋4 + 𝑋2 + 1 = 110101

𝐷 𝑋 = 1010001101

𝑅 𝑋 =

𝑇(𝑋) = 110101 101000110100000

17

Page 18: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

CRC

CRC can detect

All single-bit errors, if 𝑃(𝑋) has more than one nonzero term

All double-bit errors, as long as 𝑃(𝑋) has a factor with three terms

Any odd number of errors, as long as 𝑃(𝑋) contains a factor (𝑋 + 1)

Any burst error for which the length of the burst is less than or equal to 𝑛 − 𝑘; that is, less than or

equal to the length of the FCS

A fraction of error bursts of length 𝑛 − 𝑘 + 1; the fraction equals to 1 − 2− 𝑛−𝑘−1

A fraction of error bursts of length greater than 𝑛 − 𝑘 + 1; the fraction equals to 1 − 2− 𝑛−𝑘

4 Standard 𝑃(𝑋) widely used

CRC-12 = 𝑋12 + 𝑋11 + 𝑋3 + 𝑋2 + 𝑋 + 1

CRC-16 = 𝑋16 + 𝑋15 + 𝑋2 + 1

CRC-CCITT = 𝑋16 + 𝑋12 + 𝑋5 + 1

CRC-32 = 𝑋32 + 𝑋26 + 𝑋23 + 𝑋22 + 𝑋16 + 𝑋12 + 𝑋11 + 𝑋10 + 𝑋8 + 𝑋7 + 𝑋5 + 𝑋4 + 𝑋2 + 𝑋 + 1

18

Page 19: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Error Correcting Codes – 2 Main Categories

Block Codes

Message Block (of size 𝑘) Codeword (of size 𝑛)

대표적 예 : Hamming Code, Reed-Solomon Code

Convolutional Codes

Message Symbol (of size 𝑘 bits) Code Symbol (of size 𝑛 bits)

현재 데이터뿐 아니라 이전 데이터까지 포함하여 Code 생성

• Combinational Circuit vs. Sequential Circuit !!!

The transformation is a function of the last 𝐾 information

symbols, where 𝐾 is the constraint length of the code.

• Example) 𝑘 = 1, 𝑛 = 3,𝐾 = 2

현재 bit 값 𝑚1 뿐 아니라 이전의 𝑚0, 𝑚−1 값을 함께 사용하여

Code 출력 값 𝑛1, 𝑛2, 𝑛3 값을 구함.

대표적 예 : Viterbi Code / Turbo Code

19

Page 20: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Block Code – Linear Block Code (1)

The Vector Space and Subspace

벡터 공간은 Field 상에서 정의된다.

예) 실수(Field) 집합 상에서 정의된 3차원 벡터

• 𝑣 = 𝑥, 𝑦, 𝑧 , 𝑤ℎ𝑒𝑟𝑒 𝑥, 𝑦, 𝑧 ∈ ℝ

• 벡터 공간은 교환,결합,스칼라에 대한 분배 법칙,

덧셈에 대한 항등원, 역원의 존재 등을 만족하는 집합

벡터 공간의 차원(Dimension)과 기저(Bases) 개념

• 실수 집합 상의 𝑛 개의 tuple로 이루어진 벡터 공간 𝑉𝑛 = { 𝑣 = 𝑥1, 𝑥2, ⋯ , 𝑥𝑛 |𝑥𝑖 ∈ ℝ}의 차원은 ?

• 실수 집합 상에서 정의된 3차원 입체 벡터 공간의 기저를 구하면 ?

• 3차원 공간의 기저를 𝑒1, 𝑒2, 𝑒3 라고 할 때 이 공간의 임의의 벡터는 기저들의 조합을 통해 표현 가능

( 𝑣 = 𝑎 ⋅ 𝑒1 + 𝑏 ⋅ 𝑒2 + 𝑎 ⋅ 𝑒3 )

벡터 공간과 행렬

Subspace

• 3차원 공간의 두 벡터 (1,0,0)과 (0,1,0)을 기저로 만들어지는 공간은? 역시 벡터 공간, Subspace

𝑎 𝑏 𝑐 ⋅1 0 00 1 00 0 1

rank1 1 10 1 11 0 0

=?

20

Page 21: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Linear Block Code (2)

The Vector Space over ℤ2 = {0,1}

Scalars c ℤ2, Addition and Multiplication in ℤ2 are Modulo 2 operation

ℤ2𝑛 be the set of 𝑛-tuple vectors with components the elements of ℤ2.

• Example) 𝑛 = 2, ℤ22 = { 0,0 , 1,0 , 0,1 , 1,1 }, 차원은 ? 기저는 ?

• Example) 𝑛 = 4, ℤ24 ? 𝑛 = 7, ℤ2

7?

길이가 𝑛 bits인 임의의 bit string은 ℤ2상의 𝑛 차원 벡터 공간의 원소

• 0111101 (0, 1, 1, 1, 1, 0, 1)

Linear Block Code

A block code of length 𝑛 and 2𝑘 codewords is said to be a linear block code

𝐶𝑏(𝑛, 𝑘) if the 2𝑘codewords form a vector subspace of dimension 𝒌,

of the vector space 𝑉𝑛 of all vectors of length 𝑛

with component in the Field ℤ2 (that is 𝐺𝐹(2))

2𝑘

2𝑛

21

Page 22: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Linear Block Code Example – Hamming Code

The Hamming(𝑛 = 7, 𝑘 = 4) Code

The Generator Matrix

Matrix G의 Rank ?

Matrix G의 Row Vector들을 기저(Base)로 하는 Vector Subspace를 생각해 보라

길이가 4인 입력 메시지 𝑚 = (𝑚1,𝑚2, 𝑚3, 𝑚4)와 G를 곱하여 Codeword 생성

𝑐 = 𝑚 ∘ 𝐺 (Encoding)

Example) 𝑚 = 1010, 𝑚 = 0110, 𝑚 = 1110

• Systematic Coding : 원본 데이터가 변하지 않고 Codeword에 포함됨.

Hamming Code의 Hamming Distance?

𝑑𝑚𝑖𝑛 = min 𝑑 𝑐𝑖 , 𝑐𝑗 ; 𝑐𝑖 ≠ 𝑐𝑗 = min 𝜔 𝑐𝑖⨁𝑐𝑗 ; 𝑐𝑖 ≠ 𝑐𝑗 = min{𝜔 𝑐𝑚 ; 𝑐𝑚 ≠ 0}

• Linear Block Code에서는 두 코드 벡터 𝑐𝑖와 𝑐𝑗를 더한 것 역시 코드 벡터

• 결국 코드 벡터 중 1의 개수가 가장 작은 벡터를 찾아 그 수를 세면 됨.

• 위 코드의 경우 3 22

𝐺 =

1 0 0 0 1 1 00 1 0 0 0 1 10 0 1 0 1 1 10 0 0 1 1 0 1

Page 23: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Linear Block Code – Hamming Code

The Hamming(𝑛 = 7, 𝑘 = 4) Code

The Generator Matrix, G

The Parity Check Matrix, H

Matrix G - 4차원의 Subspace

Dual Subspace ?

• Dual Subspace의 차원 ? 𝑛 − 𝑘

• Orthogonal to each other; 서로 직교 직교하는 두 벡터의 내적은 ?

𝑮 ∘ 𝑯𝑻 = 𝟎

𝑐 = 𝑚 ∘ 𝐺 → 𝑐 ∘ 𝐻𝑇 = 0,

수신 메시지를 𝑟 = 𝑐⨁𝑒

→ 𝑟 ∘ 𝐻𝑇 = 𝑐⨁𝑒 ∘ 𝐻𝑇 = 𝑐 ∘ 𝐻𝑇⨁𝑒 ∘ 𝐻𝑇 = 0⨁𝑒 ∘ 𝐻𝑇 = 𝑒 ∘ 𝐻𝑇

𝑒 = (1,0,0,0,0,0,0) 인 경우 𝑟 ∘ 𝐻𝑇 값은 ?

𝐺 =

1 0 0 0 1 1 00 1 0 0 0 1 10 0 1 0 1 1 10 0 0 1 1 0 1

𝐻 =1 0 1 1 1 0 01 1 1 0 0 1 00 1 1 1 0 0 1

23

Page 24: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Hamming Code

For any positive integer 𝑚 ≥ 3, there exists a Hamming code with

the following characteristics:

- Length 𝑛 = 2𝑚 − 1

- Number of message bits 𝑘 = 2𝑚 − 𝑚 − 1

- Number of parity check bits 𝑛 − 𝑘 = 𝑚

- Error-correction capability 𝑡 = 1, (𝑑𝑚𝑖𝑛 = 3)

Ex) 𝑚 = 3, Hamming(7,4)

Ex) 𝑚 = 4, Hamming(15,11)

24

Page 25: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Cyclic Codes

An important class of linear block codes

𝑐 = (𝑐𝑛−1, 𝑐𝑛−2, ⋯ , 𝑐1, 𝑐0)이 Codeword라면 이것을 𝑖번 left-shift rotation한

𝑐𝑖 = (𝑐𝑛−1−𝑖 , 𝑐𝑛−2−𝑖 , … , 𝑐1, 𝑐0, … , 𝑐𝑛−𝑖) 역시 Codeword를 만족하는 Code

Cyclic Code는 Generator Polynomial 개념에 기초

𝑔 𝑋 = 𝑋𝑛−𝑘 + 𝑔𝑛−𝑘−1𝑋𝑛−𝑘−1 + ⋯+ 𝑔1𝑋 + 1 → (0,… , 0, 1, 𝑔𝑛−𝑘−1, … , 𝑔1, 1)

• 𝑔(𝑋)의 degree (다항식의 차수)는 𝑛 − 𝑘

• 𝑘 − 1 bits 0, 𝑔 𝑋 = 𝑛 − 𝑘 + 1 bits

𝑋𝑖 ⋅ 𝑔 𝑋 ∶ Cyclic Code의 정의에 따라 역시 Codeword

• 𝑋𝑖를 곱하는 것은 𝑖 번 shift 하는 것

유사하게 𝑔(𝑋)에 임의의 𝑘 bits 길이의 메시지 𝑚(𝑥)를 곱하여도 Codeword

• 𝑐 𝑋 = 𝑚 𝑋 𝑔(𝑋)

Example) 𝑛 = 7, 𝑘 = 4, 𝑔 𝑋 = 𝑋3 + 𝑋 + 1

𝑚 𝑋 = 1000의 Codeword 𝑐 𝑋 =?

𝑚 𝑋 = 1100의 Codeword 𝑐 𝑋 =? 25

Page 26: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Cyclic Codes

Hamming(7,4) Code 역시 Cyclic Codes

Generator Polynomial 𝑔 𝑋 = 𝑋3 + 𝑋2 + 1

• Cyclic Code는 Linear Block Code

• 기저 ? Generator Matrix ?

어떤 Polynomial이 Cyclic Code의 Generator Polynomial이 될 수 있나 ?

• 𝑋𝑛 + 1을 Factorization 했을 때 Factor인 다항식

• 𝑋7 + 1 = (𝑋 + 1)(𝑋3 + 𝑋2 + 1)(𝑋3 + 𝑋 + 1)

• 𝑔2 𝑋 = 𝑋3 + 1은 Generator Polynomial 되지 않음.

• 𝐺𝐹2 𝑋 /(𝑋3 + 𝑋 + 1) Galois Field 𝐺𝐹23 = 𝐺𝐹8

Cyclic Code를 단순 적용하면 Systematic Form이 되지 않음.

Systematic Form으로 만드는 방법

• 앞의 Generator Matrix G를 가우스 소거법으로 앞쪽을 단위 행렬 형태로 변형

𝑋𝑛−𝑘 ⋅ 𝑚 𝑋 = 𝑞 𝑋 ⋅ 𝑔 𝑋 + 𝑝 𝑋 ⇒ 𝑋𝑛−𝑘 ⋅ 𝑚 𝑋 + 𝑝 𝑋 = 𝑞 𝑋 ⋅ 𝑔 𝑋 ⇒ 𝑐 𝑋

• 예) 𝑚 𝑋 = 1100 인 경우 1100000을 𝑔 𝑋 = 𝑋3 + 𝑋2 + 1 로 나눈 나머지를 1100000에

더함.

𝐺 =

1 1 0 1 0 0 00 1 1 0 1 0 00 0 1 1 0 1 00 0 0 1 1 0 1

26

Page 27: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

성능 분석 관련 문제 예

단위 시간 당 1 bit를 전송할 수 있는 어떤 Binary Symmetric

Channel의 BER(Bit Error Ratio)가 𝑝 일때

1. 길이가 𝑘 bits인 메시지 블록에서 에러가 발생할 확률은?

2. 에러가 발생한 메시지 블록은 사용할 수 없다고 할 때

채널의 평균 유효처리율(goodput)은?

3. 길이가 𝑘 bits인 메시지 블록에 Error Correcting Code를 적용하여

길이가 𝑛 (𝑛 > 𝑘) 인 코딩된 블록을 생성한다. 이 코드의 Hamming

Distance는 2 ⋅ ℎ + 1이다. 이 코드를 이용하여 에러를 복원할 경우

복원에 실패하여 여전히 에러가 발생할 확률은 얼마인가? 이 때 이

채널의 평균 유효처리율은 얼마인가?

1. Ex) (𝑛, 𝑘, ℎ)

Code A) (7, 4, 1) ; Code B) (15, 7, 2); Code C) (31, 16, 3)

27

Page 28: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Burst Error & Interleaving

에러의 발생 형태가 에러 복구에 큰 영향을 미침

Ex) Hamming (7,4) Code는 7bits Block에서 1 bits 에러 복구 가능

• 평균 비트 에러 발생율 = 1/7인 경우

• 에러 발생 예 1) Random Independent Error

• 에러 발생 예 2) Burst Error (밀집, 군집 에러)

무선 Channel의 Error는 Independent Error인 경우보다 에러가 밀집하여 발생하는 Burst

Error 특성이 강함

전송 순서를 조절하는 Interleaving을 통해 Burst Error에 보다 강인해질 수

있음.

28

E E E E

EE E E

Page 29: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Channel Coding

Related Keywords

Information Theory; Entropy, Source Coding – 2학년 2학기 확률

• Source Coding - 정보를 어떻게하면 효율적으로 표현할까?

– Ex) Entropy Coding / Huffman Coding

Shannon Capacity Formula : 𝐶 = 𝐵 ⋅ log2 1 + 𝑆𝑁𝑅 ∶ 이론적 한계치

• Shannon Capacity Formula를 근접하기 위해서는 적절한 Error Correction Code 즉 Channel

Coding 기술을 사용하여야 함

참고 - http://coding.yonsei.ac.kr/storyofchannelcoding.html

채널코딩에 관한 연구는 시대적으로 항상 미래 통신기술의 핵심을 이룬다. 오늘날 채널코딩이 적용되지 않은 통신시

스템은 이제 상상할 수 없는 지경이다. 현재 사용되고 있는 모든 디지털통신 시스템의 국제/국내표준안에는 반드시

적절한 채널코딩방식이 들어있다. 이동통신(핸드폰), 이동인터넷통신(와이브로 및 와이맥스), 태양계 및 우주 탐사위

성통신, 통신방송을 위한 위성통신, 모든 종류의 군통신 시스템, 지상파 및 위성 DMB, HDTV 방송통신, 디지털 캠코더

및 CD/DVD, MP3파일, 심지어 컴퓨터 하드디스크나 모든 종류의 디지털 무선 가전시스템의 무선통신 신호에까지 채

널코딩이 널리 사용되고 있으니 앞으로 우리가 맞이할 IT시대는 가히 채널코딩의 시대라 아니할 수 없다.

Claude Shannon(1916~2001)Input Codeword Frequency (Prob.) Output Codeword

00 0.6 0

01 0.15 100

10 0.2 11

11 0.05 101

29

Page 30: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Essential Blocks in Digital Communications

FormatSourceEncode

EncryptChannelEncode

MultiplexPulse

ModulationBandpass

ModulationFrequency

SpreadMultipleAccess

XMT

FormatSourceDecode

DecryptChanneldecode

De-Multiplex

Detect

De-Modulate

&Sample

FrequencyDespread

MultipleAccess

RCV

Synchro-nization

InformationSource

InformationSink

MessageSymbols

DigitalBasebandwaveform

Digitalbandpasswaveform

30

Page 31: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Packet Level Error Correction

Channel Code. Vs. Erasure Code

Channel Code 기술은 Binary Symmetric Channel과 같이 값이 바뀌는 에러에 대

응한 코딩 기술 Bit Level Error Detection/Correction Code

Erasure Code 기술은 Binary Erasure Channel과 같이 값이 유실/소실되는 에러

에 대응한 코딩 기술 일반적으로 Packet Level Error Correction (FEC)

Example)

어떤 저장소가 X, Y라는 (동일한 크기의/단위) 정보 2개를 저장할 수 있다.

하나의 (단위) 정보를 저장한 저장소에서 에러가 발생하여 해당 내용을 읽을 수 없는 (소실) 에러가 발생할

확률이 10%라고 하자.

두 개의 정보를 모두 에러 없이 읽을 확률은 얼마인가?

에러에 보다 강인한 저장소를 만들기 위해 정보 1개를 추가로 저장할 수 있다고 할 때 해당 저장소에 어떤

정보를 저장하는 것이 좋을까? 그리고 그때 X,Y 정보를 모두 에러 없이 읽을 확률은 얼마인가?

31

X Y ?

Page 32: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Packet Level FEC 개념

32

Erasure Code의 Encoding/Decoding 과정

Erasure Code의 핵심 인자 - N, K

•K개의 소스 패킷을 입력 받아 N (N > K) 개의 부호화(Encoded) 패킷 생성

•생성한 N개의 패킷 전송, 전송 추가 부하 = (N-K)/N

•N개의 전송 패킷 중 단말이 수신한 패킷 수 K’ >= K를 만족하면 유실된 패킷이 무엇

이든 K개의 원본 소스 패킷 모두 복원 가능

•대표적 Erasure Code – RAPTOR Code, Reed-Solomon Code

Page 33: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

zFEC – Open Source Erasure Code Library (참고)

A fast erasure codec which can be used with the command-line,

C, Python, or Haskell

https://pypi.python.org/pypi/zfec

33

Page 34: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

zFEC API – Original C APIs (참고)

4 Functions - fec_new(), fec_free(), fec_encode(), fec_decode()

API 인자의 의미를 이해할 수 있는가?

34

typedef unsigned char gf;

typedef struct {

unsigned long magic;

unsigned short k, n; /* parameters of the code */

gf* enc_matrix;

} fec_t;

extern fec_t* fec_new(unsigned short k, unsigned short n);

extern void fec_free(fec_t* p);

extern void fec_encode(const fec_t* code, gf** src, gf** fecs,

const unsigned* const block_nums, size_t num_block_nums,

size_t sz);

extern void fec_decode(const fec_t* code, gf** inpkts, gf** outpkts,

const unsigned* const index,

size_t sz);

Page 35: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

zFEC API - Android Ported Version (참고)

JNI를 이용한 zFEC Android API

2010년 이동통신연구실 연구생 정아정/석선희 작성

활용

졸업과제, 무선 랜 기반 멀티미디어 방송 시스템

2013년 2학기 컴퓨터 네트워크 Term Project 활용

가능 라이브러리

35

2010년 이동통신연구실 졸업과제

package com.example.zfectest;

public class myFEC {

public native byte[][] FEC_Decode (byte[][] data,

int[] ids, int n, int k, int Dlen, int num);

public native byte[][] FEC_Encode (byte[][] data,

int n, int k, int Dlen, int num);

static {

System.loadLibrary("myFEC");

}

}

Page 36: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Cyclic Codes – 가우스 소거법

𝑔 𝑋 = 𝑋3 + 𝑋2 + 1 𝑔 𝑋 = 𝑋3 + 𝑋 + 1

36

𝐺 =

1 1 0 1 0 0 00 1 1 0 1 0 00 0 1 1 0 1 00 0 0 1 1 0 1

𝐺1 =

1 1 0 0 1 0 10 1 1 0 1 0 00 0 1 0 1 1 10 0 0 1 1 0 1

𝐺2 =

1 1 0 0 1 0 10 1 0 0 0 1 10 0 1 0 1 1 10 0 0 1 1 0 1

𝐺3 =

1 0 0 0 1 1 00 1 0 0 0 1 10 0 1 0 1 1 10 0 0 1 1 0 1

𝐺 =

1 0 1 1 0 0 00 1 0 1 1 0 00 0 1 0 1 1 00 0 0 1 0 1 1

𝐺1 =

1 0 1 0 0 1 10 1 0 0 1 1 10 0 1 0 1 1 00 0 0 1 0 1 1

𝐺2 =

1 0 0 0 1 0 10 1 0 0 1 1 10 0 1 0 1 1 00 0 0 1 0 1 1

𝐻 =1 0 00 1 00 0 1

Page 37: Error Detection/Correction Code - KOCWcontents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/5.pdf · 2016. 9. 9. · 15bits의Codeword에서최대1 bit의Error가발생할수있다고할때

Hamming Code Example

Hamming Code (7,4)의 Generator Matrix 𝐺와 Parity Check Matrix

𝐻가 다음과 같이 주어져 있다.

1. 𝐻𝑇를 구하라.

2. 𝐺 ∘ 𝐻𝑇를 계산해 보라.

3. 전송해야 할 원본 데이터가 1101일 때 이에 해당 하는 Hamming Code 값은?

4. 수신한 값이 1101101일 때 에러 발생 여부, 에러 발생 시 Correction 가능 여부

를 확인하라. Correction이 가능한 경우 원본 데이터는 무엇인가?

5. 수신한 값이 1100000일 때 에러 발생 여부, 에러 발생 시 Correction 가능 여부

를 확인하라. Correction이 가능한 경우 원본 데이터는 무엇인가?

37

𝐺 =

1 0 0 0 1 1 00 1 0 0 0 1 10 0 1 0 1 1 10 0 0 1 1 0 1

𝐻 =1 0 1 1 1 0 01 1 1 0 0 1 00 1 1 1 0 0 1