Sie sind auf Seite 1von 40

Data Communication &

Networking
Data Communication & Computer Networks
Lecture 17

Error Detection
and
Correction

Data can be corrupted during transmission.


For reliable communication, errors must be
detected and corrected.
Network must be able to transfer data from one
device to another with acceptable accuracy.
For most application, a system must guarantee that
the data received are identical to the data
transmitted.
An electromagnetic signal is subject to interference
from heat, magnetism, and other forms of electricity

Types of Error
1. Single-Bit Error
2. Burst Error

Single-Bit Error

only one bit in the data unit has


changed.
Single-bit error: 0 1 or 1 0

The least likely type of error in serial


transmission. Why ?
Single-bit error can happen in parallel
transmission

Burst Error

2 or more bits in the data unit have


changed.

Burst error does not necessarily mean that the errors occur in
consecutive bits
Most likely to happen in a serial transmission
Number of bits affected depends on the data rate and duration of
noise If the data is sent at 1 kbps, a noise of 1/100 s can affect 10
bits.
If the data is sent at 1 Mbps, a noise of 1/100 s can affect
10000 bits.

Redundancy

Error detection uses the concept of


redundancy, which means adding extra bits
for detecting errors at the destination.

Error Detection and Correction


Detection vs. Correction
Detection: error ? yes or no
Correction: Need to know the exact number of bits that are corrupted, and
their location in the message
Ex : one error in 8 bits sequence 8 possible location.
Ex : 10 errors in 1000 bits sequence ?

Forward Error Correction vs. Retransmission


2 main methods of error correction :
Forward Error Correction the receiver tries to guess the message by using
redundant bits (in the case the number of errors is small).
Retransmission the receiver detects the occurrence of an error and ask the
sender to resend the message. This process is repeated until a message
arrives that the receiver believes is error-free.

Error Detection and Correction


Hamming Distance
The Hamming distance between two words is the number of differences
between corresponding bits.
Easily found by applying the XOR operation on the two words and count the
number of 1s in the result.
Ex : Hamming distance d (000,011) = 2
Ex : Hamming distance d (10101, 11110) = 3

Minimum Hamming Distance


The minimum Hamming distance is the smallest Hamming distance between
all possible pairs in a set of words
Ex : Find the minimum Hamming distance of the coding scheme in below
table.
Sol: = 2

Error Detection and Correction


Relation between Hamming Distance and Error
When a codeword is corrupted during transmission, the Hamming
distance between the sent and received codewords is the number of
bits affected by the error.
In other words, the Hamming distance between the received
codeword and the sent codeword is the number of bits that are
corrupted during transmission.
Ex : if the codeword 00000 is sent and 01101 is received, 3 bits are
in error and the Hamming distance between the two is d (00000,
01101) = 3.

Minimum Distance for Error Detection


If s errors occur during transmission, the Hamming distance
between the sent codeword and the received codeword is s.
To guarantee the detection of up to s errors in all cases, the
minimum Hamming distance in a block code must be dmin = s + 1.

Detection methods

Simple Parity-Check Code


A k-bit dataword is changed to an n-bit codeword where n = k + 1.
The extra bit (called the parity bit), is selected to make the total number
of 1s in the codeword even.
The minimum Hamming distance dmin = 2, which means that the code is
a single-bit error-detecting code.
Example of parity-check code with k = 4, n = 5; C (5,4) :

Even-parity concept

A parity bit is added to every data unit so


that the total number of 1s is even
(or odd for odd-parity).

Encoder and Decoder for Parity-Check


Code

Encoder and Decoder for Parity-Check Code


The encoder uses a generator that takes a copy of a 4-bit dataword (a0,
a1, a2 and a3) and generates a parity bit r0.
The dataword bits and the parity bit create the 5-bit codeword.
The parity bit that is added make the number of 1s in the codeword
even.
This is done by adding the 4 bits of the dataword, where the result is
the parity bit.
r0 = a3 + a2 + a1 + a0
The sender sends the codeword which may be corrupted during
transmission and the receiver receives a 5-bit word.
The checker at the receiver does the same thing as the generator at the
sender, but the addition is done over all 5 bits.
s0 = b3 + b2 + b1 + b0 + q0
The result which is called the syndrome, is just 1 bit.
The syndrome is passed to the decision logic analyzer.
If the syndrome = 0 = no error in the received codeword; the data
portion of the received codeword is accepted as the dataword.
If the syndrome = 1 = error in the received codeword; the data portion
of the received codeword is discarded and no dataword is created

Example 1
Supposethesenderwantstosendthewordworld.In
ASCIIthefivecharactersarecodedas
1110111 1101111 1110010 1101100 1100100
Thefollowingshowstheactualbitssent
1110111011011110111001001101100011001001

Example 2
NowsupposethewordworldinExample1isreceivedby
thereceiverwithoutbeingcorruptedintransmission.
11101110110111101110010011011000
11001001
Thereceivercountsthe1sineachcharacterandcomesup
withevennumbers(6,6,4,4,4).Thedataareaccepted.

