You are on page 1of 37

CSE 306

UNIT 3
Prepared By: Dr. Krishan kumar, Professor,
LPU

LPU
Unit III

DATA LINK LAYER : Data link Layer design issues,


Elementary Datalink Protocols, Error Detection and
Correction- Hamming code, CRC, Parity, Checksum,
Switch working

MAC SUBLAYER : Multiple Access Protocols-


ALOHA, CSMA and CSMA/CD, Random Access,
Controlled access, Ethernet protocol
KEYWORDS
• ERROR
• ERROR DETECTION
• ERROR CORRECTION
• PARITY
• LRC
• VRC
• HAMMING CODE
• CRC
Error Control
Once an error is detected, what is the receiver
going to do?
1. Do nothing
2. Return an error message to the transmitter
3. Fix the error with no further help from the
transmitter

4
Basic concepts
 Networks must be able to transfer data from one
device to another with complete accuracy.
 Data can be corrupted during transmission.
 For reliable communication, errors must be detected
and corrected.
 Error detection and correction are
implemented either at the data link layer or
the transport layer of the OSI model.
PLACEMENT—Interview Question
Q.1. What are the type of error control methods
Answer
Generally, the error control methods are of two types :
Error detection with retransmission
Forward acting error correction
• In case of first method, when an error is detected, the
retransmission request (ARQ) is sent back to the
transmitter.
• In the second method, the errors are detected and corrected
by proper coding techniques at the receiver end. Whenever
a single source transmits data to a number of receivers, the
forward acting error correction is used. This is due to the
fact that the retransmission is impossible in these cases.

6
Types of Errors
Single-bit error
Single bit errors are the least likely type of errors
in serial data transmission because the noise must
have a very short duration which is very rare.
However this kind of errors can happen in parallel
transmission.
Example:
If data is sent at 1Mbps then each bit lasts only
1/1,000,000 sec. or 1 μs.
For a single-bit error to occur, the noise must have a
duration of only 1 μs, which is very rare.
Burst error
The term burst error means that two or more bits in
the data unit have changed from 1 to 0 or from 0 to
1.

Burst errors 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.
Burst error is most likely to happen in serial
transmission since the duration of noise is normally
longer than the duration of a bit.
The number of bits affected depends on the data rate
and duration of noise.
Error detection
Error detection means to decide whether the
received data is correct or not without having a
copy of the original message.

Error detection uses the concept of redundancy,


which means adding extra bits for detecting errors at
the destination.
Redundancy
Four types of redundancy checks are used
in data communications
Vertical Redundancy Check
VRC
Longitudinal Redundancy Check
LRC
Performance

LCR increases the likelihood of detecting burst


errors.
If two bits in one data units are damaged and
two bits in exactly the same positions in another
data unit are also damaged, the LRC checker
will not detect an error.
Placement Interview Question
What is a Hamming code ?
Explanation:
• Hamming codes are used for the purpose of error
detection and correction.
• It is also used for channel encoding and decoding.
• They are linear-error correcting codes.
Hamming code
Hamming code is used to detect and correct the error in the transmitted
data. It was originally invented by Richard W. Hamming in the year 1950.
Hamming codes detect 1-bit and 2-bit errors.
Note-Number of redundant bits depending on the number of information
bits in the message. Let n be the number of information or data bits, then
the number of redundant bits P is determined from the following formula,

Suppose P=2

The above equation implies 4 not greater than or equal to 7. So let’s choose another value of P=3.
23
Example
Encode a binary word 11001 into the even parity
hamming code.
Answer-
Given, number of data bits, n =5.To find the number of
redundant bits, Let us try P=4.
The equation is satisfied and so 4 redundant bits are selected. Total code bit = n+P = 9
The redundant bits are placed at bit positions 1, 2, 4 and 8.
D5 P4 D4 D3 D2 P3 D1 P2 P1
1 1 0 0 1
To determine the parity bits
For P1: Bit locations 3, 5, 7 and 9 have three 1s. To have even parity, P1
must be 1.
For P2: Bit locations 3, 6, 7 have two 1s. To have even parity, P2 must be 0.
For P3: Bit locations 5, 6, 7 have one 1s. To have even parity, P3 must be 1.
For P4: Bit locations 8, 9 have one 1s. To have even parity, P2 must be 1.
Thus the encoded 9-bit hamming code is 111001101. Now detect and correct the error
Let us assume the even parity hamming code from
the above example (111001101) is transmitted and the
received code is (110001101).
Now from the received code, detect and correct the error.

