You are on page 1of 54

ERROR DETECTION AND

CORRECTION
STALLINGS CHAPTER 6
ERRORS
• Error: When a bit is altered between transmission and
reception
Examples:
• Binary 1 is transmitted and a binary 0 is received
• Binary 0 is transmitted and a binary 1 is received
ERRORS
• General Types of Errors:
• Single-bit error: an isolated error condition that alters
one bit but does not affect nearby bits
• Burst error: determined by length B, is a contiguous
sequence of B bits in which the first and last bits and
any number of intermediate bits are received in error
ERRORS
• General Types of Errors:
ERRORS
• Single-bit error can occur in the presence of white
noise, when a slight random deterioration of the
signal-to-noise ratio is sufficient to confuse the
receiver’s decision of a single bit
• Burst error are more common and more difficult to
deal with, caused by impulse noise
• Cause of errors are also fading for the mobile wireless
environment
ERRORS
• How to correct errors:
1.Error-Detection Codes: have to know there is an
error and where is the error located
2.Error-Correction Codes (Forward Error
Correction Codes): automatically replace the data in
error (since binary can easily replace 1 to 0 or 0 to 1)
3.Automatic Repeat Request (ARQ) Protocols:
automatically send control signals to source to resend
the data
ERROR DETECTION
• Errors are unavoidable to all digital transmission
systems
• Probabilities of errors: what is the chance that a
single-bit or burst error occurs, assuming data is sent
by groups of bits called frames
• Probabilities of errors:
• Pb: Probability that a bit is received in error; also known
as the bit error rate (BER)
• P1: Probability that a frame arrives with no bit errors
ERROR DETECTION
• Probabilities of errors:
• P2: Probability that, with an error-detecting algorithm in
use, a frame arrives with one or more undetected errors
• P3: Probability that, with an error-detecting algorithm in
use, a frame arrives with one or more detected bit
errors but no undetected bit errors
ERROR DETECTION
••  Probabilities of errors:

F = number of bits per frame

Note: the longer the frame, the more bits it has and the
higher the probability that one of these is in error
ERROR DETECTION
• Example 1: If a transmission system is transmitting 32
bits per frame, and has a BER of 0.0002, what is the
probability that no error occurs? And what is the
probability that an undetected error can occur?
ERROR DETECTION
• Example 1: If a transmission system is transmitting 32 bits per frame,
and has a BER of 0.0002, what is the probability that no error occurs?
And what is the probability that an undetected error can occur?

• Solution:
• Given:
• F = 32
• BER = PF = 0.0002
• Find P1 and P2
ERROR DETECTION
•  Example 1: If a transmission system is transmitting 32 bits per
frame, and has a BER of 0.0002, what is the probability that no error
occurs? And what is the probability that an undetected error can
occur?

• Solution:
ERROR DETECTION
•  Example 1: If a transmission system is transmitting 32 bits per
frame, and has a BER of 0.0002, what is the probability that no error
occurs? And what is the probability that an undetected error can
occur?

