Block Coding Techniques in Error Detection and Correction
Block Coding Techniques in Error Detection and Correction
In block coding, we divide our message into blocks, each of k bits, called data words.
We add r redundant bits to each block to make the length n = k + r. The resulting n-
bit blocks are called code words.
For example, we have a set of data words, each of size k, and a set of code words, each
of size of n. With k bits, we can create a combination of 2k data words, with n bits; we
can create a combination of 2n code words. Since n > k, the number of possible code
words is larger than the number of possible data words.
The block coding process is one-to-one; the same data word is always encoded as the
same code word. This means that we have 2n-2k code words that are not used. We
call these code words invalid or illegal. The following figure shows the situation.
Error Detection
If the following two conditions are met, the receiver can detect a change in the original
code word by using Block coding technique
1. The receiver has (or can find) a list of valid code words.
2. The original code word has changed to an invalid one.
The sender creates code words out of data words by using a generator that applies
the rules and procedures of encoding (discussed later). Each code word sent to the
receiver may change during transmission. If the received code word is the same as one
of the valid code words, the word is accepted; the corresponding data word is
extracted for use.
If the received code word is not valid, it is discarded. However, if the code word is
corrupted during transmission but the received word still matches a valid code word,
the error remains undetected. This type of coding can detect only single errors. Two
or more errors may remain undetected.
For example, consider the following table of data words and Code words:
Assume the sender encodes the data word 01 as 011 and sends it to the receiver.
Consider the following cases:
1. The receiver receives O11. It is a valid code word. The receiver extracts the data word
01 from it.
2. The code word is corrupted during transmission, and 111 is received (the leftmost
bit is corrupted). This is not a valid code word and is discarded.
3. The code word is corrupted during transmission, and 000 is received (the right two
bits are corrupted). This is a valid code word. The receiver incorrectly extracts the data
word 00. Two corrupted bits have made the error undetectable.
Error Correction:
Error correction is much more difficult than error detection. In error detection, the
receiver needs to know only that the received code word is invalid, in error correction
the receiver needs to find (or guess) the original code word sent. So, we need more
redundant bits for error correction than for error detection.
Consider the following table of Data words and Code words.
Assume the data word is 01. The sender consults the table (or uses an algorithm) to
create the code word 01011. The code word is corrupted during transmission, and
01001 is received (error in the second bit from the right). First, the receiver finds that
the received code word is not in the table. This means an error has occurred. (Detection
must come before correction.) The receiver, assuming that there is only 1 bit corrupted,
uses the following strategy to guess the correct data word.
1. Comparing the received code word with the first code word in the table (01001
versus 00000), the receiver decides that the first code word is not the one that was
sent because there are two different bits.
2. By the same reasoning, the original code word cannot be the third or fourth one
in the table.
3. The original code word must be the second one in the table because this is the only
one that differs from the received code word by 1 bit. The receiver replaces 01001 with
01011 and consults the table to find the data word 01.
Types of Errors:
Networks must be able to transfer data from one device to another with acceptable
accuracy. Any time data are transmitted from one node to the next, they can become
corrupted in passage. Many factors can alter one or more bits of a message. Some
applications require a mechanism for detecting and correcting errors.
Whenever bits flow from one point to another, they are subject to unpredictable
changes because of interference. This interference can change the shape of the signal.
In a single-bit error, a 0 is changed to a 1 or a 1 to a 0. In a burst error, multiple bits
are changed.
Single-Bit Error
The term single-bit error means that only 1 bit of a given data unit (such as a byte,
character, or packet) is changed from 1 to 0 or from 0 to 1.
The following figure shows the effect of a single-bit error on a data unit. To understand
the impact of the change, imagine that each group of 8 bits is an ASCII character with
a 0 bit added to the left. In the figure 00000010 (ASCII STX) was sent, meaning start of
text, but 00001010 (ASCII LF) was received, meaning line feed.
Burst Error:
The term burst error means that 2 or more bits in the data unit have changed from 1
to 0 or from 0 to 1.
The following figure shows the effect of a burst error on a data unit. In this case,
0100010001000011 was sent, but 0101110101100011 was received. Note that a burst
error does not necessarily mean that the errors occur in consecutive bits. The length
of the burst is measured from the first corrupted bit to the last corrupted bit. Some
bits in between may not have been corrupted.
The encoder uses a generator that takes a copy of a 4-bit data word (a0, a1, a2 and
a3) and generates a parity bit r0. The data word bits and the parity bit create the 5-bit
code word. The parity bit that is added makes the number of 1s in the code word even.
This is normally done by adding the 4 bits of the data word (modulo-2).
r0=a3+a2+a1+a0 (modulo-2)
The result is the parity bit. In other words, If the number of 1s is even, the result is 0; if
the number of 1s is odd, the result is 1.
In both cases, the total number of 1s in the code word is even.
The sender sends the code word which may be corrupted during transmission. The
receiver receives a 5-bit word. The checker at the receiver does the same thing as the
generator in the sender with one exception: The addition is done over all 5 bits.
s0=b3+b2+b1+b0+ q0 (modulo-2)
The result, which is called the syndrome, is just 1 bit. The syndrome is 0 when the
number of 1s in the received code word is even; otherwise, it is 1.
The syndrome is passed to the decision logic analyzer. If the syndrome is 0, there is no
error in the received code word, the data portion of the received code word is accepted
as the data word, if the syndrome is 1, the data portion of the received code word is
discarded. The data word is not created.
For example, the sender sends the data word 1011. The code word created from this
data word is 10111, which is sent to the receiver. We examine five cases:
1. No error occurs; the received code word is 10111. The syndrome is 0. The data
syndrome is 1. No data word is created. Note that although none of the data
word bits are corrupted, no data word is created because the code is not
00110. The syndrome is O. The data word 0011 is created at the receiver. Note
that here the data word is wrongly created due to the syndrome value. The
simple parity-check decoder cannot detect an even number of errors. The errors
cancel each other out and give the syndrome a value of O.
5. Three bits-a3, a2, and a1-are changed by errors. The received code word is
01011. The syndrome is 1. The data word is not created. This shows that the
simple parity check, guaranteed to detect one single error, can also find any
odd number of errors.
A better approach is the two-dimensional parity check. In this method, the data word
is organized in a table (rows and columns). In the following figure, the data to be sent,
five 7-bit bytes, are put in separate rows. For each row and each column, 1 parity-check
bit is calculated. The whole table is then sent to the receiver, which finds the syndrome
for each row and each column.
As shown in the figure, the two-dimensional parity check can detect up to three errors
that occur anywhere in the table (arrows point to the locations of the created nonzero
syndromes). However, errors affecting 4 bits may not be detected.