You are on page 1of 55

Data Link Layer

Achieve CO2

1/20/20 KL Hyderabad 1
Where is Data Link Layer in OSI model?

1/20/20 KL Hyderabad 2
Logical Link Control(LLC)

• The LLC sub-layer acts as an interface between the media access control (MAC) sub layer and
the network layer.

• The LLC sub layer is primarily concerned with:


• Multiplexing protocols transmitted over the MAC layer (when transmitting) and decoding them (when receiving).
• Managing the data-link communication
• Link Addressing
• Defining Service Access Points (SAPs)
• Sequencing

• Application example: Local area network (LAN) Protocols like IEEE 802.2, 802.3
[ Details of this topic is out of scope]

3
Functions

1. Framing
2. Addressing
3. Flow Control
4. Error Control
5. Access Control

4
1 Framing

1.1 Fixed Size Framing


1.2 Variable Size framing
Character oriented or Byte Oriented protocol Ex: PPP
 Bit Oriented Protocol Ex: HDLC

5
Character oriented or Byte Oriented protocol

• Use reserved characters to indicate the start and end of a frame.

• Problem: Any pattern used for the flag could also be part of the
information. If this happens, the receiver, when it encounters this pattern
in the middle of the data, thinks it has reached the end of the frame.
• Solution: Byte Stuffing

6
Byte stuffing (with ESC) is the process of adding 1 extra byte whenever there is a flag
or escape character in the text.

7
Bit Oriented Protocol

• Use reserved bit patterns to indicate the start and end of a frame. For instance, use the 8-bit
sequence of 01111110 to delimit consecutive frames. A frame consists of everything between
two delimiters.

• Problem: If the flag pattern appears in the data


• Solution: Bit Stuffing

8
Bit stuffing and un-stuffing

9
3 Flow Control

10
3 Flow Control

11
Link Utilization
Let us assume the following:
Transmission time: The time it takes for a station to transmit a frame (normalized to a value of 1).
Propagation delay: The time it takes for a bit to travel from sender to receiver (expressed as a).
a < 1 :The frame is sufficiently long such that the first bits of the
frame arrive at the destination before the source has completed
transmission of the frame.

a > 1: Sender completes transmission of the entire frame before the


leading bits of the frame arrive at the receiver.
The link utilization U = 1/(1+2a), where a = Propagation time / transmission time

1/20/20 KL Hyderabad 12
3 Flow Control

3.1 Stop and Wait

13
Drawbacks:
• Firstly, if the receiver had the capacity to accept more than one frame, its resources are being
underutilized.
• Secondly, if the receiver was busy and did not wish to receive any more packets, it may delay
the acknowledgement. However, the timer on the sender's side may go off and cause an
unnecessary retransmission.
------These drawbacks are overcome by the sliding window protocols.

1/20/20 KL Hyderabad 14
• Piggybacking
The technique of temporarily delaying outgoing acknowledgments so that they
can be hooked onto the next outgoing data frame is known as piggybacking.
Add acknowledgement to data frames going in reverse direction.
Advantage : It is used to improve the efficiency of bidirectional
transmission.
Disadvantage: If the data link layer waits longer than the sender’s
timeout period, the frame will be retransmitted, defeating the whole
purpose of having acknowledgments.
1/20/20 KL Hyderabad 15
• Piggybacking

1/20/20 KL Hyderabad 16
3 Flow Control
Sliding window Concept
• Sending window
• Receiving Window
Sliding window flow control: Example (assume no errors)

17
Link Utilization
The link utilization in case of Sliding Window Protocol
U = 1, for N > 2a + 1
N/(1+2a), for N < 2a + 1
Where N = the window size
a = Propagation time / transmission time

1/20/20 KL Hyderabad 18
Error Control

1. Error Detection

2. Error Correction

19
Error Detection

Types of Errors
Concept of Redundancy in Error detection
Error Detection Schemes
• Parity Check
• Cyclic Redundancy Check(CRC)
• Checksum

20
Types of Errors
• 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.

• Multiple-Bit error

21
Types of Errors

• 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.

22
Redundancy
To be able to detect or correct errors, we need to send some extra bits with our
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.

23
Error Detection Schemes

Block Coding
Error can be detected by using block coding:
• Divide the message into blocks, each of k bits, called dataword.
• Add r redundant bits to each block to make the length n = k + r.
• The resulting n bits blocks are called codeword.

24
Error Detection Schemes
Parity Check
Single Bit Parity Check

In this technique, a redundant bit called a parity bit is added to every data unit so that the total
number of 1’s in the unit (including the parity bit) becomes even (or odd).

25
Error Detection Schemes
Parity Check
Even Parity Concept

26
Error Detection Schemes

Single Bit Parity Check

Performance

Simple parity check can detect all single-bit errors. It can also detect burst errors as long as the total
number of bits changed is odd. This method cannot detect errors where the total number of hits
changed is even.

27
Error Detection Schemes

2D Parity Check

28
Error Detection Schemes

2D Parity Check

Performance

Two-dimensional parity check increases the likelihood of detecting burst


errors.
However, one pattern of errors that remains exclusive. If 2 bits in one data unit
are damaged and two bits in exactly the same positions in another data unit are
also damaged, the checker will not detect an error.

Consider for example, two data units: 11110000 and 11000011. If the first and
last bits in each of them are changed, making the units read 01110001 and
01000010 the errors cannot he detected by this method.

