IT-2205 Lec 03 Error Detection & Correction-1

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 45

IT-2205: Data Communication

for
2nd Year 2nd Semester of B.Sc (Honors) in IT

Lecture: 03
Error Detection
Prepared by:
K M Akkas Ali
akkas_khan@yahoo.com, akkas@juniv.edu

Associate Professor
Institute of Information Technology (IIT)
Jahangirnagar University, Dhaka-1342
Lecture-03: Error Detection

Objectives of this Lecture:

 Introductory concepts on error control


 Various types of error control
 Types of errors occurred during transmission
 Redundancy and error detection methods
- VRC
- LRC
- CRC
- Checksum

Slide-2
Introduction to Error Detection & Correction
Networks must be able to transfer data from one
device to another with acceptable accuracy.
 In most cases, it is expected that the data received are
identical to the data transmitted.

Many communication channels are subject to


channel noise, and thus errors may be introduced
during transmission from the source to a receiver.
That means, data can be corrupted during
transmission.
 For reliable communication, error must be detected
and corrected.

Slide-3
Error Control
Error controls are techniques that enable reliable
delivery of digital data over unreliable
communication channels.
Error control process has two components:
1. Error Detection
 Error detection techniques allow detecting errors caused
by noise or other impairments during transmission of data
from the transmitter to the receiver.
2. Error Correction
 Error correction enables reconstruction of the original
data.
 The correction of errors is more difficult than the
detection.
 Error detection and correction are implemented either
at the data link layer or the transport layer of the OSI
model.
Slide-4
Error Detection Vs. Error Correction
 In error detection, we are looking only to see if any
error has occurred. The answer is a simple yes or no.
We are not even interested in the number of errors. A
single-bit error is the same for us as burst error.
 Error detection uses the concept of redundancy, which
means adding extra bits for detecting errors at the
destination.
 In error correction, we need to know the exact number
of bits that are corrupted and more importantly, their
location in the message. The number of errors and the
size of message are important factors.
 If we need to correct one single error in an 8-bit data unit, we
need to consider eight possible error locations; if we need to
correct two errors in a data unit of the same size, we need to
consider 28 possibilities.
Slide-5
Types of Errors
Whenever bits flow from one point to another,
they are subject to unpredictable changes
because of interference which can change the
shape of the signal.

Figure: Types of Errors


Slide-6
Single-bit Error
In a single-bit error, only 1 bit in the data unit has
changed, i.e. a 0 is changed to a 1 or a 1 to 0.
 Figure below shows the effect of a single-bit error
on a data unit.

Figure: Single-bit error

 Single-bit errors are the least type of error in serial data


transmission. To understand why, imagine data sent at 1
Mbps (i.e. 1000000 bits per second). This means that each
bit lasts only 1 µs (1/1000000 s). For a single-bit error to
occur, the noise must have a duration of only 1 µs, which is
Slide-7 very rear; noise lasts much longer than this.
Burst Error
A burst error means that 2 or more bits in the
data unit have changed from 1 to 0 or from 0 to 1.
 Figure below shows the effect of a burst error on a
data unit.

Figure: Burst error


Slide-8
Burst Error
A burst error does not necessarily mean that
errors occur in consecutive bits.
 The length of the burst error is measured from the
first corrupted bit to the last corrupted bit. Some
bits in between may not have been corrupted.
 A burst error is most likely to occur than a single-
bit error.
The duration of noise is normally longer than the
duration of 1 bit, which means that when noise
affects data, it affects a set of bits.
 The number of bits affected depends on the data
rate and duration of noise.
 For example, if we are sending data at 1 kbps, a

noise of 1/100 s can affect 10 bits; if we are sending


Slide-9 data at 1 Mbps, the same noise can affect 10000 bits.
Types of Error Correction
Error correction can be handled in two ways:
1. Forward error correction:
 Forward error correction is a process of error
correction in which the receiver tries to guess the
message by using redundant bits.
 This method is used if the number of errors is small.

2. Retransmission:
 Retransmission is a error correction technique in
which the receiver detects the occurrence of an error
and asks the sender to resend the message.
 Resending is repeated until a message arrives that
the receiver believes is error-free.

Slide-10
Error Detection: Example
Suppose a computer sends a frame to another computer
on a bus topology Local Area Network (LAN). The
physical destination address of the frame is corrupted
during the transmission. What happens to the frame?
How can the sender be informed about the situation?