Example 3
NowsupposethewordworldinExample1iscorrupted
duringtransmission.
11111110110111101110110011011000
11001001
Thereceivercountsthe1sineachcharacterandcomesup
withevenandoddnumbers(7,6,5,4,4).Thereceiver
knowsthatthedataarecorrupted,discardsthem,andasks
forretransmission.

Simple parity check can detect all


single-bit errors. It can detect burst
errors only if the total number of
errors in each data unit is odd.

Two-dimensional parity
A block of bits is divided into rows and a
redundant row of bits is added to the whole block.

Two-dimensional parity-check code

Two-dimensional parity-check code

Error Detection & Correction Common Techniques


Error Correcting Code : Hamming Codes C (7,4)

Error Detection & Correction Common Techniques


Encoder and decoder for a Hamming Code

Error Detection & Correction Common Techniques

Examples:
dataword 0100 codeword received 0100011 syndrome = 000
no errors
0111 0111001 received 0011001 syndrome 011 (b2) flip
b2 error is corrected
Dataword 1101 1101000 received 0001000 syndrome 101
(b0) flip b0 0000 wrong data word

Hamming code can only correct a single error or


detect a double errors

Error Detection & Correctioon Common Techniques


The use of Hamming Code in burst error correction
A Hamming code can only correct a single error and detect a double error.
But there is a way to make it detect a burst error :

When a burst of error of size 4 corrupts the frame, only 1 bit from
each codeword is corrupted the corrupted bit can be easily be
corrected at the receiver

Error Detection & Correction Common Techniques


Cyclic Codes
Cyclic codes are special linear block code if a codeword is cyclically shifted
(rotated), the result is another codeword
Ex : 1011000 is a codeword and if cyclically left-shifted, the result 0110001 is also a
codeword.

Error Detection & Correction Common Techniques


Cyclic Redundancy Check
The use of cyclic codes to detect and correct error

CRC encoder and decoder

CRC generator and checker

Error Detection & Correction Common Techniques


CRC encoder and decoder
In the encoder, the dataword has k
bits (4 bits)
The size of dataword is augmented
(increased) by adding n k (3 bits)
0s to the right-hand side of the word.
The n-bits is then fed to the
generator.
The generator uses a pre-defined
divisor to divide the dataword
(modulo-2 division).
The quotient of the division is
discarded, the remainder (r2r1r0) is
appended to the dataword to create
the codeword.

Error Detection & Correction Common Techniques


CRC encoder and decoder
The decoder receives the possibly
corrupted codeword.
A copy of all n bits is fed to the
checker to do the same step as the
generator.
The remainder produced by the
checker is a syndrome of n k (3
bits) which is fed to the decision
logic analyzer.
If the syndrome bits are all 0s, the 4
leftmost bits of the codeword are
accepted as a dataword.
Otherwise, the 4 bits are discarded
(error).

Error Detection & Correction Common Techniques


Example : Division in CRC Encoder

Error Detection & Correction Common Techniques


Example : Division in CRC Decoder

Checksum
The receiver follows these steps:
1. The unit is divided into k
sections, each of n bits.
2. All sections are added using
ones complement to get the
sum.
3. The sum is complemented.
4. If the result is zero, the data
are accepted: otherwise,
rejected

The sender follows these steps:

1. The unit is divided into k sections,


each of n bits.
2. All sections are added using ones
complement to get the sum.
3. The sum is complemented and
becomes the checksum.
4. The checksum is sent with the
data.

Example
Supposethefollowingblockof16bitsistobesentusinga
checksumof8bits.
1010100100111001
Thenumbersareaddedusingonescomplement
10101001
00111001

Sum 11100010
Checksum00011101
Thepatternsentis101010010011100100011101

Example
NowsupposethereceiverreceivesthepatternsentinExample7
andthereisnoerror.
101010010011100100011101
Whenthereceiveraddsthethreesections,itwillgetall1s,which,
aftercomplementing,isall0sandshowsthatthereisnoerror.
10101001
00111001
00011101
Sum

11111111

Complement

00000000meansthatthepatternisOK.

Example
Nowsupposethereisabursterroroflength5thataffects4bits.
101011111111100100011101
Whenthereceiveraddsthethreesections,itgets
10101111
11111001
00011101
PartialSum111000101
Carry
Sum

1
11000110

Complement00111001thepatterniscorrupted.

implementation of checksum
The sender initializes the checksum to 0 and adds all data items and the
checksum.
36 cannot be expressed in 4 bits. The extra two bits are wrapped and added
with the sum to create the wrapped sum value 6.
The sum is then complemented, resulting in the checksum value 9 (15 6 =
9).

11 1
1

Error Detection & Correction Common Techniques


Internet checksum
Sender site:

1. The message is divided into 16-bit words.


2. The value of the checksum word is set to 0.
3. All words including the checksum are added using ones complement
addition.
4. The sum is complemented and becomes the checksum.
5. The checksum is sent with the data.

Receiver site:

1. The message (including checksum) is divided into 16-bit words.


2. All words are added using ones complement addition.
3. The sum is complemented and becomes the new checksum.
4. If the value of checksum is 0, the message is accepted; otherwise, it is
rejected.

Error Detection & Correction Common Techniques


Internet checksum : Example

Das könnte Ihnen auch gefallen