Checking the parity bits


For P1 : Check the locations 1, 3, 5, 7, 9. There is three 1s in this group,
which is wrong for even parity. Hence the bit value for P1 is 1.
For P2 : Check the locations 2, 3, 6, 7. There is one 1 in this group, which
is wrong for even parity. Hence the bit value for P2 is 1.
For P3 : Check the locations 3, 5, 6, 7. There is one 1 in this group, which
is wrong for even parity. Hence the bit value for P3 is 1.
For P4 : Check the locations 8, 9. There are two 1s in this group, which is
correct for even parity. Hence the bit value for P4 is 0.
The resultant binary word is 0111. It corresponds to the bit location 7 . The
error is detected in the data bit D4. The error is 0 and it should be changed
to 1. Thus the corrected code is 111001101.
25
Cyclic Redundancy Check-
•Cyclic Redundancy Check (CRC) is an error detection method.
•It is based on binary division.
CRC Generator-
•CRC generator is an algebraic polynomial represented as a bit pattern.
•The power of each term gives the position of the bit and the coefficient
gives the value of the bit.
Example
Consider the CRC generator is x7 + x6 + x4 + x3 + x + 1.
Corresponding binary pattern

26
for the given CRC generator, the corresponding binary pattern is 11011011.
Properties Of CRC Generator-
The algebraic polynomial chosen as a CRC generator should have at least the following
properties-
Rule-01:
It should not be divisible by x.
Rule-02:
It should be divisible by x+1.
Important Notes-
If the CRC generator is chosen according to the above rules, then-
CRC can detect all single-bit errors
CRC can detect all double-bit errors provided the divisor contains at least
three logic 1’s.
CRC can detect any odd number of errors provided the divisor is a factor of
x+1.CRC can detect all burst error of length less than the degree of the
polynomial.CRC can detect most of the larger burst errors with a high
probability.

27
EXAMPLE

A bit stream 1101011011 is transmitted using the standard


CRC method. The generator polynomial is x4+x+1. What is
the actual bit string transmitted?
Solution-

The generator polynomial G(x) = x4 + x + 1 is encoded as 10011.


Clearly, the generator polynomial consists of 5 bits.So, a string of 4 zeroes is appended to the bit stream to be transmitted.
The resulting bit stream is 11010110110000.Now, the binary division is performed as-
From here, CRC = 1110.
•The code word to be transmitted is
obtained by replacing the last 4 zeroes
of 11010110110000 with the CRC.
•Thus, the code word transmitted to the
receiver = 11010110111110.

29
Cyclic Redundancy Check
CRC
Example
Standard Polynomials
Checksums
This is a block code method where a checksum is created based
on the data values in the data blocks to be transmitted using
some algorithm and appended to the data.
When the receiver gets this data, a new checksum is calculated
and compared with the existing checksum. A non-match indicates
an error.
Error Detection by Checksums
For error detection by checksums, data is divided into fixed sized
frames or segments.
•Sender’s End − The sender adds the segments using 1’s
complement arithmetic to get the sum. It then complements the
sum to get the checksum and sends it along with the data frames.
•Receiver’s End − The receiver adds the incoming segments
along with the checksum using 1’s complement arithmetic to get
the sum and then complements it.
Example
Suppose that the sender wants to send 4 frames each of 8 bits,
where the frames are
11001100, 10101010, 11110000 and 11000011.
The sender adds the bits using 1s complement arithmetic.
While adding two numbers using 1s complement
arithmetic, if there is a carry over, it is added to the sum.
After adding all the 4 frames, the sender complements the
sum to get the checksum, 11010011, and sends it along
with the data frames.
The receiver performs 1s complement arithmetic sum of
all the frames including the checksum. The result is
complemented and found to be 0. Hence, the receiver
assumes that no error has occurred.
Questions/Answers
THANKS

You might also like