Answer:
 If the corrupted destination address does not match
any station address in the network, the packet is lost. If
the corrupted destination address matches one of the
stations, the frame is delivered to the wrong station. In
this case, however, the error detection mechanism,
available in most data link protocols, will find the error
and discard the frame. In both cases, the source will
somehow informed using one of the data link control
mechanisms
Slide-11
Error Detection Methods
If only data is transmitted, errors cannot be detected. So,
more information needs to be sent along with data that
satisfies a special relationship, i.e. add redundancy to
original data. Some commonly used error-detection
methods are:
1. Repetition code method
2. Checksum method
3. Parity bit method
 VRC (vertical redundancy check: even or odd parity VRC)
 HRC (horizontal redundancy check)
 LRC (longitudinal redundancy check: even or odd parity
LRC)
4. CRC (cyclic redundancy check) method

Slide-12
Redundancy
The general idea for achieving error detection
and correction is to add some redundancy (i.e.,
some extra data) to a message, which receivers
can use to check consistency of the delivered
message, and to recover data determined to be
erroneous.
 In general, the larger the amount of redundancy sent
with the message, the greater the ability to detect an
error.
 Redundancy is achieved through various coding
schemes, e.g., block coding, convolution coding etc.

Slide-13
Redundancy

Slide-14
Types of Redundancy Check
Four types of redundancy checks are used
in data communications:

Figure: Types of Redundancy Check

Slide-15
Error Detection Method: Code Repetition
A repetition code is an error-correcting coding
scheme that repeats the bits across a channel to
achieve error-free communication.
 Given a stream of data to be transmitted, the data is
divided into blocks of bits. Each block is transmitted some
predetermined number of times.
 For example, to send the bit pattern "1011", the four-bit

block can be repeated three times, thus producing "1011


1011 1011". However, if this twelve-bit pattern was received
as "1010 1011 1011" – where the first block is unlike the
other two – it can be determined that an error has
occurred.
 Repetition codes are very inefficient, and can be

susceptible to problems if the error occurs in exactly the


same place for each group (e.g., "1010 1010 1010" in the
previous example would be detected as correct). The
advantage of repetition codes is that they are extremely
Slide-16simple.
Error Detection Method: Checksum
A checksum of a message is a modular
arithmetic sum of the message code words of a
fixed word length (e.g., byte values).
 Detecting errors using this method is based on the
concept of redundancy, i.e. some extra bits are
added to the data bits by the sender. The extra bits
are here termed as checksum.

Slide-17
Error Detection Method: Checksum
The concept of checksum is illustrated with
examples:
Example-1:
 Suppose our data is a list of five 4-bit numbers that we

want to send to a destination. For example, the set of


numbers is (7, 11, 12, 0, 6).
 In checksum method, the sum of the data numbers (in

this case it is 36, which is called checksum) is sent


along with the data. That is, the sender will send (7, 11,
12, 0, 6, 36) instead of the original data (7, 11, 12, 0, 6).
 The receiver adds the five numbers and compares the

result with the sum. If the two are the same, the
receiver assumes no error, accepts the five numbers,
and discards the sum. Otherwise, there is an error
somewhere and the data are not accepted.
Slide-18
Error Detection Method: Checksum
Example-2:
 To send the same data stated in example-1, the

negative value of the sum of the data numbers (in this


case it is -36, that is called checksum) is sent along
with the data. That is, the sender will send (7, 11, 12, 0,
6, -36) instead of the original data (7, 11, 12, 0, 6).
 The receiver adds all the numbers received (including

the checksum). If the result is zero, it assumes no


error, accepts the five numbers, and discards the
checksum. Otherwise, there is an error somewhere
and the data are not accepted.

Slide-19
Error Detection Method: Checksum
Example-3:
 To send the same data stated in example-1, one’s

complement arithmetic can be used. Figure below


shows the process at the sender and at the receiver.

Slide-20
Error Detection Method: Checksum
Sender Site: Receiver Site:
 The sender initializes the  The receiver follows the same
checksum to 0 and adds all data procedure as the sender.
items and the checksum (the  It adds all data items
checksum is considered as one (including the checksum); the
data item and is shown in color). result is 45.
the result is 36.  Since, 45 cannot be expressed
 Since, 36 cannot be expressed in in 4 bits, the sum is wrapped