• Solution:
ERROR DETECTION PROCESS
ERROR DETECTION PROCESS
• For a given frame of bits, additional bits that constitute an
error-detecting code are added by the transmitter
• This code is calculated as a function of the other
transmitted bits
• For a data block of k bits, the error-detecting algorithm
yields an error-detecting code of n - k bits, where (n - k) < k
• The error-detecting code, also referred to as the check bits,
is appended to the data block to produce a frame of n bits,
which is then transmitted
ERROR DETECTION PROCESS
• The receiver separates the incoming frame into the k
bits of data and (n - k) bits of the error-detecting code
• The receiver performs the same error-detecting
calculation on the data bits and compares this value
with the value of the incoming error-detecting code
• A detected error occurs if and only if there is a
mismatch
ERROR DETECTION PROCESS
• Thus P3 is the probability that a frame contains errors
and that the error-detecting scheme will detect that
fact
• P2 is known as the residual error rate and is the
probability that an error will be undetected despite the
use of an error-detecting scheme
PARITY CHECK
• Simplest error-correcting scheme
• Uses parity count and parity bit
• Parity count: how many logic 1’s are there in the frame
• Parity bit: has the value depending on the parity count,
appended to the end of the frame:
• Logic 1if parity count is odd (odd parity)
• Logic 0 if parity count is even (even parity)
PARITY CHECK
Strengths:
• Easy to detect single-bit errors
Weaknesses:
• If bits are inverted, errors remain undetected
TWO DIMENSIONAL PARITY CHECK
• The string of data bits to be checked is arranged in a
two dimensional array
• Appended to each row i is an even parity bit r i for that
row, and appended to each column j is an even parity
bit cj for that column
• An overall parity bit p completes the matrix
• The error-detecting code consists of i + j + 1 parity bits
• Every bit participates in two parity checks
TWO DIMENSIONAL PARITY CHECK
TWO DIMENSIONAL PARITY CHECK
TWO DIMENSIONAL PARITY CHECK
• Uncorrectable
TWO DIMENSIONAL PARITY CHECK
• Example 2: Encode the parity bits of the following two-
dimensional frames:
TWO DIMENSIONAL PARITY CHECK
• Example 2: Encode the parity bits of the following two-
dimensional frames:
• Solution:
TWO DIMENSIONAL PARITY CHECK
• Example 3: Detect where is the error for the following
frames:
TWO DIMENSIONAL PARITY CHECK
• Example 3: Detect where is the error for the following
frames:
• Solution: Find which of the parity counts are wrong
THE INTERNET CHECKSUM
• An error-detecting code used in many Internet
standard protocols, including IP, TCP, and UDP
• The calculation makes use of the ones-complement
operation and ones-complement addition (from logic
circuits class)
• The checksum is included as a field in the header of a
protocol data unit, such as in IP datagram
THE INTERNET CHECKSUM
• Ones-complement addition
THE INTERNET CHECKSUM
• To compute the checksum, the checksum field is first set to
all zeros
• The checksum is then calculated by performing the ones-
complement addition of all the words in the header, and then
taking the ones-complement operation of the result
• This result is placed in the checksum field
• To verify a checksum, the ones-complement sum is computed
over the same set of octets, including the checksum field
• If the result is all 1 bits, the check succeeds (no error)
THE INTERNET CHECKSUM
• Example 4: Consider a header that consists of 10
octets, with the checksum in the last two octets (this
does not correspond to any actual header format) with
the following content (in hexadecimal):
00 01 F2 03 F4 F5 F6 F7 00 00
Note that the checksum field is set to zero.
THE INTERNET CHECKSUM
• Step 1: group the hexadecimal digits into streams of
four
0001
F203
F4F5
F6F7
0000
THE INTERNET CHECKSUM
• Step 2: add the groups by pair (one and the next),
either using binary addition or hexadecimal addition,
the result is added to the next digits
If no carry, don’t add the carry, if there is a carry (more
than the groups digits), add it to the last digit
THE INTERNET CHECKSUM
• Step 3: If all digits are added, the result is then
complemented (i.e. flip the binary digits 0  1 and 1
 0)
THE INTERNET CHECKSUM
• Step 4: To verify, simply repeat
steps 1-2, when the result is
added to the result in step 3, if
the result is all 1’s (e.g. FFFF),
then no error, otherwise, there is
an error
THE INTERNET CHECKSUM
• The Internet checksum provides greater error-
detection capability than a parity bit or two-
dimensional parity scheme but is considerably less
effective than the cyclic redundancy check (CRC)
• Very efficient to use for the Internet Protocols
• Internet checksum is simply an additional end-to-end
check for errors
CYCLIC REDUNDANCY CHECK (CRC)
• One of the most common, and one of the most powerful,
error-detecting codes
• Given a k-bit block of bits, or message, the transmitter
generates an (n - k)-bit sequence, known as a frame check
sequence (FCS)
• The receiver then divides the incoming frame by that number
and, if there is no remainder, assumes there was no error
• Uses modulo 2 arithmetic, polynomial division, and digital
logic
CYCLIC REDUNDANCY CHECK (CRC)
Modulo 2 arithmetic:
• Modulo addition: uses binary addition with no carries,
which is just the exclusive-OR (XOR) operation
• Binary subtraction with no carries is also interpreted as
the XOR operation
• Add using FCS
CYCLIC REDUNDANCY CHECK (CRC)
•Polynomial
  Division:
• Express all values as polynomials in a dummy variable
X, with binary coefficients
• Logic 1 = coefficient 1, Logic 0 = coefficient 0
• Example: 110101 =
• Divide by pre-determined FCS
CYCLIC REDUNDANCY CHECK (CRC)
Polynomial Division:
CYCLIC REDUNDANCY CHECK (CRC)
Digital Logic:
• The CRC process can be represented by, and indeed
implemented as, a dividing circuit consisting of XOR gates and
a shift register
• The shift register is a string of 1-bit storage devices
• Each device has an output line, which indicates the value
currently stored, and an input line
• At discrete time instants, known as clock times, the value in the
storage device is replaced by the value indicated by its input line
CYCLIC REDUNDANCY CHECK (CRC)
Digital Logic:
• The circuit is implemented as follows:
1. The register contains n - k bits, equal to the length of
the FCS
2. There are up to n - k XOR gates
3. The presence or absence of a gate corresponds to
the presence or absence of a term in the divisor
polynomial, P(X), excluding the terms 1 and X (n – k)
CYCLIC REDUNDANCY CHECK (CRC)
Digital Logic:
FORWARD ERROR CORRECTION (FEC)
• Enable the receiver to correct errors in an incoming
transmission on the basis of the bits in that
transmission
• Key to correcting errors: Codeword
• Codeword is generated via FEC encoder
• Correction is guided by codeword through FEC decoder
FORWARD ERROR CORRECTION (FEC)
FORWARD ERROR CORRECTION (FEC)
• FEC outcomes:
1.No errors: If there are no bit errors, the input to the
FEC decoder is identical to the original codeword, and
the decoder produces the original data block as output
2.Detectable, correctable errors: For certain error
patterns, it is possible for the decoder to detect and
correct those errors. Thus, even though the incoming
data block differs from the transmitted codeword, the
FEC decoder is able to map this block into the original
data block
FORWARD ERROR CORRECTION (FEC)
• FEC outcomes:
3.Detectable, not correctable errors: For certain
error patterns, the decoder can detect but not correct
the errors. In this case, the decoder simply reports an
uncorrectable error
4.Undetectable errors: For certain, typically rare,
error patterns, the decoder does not detect the error
and maps the incoming n-bit data block into a k-bit
block that differs from the original k-bit block
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• Hamming distance: d(v1, v2) between two n-bit
binary sequences v1 and v2 is the number of bits in
which v1 and v2 have different bits in the sequence
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• For every blocks of data k-bits long, there is a unique
n-bit codeword
• Each of the block is checked according to the
codeword given to that sequence
• If the codeword at the receiver matches a block, it has
no errors, otherwise, error is detected
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• To correct an error:
1. Find the codeword that has no block matched
2. Find all other codewords possible with block matched
3. Get the Hamming distance of the codeword in #1
with all codewords with #2
4. Get the minimum distance in #3 to determine the
closest valid codeword
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• To correct an error:
5. Get the corresponding block for that minimum
Hamming distance
6. In case of a tie, from #4, get the codeword that has a
block that only has a change of 1 bit, if there is still a
tie, increase check of change to 2 bits, and so on
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• Example: If receiver got a codeword of 00100, and
data block is 01, find and correct the error from the
following valid codewords
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• Example: If receiver got a codeword of 00100, and
data block is 01, find and correct the error from the
following valid codewords
FORWARD ERROR CORRECTION (FEC)
Block Code Principles
• Example: If receiver got a codeword of 00100, and
data block is 01, find and correct the error from the
following valid codewords
• Answer:
• Codeword = 00000
• Block = 00

You might also like