0% found this document useful (0 votes)
8 views

CN-BCS502-Module2-Notes

CN

Uploaded by

THANUSHREE M
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

CN-BCS502-Module2-Notes

CN

Uploaded by

THANUSHREE M
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Computer Networks (BCS502)-Notes

MODULE-2

Data Link Layer: Error Detection and Correction: Introduction, Block Coding, Cyclic Codes.
Data link control: DLC Services: Framing, Flow Control, Error Control, Connectionless and
Connection Oriented, Data link layer protocols, High Level Data Link Control. Media Access
Control: Random Access, Controlled Access. Check Sum and Point to Point Protocol
Textbook: Ch. 10.1-10.4, 11.1 -11.4, 12.1 - 12.2

1. Error Detection and Correction


1.1 Introduction
For many applications system must guarantee that the data received are same to the data
transmitted. During transmission data may be corrupted because of many factors. Hence there
should be some mechanism to detect and correct errors.

Types of Errors
There are two types of error: Single bit error and Burst error.

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. Single-bit errors are the least likely type of error
in serial data transmission.

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. In the below figure, 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.

1
Computer Networks (BCS502)-Notes

Redundancy/Redundant bits:
To detect or correct errors some extra bits are sent with data. These redundant bits are added by the
sender and removed by the receiver. Their presence allows the receiver to detect or correct corrupted
bits.

Detection versus Correction


• The correction of errors is more difficult than the detection.
• In error detection, we are looking only to see if any error has occurred.
• 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 the errors and the size of the 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 (permutation of 8 by 2) possibilities. [P(8,2)= 8!/(8−2)! = 8!/ 6!=8×7=56/2 = 28]

Forward Error Correction versus Retransmission


There are two main methods of error correction.
• Forward error correction is the process in which the receiver tries to guess the message by
using redundant bits. This is possible, if the number of errors is small.
• Correction by retransmission is a 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.

Coding
• Redundancy is achieved through various coding schemes.
• The sender adds redundant bits through a process that creates a relationship between the
redundant bits and the actual data bits.
• The receiver checks the relationships between the two sets of bits to detect or correct the errors.

Coding schemes can be divided into two broad categories: block coding and convolution
coding.
2
Computer Networks (BCS502)-Notes

Introduction to Modular Arithmetic


In modular arithmetic only integers in the range 0 to N-1 is used. This is known as modulo-N arithmetic.
For example, if the modulus is 12, we use only the integers 0 to 11, inclusive.
Modulo-2 Arithmetic
In this arithmetic, the modulus N is 2. We can use only 0 and 1. Operations in this arithmetic are
very simple. The following shows how we can add or subtract 2 bits.
Adding: 0+0=0 0+1=1 1+0=1 1+1=0
Subtracting: 0-0=0 0-1=1 1-0=1 1-1=0

1.2 Block Coding


• In block coding message is divided into k bits blocks called datawords. Then r
redundant bits are added to each block to make the length n = k + r. The resulting n-bit
blocks are called codewords.
• With k bits, we can create a combination of 2 k datawords; with n bits, we can create a
combination of 2n codewords.
• Since n > k, the number of possible codewords is larger than the number of possible
datawords.
• The block coding process is one-to-one; the same dataword is always encoded as the
same codeword. This means that we have 2n - 2k codewords that are not used. We call
these codewords invalid or illegal.

3
Computer Networks (BCS502)-Notes

Error Detection
If the following two conditions are met, the receiver can detect a change in the original
codeword:
• The receiver has (or can find) a list of valid codewords.
• The original codeword has changed to an invalid one.
Process of error detection in block coding
• The sender creates codewords out of datawords by using a generator that applies the
rules and procedures of encoding.
• Each codeword sent to the receiver may change during transmission.
• If the received codeword is the same as one of the valid codewords, the word is
accepted; the corresponding dataword is extracted for use. If the received codeword is
not valid, it is discarded.

• However, if the codeword is corrupted during transmission but the received word still
matches a valid codeword, the error remains undetected.
• This type of coding can detect only single errors. Two or more errors may remain
undetected.

Example:
Let us assume that k =2 and n =3. Below Table shows the list of datawords and codewords.

Dataword Codeword
00 000
01 011
10 101
11 110
Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider the
following cases:
• The receiver receives 011. It is a valid codeword. The receiver extracts the dataword 01
from it.
• The codeword is corrupted during transmission, and 111 is received (the leftmost bit is
4
Computer Networks (BCS502)-Notes

corrupted). This is not a valid codeword and is discarded.

5
Computer Networks (BCS502)-Notes

• The codeword is corrupted during transmission, and 000 is received (the right two bits
are corrupted). This is a valid codeword. The receiver incorrectly extracts the dataword
00. Two corrupted bits have made the error undetectable.

Error Correction
In error detection, the receiver needs to know only that the received codeword is invalid; in
error correction the receiver needs to find (or guess) the original codeword sent.

Below Table shows the datawords and codewords.


Dataword Codeword
00 00000
01 01011
10 10101
11 11110
Assume the dataword is 01. The sender consults the table (or uses an algorithm) to create
the codeword 01011.
The codeword is corrupted during transmission, and 01001 is received (error in the second
bit from the right).
1. First, the receiver finds that the received codeword is not in the table. This means an
error has occurred. (Detection must come before correction.)
2. The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to
guess the correct dataword.
3. Comparing the received codeword with the first codeword in the table (01001 versus
00000), the receiver decides that the first codeword is not the one that was sent because
there are two different bits.
4. By the same reasoning, the original codeword cannot be the third or fourth one in the
table.