4 bits. The extra two bits are and becomes 15.
wrapped and added with the sum
 The wrapped sum is
to create the wrapped sum value complemented and becomes
0.
6.  Since the value of the
 The sum is then complemented,
checksum is 0, this means that
resulting in the checksum value 9 the data is not corrupted.
(15 − 6 = 9).  The receiver drops the
 The sender now sends six data checksum and keeps the other
items to the receiver including the data items.
checksum 9.  If the checksum is not zero,
the entire packet is dropped.
Slide-21
Error Detection Method: Checksum
Sender Site: Receiver Site:
1. The message is divided into 1. The message (including
16-bit words. checksum) is divided into
2. The value of the checksum 16-bit words.
word is set to 0. 2. All words are added using
3. All words including the one’s complement addition.
checksum are added using 3. The sum is complemented
one’s complement addition. and becomes the new
4. The sum is complemented and checksum.
becomes the checksum. 4. If the value of checksum is
5. The checksum is sent with the 0, the message is accepted;
data. otherwise, it is rejected.

Slide-22
Error Detection Method: Internet Checksum
The 16-bit checksum is used in the Internet by several
protocols. Rules for calculating checksum on the sender
and receiver sides, and detecting error are given below.

Sender site:
1. The message to be sent is divided into 16-bit
words.
2. The value of the checksum word is set to 0.
3. All data words including the checksum are added
using 1’s complement addition.
4. The sum is complemented and becomes the
checksum that is to be attached to the message.
5. The checksum is sent with the data.

Slide-23
Error Detection: Internet Checksum
Receiver site:
1. The message (including checksum) is divided into
16-bit words.
2. All words are added using one’s 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.

Slide-24
Error Detection Method: Checksum
Example-4:
Suppose, a transmitter wants to transmit the following
text to a receiver:
ASIFF KHAN
At the sender’s site:
1. The text ASIFF KHAN needs to be divided into 16-bit
words. We use ASCII code of each character which is a
2-digit
hexadecimal
number (i.e. 8-
bit). So, to divide
the message into
16-bit words, we
use two
characters.
Slide-25
Error Detection Method: Checksum
16-bit words of the message is:

2. Initial value of checksum word is set to zero, which is


represented as four hexadecimal digits (i.e. 16 bit) as:

Slide-26
Error Detection Method: Checksum
3. All data words including the checksum word are
added using 1’s compliment addition.

Slide-27
Error Detection Method: Checksum
4. 5D4F is the final sum. Recompliment the sum, i.e.
calculate its 15’s compliment which will be the
checksum to be sent with the message.
5 D 5 0 (Sum, final)
A 2 A F (15’s compliment of the sum. This is the
checksum)
 
5. The checksum to be sent with the message is: A 2 A
F.

Slide-28
Error Detection Method: Checksum
At the receiver’s site:
1. The message receiver will receive including the
checksum is:

Slide-29
Error Detection Method: Checksum
2. All data words including the checksum word are
added using 1’s compliment addition.

Slide-30
Error Detection Method: Checksum
3. F F F F is the final sum. Recompliment the sum, i.e.
calculate its 15’s compliment which will be the
checksum on the receiver site.
 
F F F F (Sum, final)
0 0 0 0 (15’s compliment of the sum. This is
the checksum on the receiver site)

4. The checksum is zero, therefore the message is


accepted.

Slide-31
Error Detection: Checksum
Limitations of Checksum:
Checksum method will not find the error if
 Equal number of 0s and 1s are replaced
 This happens as Checksum works with the sum only

Slide-32
Error Detection: Cyclic Redundancy Check (CRC)
A cyclic redundancy check (CRC) is a powerful
and most common error-detection technique. It
is designed to detect accidental changes to
digital data in computer networks.

Slide-33
Error Detection: Cyclic Redundancy Check (CRC)
CRC can be described as follows:
 Given k message bits, the transmitter generates n bits
of redundancy known as FCS (frame check sequence).
The resulting frame consists of k+n bits. If P is a
predetermine pattern of n+1 bits, then the resulting
frame is exactly divisible by P. The receiver then
divides the incoming frame by the pattern P. If there is
no remainder, it is assumed that there was no error in
the received data.
 Let us assume that:

M= k-bit message
n= n-bits redundancy
T= (k+n)-bit frame to be transmitted, with n<k
F= n-bit FCS, the last n bits of T
P= pattern of n+1 bits, this is the predetermined
Slide-34 divisor
Error Detection: Cyclic Redundancy Check (CRC)
Rules for detecting errors by CRC using modulo
2 Arithmetic:
1. Multiply the message M by 2n. This will shift the message to the left by
n bits and padded out the result with n zeros.
2. Divide the above product 2nM by predetermined pattern P using
modulo 2 divisions. There is a quotient Q and a remainder R in the
result (R is always at least one bit shorter than the divisor P). The
group of bits in R, which is sometimes called syndrome of frame
check sequence (FCS), is appended to the end of the transmitted
data
3. Ignore the quotient and keep the remainder R as FCS.
4. Concatenate 2nM with R to give T=2nM+R, where T is the message
frame the receiver will receive.
5. Divide the received message frame T by P.
6. Accept the message if remainder is zero, otherwise reject.

Slide-35
Error Detection: Cyclic Redundancy Check (CRC)
Example of CRC code using modulo 2 arithmetic:
 Suppose we want to transmit the message string: 1010001101.
The receiver and sender decide to use the divisor pattern :
110101.

 At transmitter side:
Given

1. The message string is shifted left by one position less than the
number of position in the divisor (i.e. 5 bits in this case). This is
achieved by multiplying the message by 25, which yields
101000110100000
2. To find out remainder, the above product is divided by P using
Slide-36modulo 2 divisions.
Error Detection: Cyclic Redundancy Check (CRC)

Slide-37
Error Detection: Cyclic Redundancy Check (CRC)
1. The remainder R is 01110 which is the FCS or syndrome.
2. This remainder is added (concatenated) to 2nM to give
T= 101000110101110
3. Divide T by P, which yields R=0

4. Since remainder is zero, t


therefore, the message is accepted.
Slide-38
Error Detection: Cyclic Redundancy Check (CRC)
Properties of CRC:
 Cyclic codes have favorable properties in that they
are well suited for detecting burst errors.
 CRCs are particularly easy to implement in

hardware, and are therefore commonly used in


digital networks and storage devices such as hard
disk drives.
 The predetermine pattern P is chosen to be one bit

longer than the FCS.


 At minimum, both the high- and low-order bits of P

must be 1.
 In CRC, the receiver will fail to detect an error if and

only if error pattern E is divisible by predetermined


pattern P.
 Even parity is a special case of a cyclic redundancy
check.
Slide-39
Error Detection: Parity Bit Method
 A parity bit is a bit that is added to a group of
source bits to ensure that the number of set
bits (i.e., bits with value 1) in the outcome is
even or odd.
 It is a very simple scheme that can be used to
detect single or any other odd number (i.e.,
three, five, etc.) of errors in the output. An even
number of flipped bits will make the parity bit
appear correct even though the data is
erroneous. Unfortunately if two bits are
erroneous, the parity checking will fail.

Slide-40
Error Detection: Parity Bit Method
Two variations on the parity bit mechanism are:
1. Horizontal Redundancy Checks (HRC)
2. Vertical Redundancy Checks (VRC)

Vertical Redundancy Check (VRC)


 VRC is also known as Parity Check

 Append a single bit (i.e. parity bit, either a 0 or a 1) at

the end of data block such that the total number of 1s


including parity bit is even for even parity or odd for odd
parity check.
 Even Parity VRC concept (odd parity is similar):

011001101100110
011000101100011

Slide-41
Error Detection: Parity Bit Method VRC

 Performance:
 VRC can detect all single-bit errors.
 It can detect multiple bit or burst errors also if the
Slide-42 total number of errors is odd.
Error Detection: Parity Bit Method LRC
Longitudinal Redundancy Check (LRC)
 LRC was developed to overcome the problem with low
probability of detecting errors in parity method.
 It organizes data into a table and creates parity for each
column.
 Parity bits of all positions are assembled into a new data
unit called BCC (block check character), which is added
to the end of the data block.

Slide-43
Error Detection: Parity Bit Method
Example: LRC
 Suppose we want to send the message “snow”
using even parity and LRC with 7-bit ASCII

 At first we determine the even parity of each


character.

Slide-44
Error Detection: Parity Bit Method

Performance:
• Detects all burst errors up to length n (n= no. of columns).
• Misses burst errors of length n+1 if there are n-1 uninverted bits
between the first and last bit
• If the block is badly garbled, the probability of acceptance is
(½)n.
Slide-45

You might also like