29
Error Detection Schemes

Cyclic Redundancy Check(CRC)

CRC is based on binary division.


In CRC, instead of adding bits to achieve a desired parity, a sequence
of redundant bits, called the CRC or the CRC remainder, is appended to
the end of a data unit so that the resulting data unit becomes exactly
divisible by a second, predetermined binary number. At its destination,
the incoming data unit is divided by the same number. If at this step
there is no remainder the data unit is assumed to be intact and is
therefore accepted. A remainder indicates that the data unit has been
damaged in transit and therefore must be rejected.

To be valid, a CRC must have two qualities: It must have exactly one
less bit than the divisor, and appending it to the end of the data string
must make the resulting bit sequence exactly divisible by the divisor.

30
Error Detection Schemes
Cyclic Redundancy Check(CRC)

31
Error Detection Schemes
Cyclic Redundancy Check(CRC)

Binary division in a CRC generator


32
Error Detection Schemes
Cyclic Redundancy Check(CRC)

Binary division in a CRC checker


33
Error Detection Schemes
Cyclic Redundancy Check(CRC)

• The divisor in CRC generator is most often represented not as string of 1s and 0s, but as an algebraic polynomial.
• The polynomial is used for two reasons: it is Short and Can be used to prove the concept mathematically
• A polynomial should be selected to have the following :
1.It should not be divisible by x.( i.e the coefficient of term X 0 should be 1)
2.It should be divisible by x+1.
• The first condition: guarantees that all the burst errors of a length equal to the degree of the polynomial are
detected.
• The Second condition: guarantees that all the burst errors affecting an odd number of bits are detected.

34
Error Detection Schemes
Cyclic Redundancy Check(CRC)

A Polynomial

 We can use a polynomial to represent a binary word.


 Each bit from right to left is mapped onto a power
term.
 The rightmost bit represents the “0” power term.
The bit next to it the “1” power term, etc.
 If the bit is of value zero, the power term is deleted
from the expression.

35
Error Detection Schemes
Cyclic Redundancy Check(CRC)

36
Error Detection Schemes
Cyclic Redundancy Check(CRC)

• CRC division using polynomials

37
Error Detection Schemes
Cyclic Redundancy Check(CRC)

Performance of CRC

CRC is a very effective error detection method. If the divisor is chosen


according to the previously mentioned rules,

1.CRC can detect all burst errors that affect an odd number of bits.
2.CRC can detect all burst errors of length less than or equal to the degree of
the polynomial
3.CRC can detect, with a very high probability, burst errors of length greater
than the degree of the polynomial.

38
Error Detection Schemes
Checksum
Like parity checks and CRC, the checksum based on redundancy. The
checksum is used in the Internet by several protocols.

39
Error Detection Schemes
Checksum

40
Error Detection Schemes
Checksum

41
Error Detection Schemes
Checksum

Performance of checksum

• Almost detects all errors involving odd numbers of bits or even.

• If one or more bits of a segment are damaged and the corresponding bit or bits of opposite
value in a second segment are also damaged,
then the sum of columns will not change. Receiver will not be able to detect the error

42
Error Correction

Forward Error Correction


 Block Coding
 Hamming Code
 Convolution Coding
 Out of scope

Error Correction by Retransmission


 Will be discussed in Lecture 4

Burst Error Correction

43
Error Correction
Hamming Code

The Hamming distance between two words is the number of differences


between corresponding bits.

Let us find the Hamming distance between two pairs of words.

1.The Hamming distance d(000, 011) is 2 because

2.The Hamming distance d(10101, 11110) is 3 because

44
Error Correction
Hamming Code

The minimum Hamming distance is the smallest Hamming distance


between all possible pairs in a set of words.

Find the minimum Hamming distance of the coding scheme in Table 1.


Solution:
We first find all Hamming distances.

The dmin in this case is 2.

45
Error Correction
Hamming Code

Table 1
46
Error Correction

Hamming Code

To guarantee the detection of up to s errors in all cases, the minimum


Hamming distance in a block code must be dmin = s + 1.

To guarantee correction of up to t errors in all cases, the minimum


Hamming distance in a block code must be dmin = 2t + 1.

47
Error Correction

Hamming Code

Positions of redundancy bits in Hamming code:


Redundancy bits are placed in the position of power of 2.

48
Error Correction
Hamming Code

Redundancy bits calculation

49
Error Correction
Hamming Code

Example of redundancy bit calculation

50
Error Correction
Hamming Code

Error detection using Hamming code

51
Error Correction

Burst error correction

• Hamming code cannot correct a burst error directly, it is possible to


rearrange the data and then apply the code.
• Organize N units in a column and then send the first bit for each,
followed by the second bit of each , and so on.
• If a burst error of M bits occurs (M<N) then the error does not corrupt
M bits of one single unit, its corrupts only 1 bit of a unit.
• With Hamming, we can then correct the corrupted bit in each unit.

52
Error Correction
Burst error correction

53
Error Correction
Burst error correction

54
Where is Data Link Layer in OSI model?
Heading2-Cambria 32 Blue Accent-1 Align left
This is a running text-Cambria 24 Black Align left
 Use this bullet. Align left
• You can highlight a keyword in red Align left

1/20/20 KL Hyderabad 55

You might also like