6
Computer Networks (BCS502)-Notes

5. The original codeword must be the second one in the table because this is the only one
that differs from the received codeword by 1 bit. The receiver replaces 01001 with
01011 and consults the table to find the dataword 01.

Hamming Distance
• One of the central concepts in coding for error control is the idea of the Hamming
distance.
• The Hamming distance between two words (of the same size) is the number of
differences between the corresponding bits.
• Hamming distance between two words x and y as d(x, y).
o Condition: d=0; bits not corrupted
d ≠ 0; bits corrupted
• Hamming distance between the received codeword and the sent codeword is the
number of bits that are corrupted during transmission.
• For example, 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.
• The Hamming distance can easily be found if we apply the XOR operation – counts the
number of 1s in the result.
Example:

Minimum Hamming Distance for Error Detection


• In a set of codewords, the minimum Hamming distance is the smallest Hamming
distance between all possible pairs of codewords.
• If s errors occur during transmission, the Hamming distance between the sent codeword

and received codeword is s.


• If our system is to detect up to s errors, the minimum distance between the valid codes
must be (s + 1), so that the received codeword does not match a valid codeword.
To detect up to s errors  dmin = s + 1
• If the minimum distance between all valid codewords is (s + 1), the received
codeword cannot be erroneously mistaken for another codeword.

Geometric concept explaining dmin in error detection

7
Computer Networks (BCS502)-Notes

Let us assume that the sent codeword x is at the center of a circle with radius s. All received
codewords that are created by 0 to s errors are points inside the circle or on the perimeter of the
circle.
All other valid codewords must be outside the circle, as shown in Figure. This means that d min
must be an integer greater than s or dmin = s + 1.

Geometric concept explaining dmin in error detection


Example 1:
• Wrf to the table, dmin = 2 (smallest Hamming distance
between all possible pairs of codewords.) Dataword Codeword
00 000
• This code guarantees detection of only a single error
01 011
S=dmin – 1 = 1 10 101
• For example, if the third codeword (101) is sent and 11 110

one error occurs, the received codeword does not match any valid codeword.
• If two errors occur, however, the received codeword may match a valid codeword and
the errors are not detected.

Example 2:
A code scheme has a Hamming distance dmin = 4. This code guarantees the detection of up
to 3 errors (d = s + 1 or s = 3).

Linear Block Codes


• Almost all block codes used today belong to a subset of block codes called linear
block codes.
• The use of nonlinear block codes for error detection and correction is not as
widespread because their structure makes theoretical analysis and implementation
difficult.
• A linear block code is a code in which the exclusive OR (addition modulo-2) of two
valid codewords creates another valid codeword.

8
Computer Networks (BCS502)-Notes

Example: Dataword Codeword


00 000
XORing of the second and third codewords creates the fourth
01 011
one. 10 101
11 110

Minimum Distance for Linear Block Codes


• It is simple to find the minimum Hamming distance for a linear block code. The
minimum Hamming distance is the number of 1s in the nonzero valid codeword with
the smallest number of 1s.
• From table: The numbers of 1s in the nonzero codewords are 2, 2, and 2. So the
minimum Hamming distance is dmin = 2.

Parity-Check Code
• Perhaps the most familiar error-detecting code is the parity-check code.
• This code is a linear block code. In this 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.
• Some cases gives odd number on 1s.
• The minimum Hamming distance for this category is
Dataword Codeword
dmin = 2, which means that the code is a single-bit error- 00 000
detecting code. Our first code is a parity-check code (k = 01 011
10 101
2 and n = 3). 11 110

• The code in below Table is also a parity-check code with k = 4 and n = 5.

9
Computer Networks (BCS502)-Notes

Encoder and decoder for simple parity-check code

Encoder:
• The calculation is done in modular arithmetic.
• 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 makes the number of 1s in the codeword even.
• This is normally done by adding the 4 bits of the dataword (modulo-2); the result is the
parity bit. In other words,
r0 = a3 + a2 + a1 + a0 (modulo-2)

Note: 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 codeword is even.
Decoder:
• The sender sends the codeword, 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.
• The result, which is called the syndrome, is just 1 bit.
• The syndrome is 0 when the number of 1s in the received codeword is even; otherwise,
it is 1.
• The syndrome is passed to the decision logic analyzer.
• If the syndrome is 0, there is no detectable error in the received codeword
• If the syndrome is 1, the data portion of the received codeword is discarded. The
dataword is not created.

10
Computer Networks (BCS502)-Notes

Example:
Assume the sender sends the dataword 1011. The codeword created from this dataword is 10111,
which is sent to the receiver. We examine five cases:
1. No error occurs; the received codeword is 10111. The syndrome is 0. The dataword
1011 is created.
2. One single-bit error changes a1. The received codeword is 10011. The syndrome is 1.
No dataword is created.
3. One single-bit error changes r0. The received codeword is 10110. The syndrome is 1.
No dataword is created. Note that although none of the dataword bits are corrupted, no
dataword is created because the code is not sophisticated enough to show the position
of the corrupted bit.
4. An error changes r0 and a second error changes a3. The received codeword is 00110.
The syndrome is 0. The dataword 0011 is created at the receiver. Note that here the
dataword 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 0.
5. Three bits—a3, a2, and a1—are changed by errors. The received codeword is 01011.
The syndrome is 1. The dataword 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 parity-check code can detect an odd number of errors.

11

You might also like