0% found this document useful (0 votes)
17 views48 pages

Unit-2 Data Link Layer

The document provides an overview of the Data Link Layer (DLL) in networking, detailing its functions such as framing, error detection and correction, flow control, and media access control. It discusses various methods for framing, including byte and bit stuffing, as well as error detection techniques like VRC, LRC, CRC, and checksums. Additionally, it covers error correction methods, including Hamming code and retransmission strategies, emphasizing the importance of these processes in ensuring accurate data transmission.

Uploaded by

22b01a45a0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views48 pages

Unit-2 Data Link Layer

The document provides an overview of the Data Link Layer (DLL) in networking, detailing its functions such as framing, error detection and correction, flow control, and media access control. It discusses various methods for framing, including byte and bit stuffing, as well as error detection techniques like VRC, LRC, CRC, and checksums. Additionally, it covers error correction methods, including Hamming code and retransmission strategies, emphasizing the importance of these processes in ensuring accurate data transmission.

Uploaded by

22b01a45a0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48

Unit-2

Data Link Layer


Table of Contents
 Overview of DLL
 Framing
 Byte Stuffing
 Bit Stuffing
 Error Detection and Error Correction
 Error Detection Methods
 VRC
 LRC
 CRC
 Checksum
 Error Correction Methods
 Hamming Code
 Flow Control
 Error Control
 Wired LANs
 Wireless LANs
 Bridge
 Switch
OVERVIEW OF DLL
The data link layer transforms the physical layer, a raw
transmission facility, to a link responsible for node-to-node (hop-
to-hop) communication. Specific responsibilities of the data link
layer include framing, addressing, flow control, error control,
and media access control.

2
FRAMING
 DLL translates the physical layer's raw bit
stream into discrete units (messages) called frames.
 How can frame be transmitted so the receiver
can
detect frame boundaries ?
That is, how can the receiver recognize the start and end of a
frame?
 Character Count
 Flag byte with Byte Stuffing
 Starting and ending flag with bite stuffing
 Encoding Violations
FRAMING – CHARACTER COUNT
 The first framing method uses a field in the header to
specify the number of characters in the frame. When
the data link layer at the destination sees the character
count, it knows how many characters follow and hence
where the end of the frame is.

1
The trouble with this algorithm is that the count can be garbled by a1
transmission error. 5
FRAMING – BYTE STUFFING
 Use reserved characters to indicate the start and end of a frame. For
instance, use the two-character sequence DLE STX (Data-Link
Escape, Start of TeXt) to signal the beginning of a frame, and the
sequence DLE ETX (End of TeXt) to flag the frame's end.
 The second framing method, Starting and ending character stuffing,
gets around the problem of resynchronization after an error by
having each frame start with the ASCII character sequence DLE STX
and end with the sequence DLE ETX.
 Problem: What happens if the two-character sequence DLX
ETX happens to appear in the frame itself?
 Solution: Use character stuffing; within the frame, replace every
occurrence of DLE with the two-character sequence DLE DLE. The
receiver reverses the processes, replacing every occurrence of DLE
DLE with a single DLE.
 Example: If the frame contained ``A B DLE D E DLE'', the characters
transmitted over the channel would be ``DLE STX A B DLE DLE D E
DLE DLE DLE ETX''.
 Disadvantage: character is the smallest unit that can be
1
operated on; not all architectures are byte oriented. 2
6
7
Byte stuffing and unstuffing

8
FRAMING – BIT STUFFING
 This technique allows data frames to contain an arbitrary number of
bits and allows character codes with an arbitrary number of bits per
character. It works like this. Each frame begins and ends with a
special bit pattern, 01111110 (in fact, a flag byte).
 Whenever the sender's data link layer encounters five consecutive
1s in the
data, it automatically stuffs a 0 bit into the outgoing bit stream.
 This bit stuffing is analogous to byte stuffing, in which an escape
byte is stuffed into the outgoing character stream before a flag
byte in the data. When the receiver sees five consecutive incoming
1 bits, followed by a 0 bit, it automatically destuffs (i.e., deletes)
the 0 bit

9
Byte stuffing and unstuffing

10
ERROR CORRECTION AND DETECTION
 It is physically impossible for any data recording or
transmission medium to be 100% perfect 100% of the
time over its entire expected useful life.
 In data communication, line noise is a fact of life (e.g., signal
attenuation, natural phenomenon such as lightning, and the
telephone repairman).
 As more bits are packed onto a square centimeter of
disk storage, as communications transmission speeds
increase, the likelihood of error increases-- sometimes
geometrically.
 Thus, error detection and correction is critical to
accurate data transmission, storage and retrieval.

 Detecting and correcting errors requires redundancy --


sending additional information along with the data.
11
Types of Errors
 There are two main types of errors in transmissions:
1. Single bit error : It means only one bit of data unit is
changed from 1 to 0 or from 0 to 1.

2. Burst error : It means two or more bits in data unit are


changed from 1 to 0 from 0 to 1. In burst error, it is not
necessary that only consecutive bits are changed. The
length of burst error is measured from first changed bit to
last changed bit

12
Error Detection & Error Correction
 There are two types of attacks against errors:
 Error Detecting Codes: Include enough redundancy
bits to detect
errors and use ACKs and retransmissions to recover from
the errors.
 Error Correcting Codes: Include enough redundancy
to detect and correct errors. The use of error-correcting
codes is often referred to as forward error correction.

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

Vertical Redundancy Check (VRC)

14
Vertical Redundancy Check (VRC)
 Append a single bit at the end of data block such that
the number of ones is even
 Even Parity (odd parity is similar)
0110011  01100110
0110001  01100011
 VRC is also known as Parity Check. Detects all odd-
number errors in a data block

15
EXAMPLE OF VRC
 The problem with parity is that it can only detect odd
numbers of bit substitution errors, i.e. 1 bit, 3bit, 5,
bit, etc. errors. If there two, four, six, etc. bits which
are transmitted in error, using VRC will not be able to
detect the error.

2
6
16
Longitudinal Redundancy Check (LRC)
 Longitudinal Redundancy Checks (LRC) seek to overcome the
weakness of simple, bit-oriented, one-directional parity checking.
 LRC adds a new character (instead of a bit) called the Block Check
Character (BCC) to each block of data. Its determined like parity, but
counted longitudinally through the message (also vertically)
 Its has better performance over VRC as it detects 98% of the burst
errors (>10 errors) but less capable of detecting single 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.

11100111 11011101 00111001


10101001
11100111
11011101
00111001
10101001
10101010
2
11100111 11011101 0011100110101001 7
10101010 Original LRC
17
Data
2D Parity Check
 Upon receipt, each character is checked according to
its VRC parity value and then the entire block of
characters is verified using the LRC block check
character.

18
19
CYCLIC REDUNDANCY CHECK (CRC)
 The cyclic redundancy check, or CRC, is a technique for
detecting errors in digital data, but not for making corrections
when errors are detected. It is used primarily in data
transmission
 In the CRC method, a certain number of check bits, often
called a checksum, are appended to the message being
transmitted. The receiver can determine whether or not the
check bits agree with the data, to ascertain with a certain
degree of probability whether or not an error occurred in
transmission
 The CRC is based on polynomial arithmetic, in particular, on
computing the remainder of dividing one polynomial in GF(2)
(Galois field with two elements) by another.
 Can be easily implemented with small amount of hardware
 Shift registers
 XOR (for addition and subtraction) 3
1

20
CRC Calculation

 Given a k-bit frame or message, the transmitter


generates an n-bit sequence, known as a frame
check sequence (FCS), so that the resulting frame,
consisting of (k+n) bits, is exactly divisible by
some predetermined number.

21
CYCLIC REDUNDANCY CHECK
 Let M(x) be the message polynomial
 Let P(x) be the generator polynomial
 P(x) is fixed for a given CRC scheme
 P(x) is known both by sender and receiver
 Create a block polynomial F(x) based on M(x)
and P(x) such that F(x) is divisible by P(x)

0
F (x)
P(x)  Q(x) P(x)

22
CYCLIC REDUNDANCY CHECK
 Sending
1. Multiply M(x) by xn
2. Divide xnM(x) by P(x)
3. Ignore the quotient and keep the
reminder C(x)
4. Form and send F(x) = xnM(x)+C(x)

 Receiving
1. Receive F’(x)
2. Divide F’(x) by P(x)
3. Accept if remainder is 0, reject otherwise

23
Example of CRC
 Consider a message 110010 represented by the polynomial
M(x) = x5 + x4 + x Consider a generating polynomial G(x) =
x3 + x2 + 1 (1101)
This is used to generate a 3 bit CRC = C(x) to be appended to
M(x).

Steps:
1. Multiply M(x) by x3 (highest power in G(x)). i.e. Add 3 zeros.
110010000
2. Divide the result by G(x). The remainder = C(x).
1101 long division into 110010000 (with subtraction mod 2)
= 100100 remainder 100
3. Transmit 110010000 + 100
To be precise, transmit: T(x) = x3M(x) + C(x)
= 110010100
4. Receiver end:
Receive T(x). Divide by G(x), should have remainder 0.

24
25
26
CHECKSUM
 Checksum is the error detection scheme used in IP, TCP & UDP.
 Here, the data is divided into k segments each of m bits. In the
sender’s end the segments are added using 1’s complement
arithmetic to get the sum. The sum is complemented to get the
checksum. The checksum segment is sent along with the data
segments
 At the receiver’s end, all received segments are added using 1’s
complement arithmetic to get the sum. The sum is
complemented. If the result is zero, the received data is
accepted; otherwise discarded
 The checksum detects all errors involving an odd number of bits.
It also detects most errors involving even number of bits.

27
CHECKSUM

28
Checksum Example

29
30
31
32
ERROR CORRECTION
 Once detected, the errors must be corrected

 Two Techniques for error correction


 Retransmission (aka Backward error
correction)
 Simplest, effective and most
commonly used technique–
involves correction by retransmission of data by the
sender
 Popularly called Automatic Repeat Request (ARQ)

 Forward Error Correction (FEC) 5


 Receiving device can correct the errors itself 1
33
ERROR CORRECTION
 Messages (frames) consist of m data (message) bits and r
redundancy bits, yielding an n = (m+r)-bit codeword.
 Hamming Distance. Given any two codewords, we can
determine how many of the bits differ. Simply exclusive or
(XOR) the two words, and count the number of 1 bits in the
result.
 Significance? If two codewords are d bits apart, d errors are
required to convert one to the other.
 A code's Hamming Distance is defined as the minimum
Hamming Distance between any two of its legal
codewords (from all possible codewords).
 To detect d 1-bit errors requires having a Hamming
Distance of at
least d+1 bits.
 To correct d errors requires 2d+1 bits. Intuitively, after d
errors, the garbled messages is still closer to the original
message than any other legal codeword.
34
Hamming Code
 Ex : If The Value of m is 7, the Relation will Satisfy if The
Minimum Value of r is 4.
2^4 = 16 > 7+4+1

53

35
Example of Hamming Code

If The Number of Data bit is 7, Then The Position of


Redundant bits Are :
2^0=1 2^1=2
2^2=4 2^3=8

36
55
37
56
38
Let Receiver receives 10010100101

39
Burst Error Correction

 Hamming Code Cannot Correct a burst Error


Directly.
 it is Possible To Rearrange The Data and Then
Apply The code.
Instead of Sending All the bits in The data Unit
Together, we can organize N units in a column.
Send The First bits of Each Followed by The Second
bit of each, and so on.
In This Way, if a burst Error of M bit Occurs (M<N),
Then The Error does not Corrupt M bit of Single Unit,
it Corrupt Only 1 bit of Unit.
 Then We Can Correct it Using Hamming Code
Scheme. 40
Hamming Code

41
Flow Control
• Flow control is a technique that allows two stations
working at different speeds to communicate with
each other.
• It is a set of measures taken to regulate the
amount of data that a sender sends so that a fast
sender does not overwhelm a slow receiver.
• In data link layer, flow control restricts the number
of frames the sender can send before it waits for an
acknowledgment from the receiver.

42
Error Control
• Error control in data link layer is the process of
detecting and correcting data frames that have
been corrupted or lost during transmission.
• In case of lost or corrupted frames, the receiver
does not receive the correct data-frame and sender
is ignorant about the loss.
• Data link layer follows a technique to detect transit
errors and take necessary actions, which is
retransmission of frames whenever error is detected
or frame is lost. The process is called Automatic
Repeat Request (ARQ). 43
Wired LANs
• Ethernet or local area network (LAN) is a computer
network that is designed for a limited geographic
area such as a building or a campus.
• Although a LAN can be used as an isolated
network to connect computers in an organization for
the sole purpose of sharing resources.
• The LAN market has several technologies such as
Ethernet, Token Ring, Token Bus, FDDI, and ATM
LAN. Some of these technologies survived for a
while, but Ethernet is by far the dominant
technology. 44
Wireless LANs
• Ethernet or local area network (LAN) is a computer
network that is designed for a limited geographic area
such as a building or a campus.
• A wireless LAN (WLAN) is a wireless computer
network that links two or more devices using wireless
communication to form a LAN within a limited area such
as a home, school, computer laboratory, campus, or
office building. This gives users the ability to move
around within the area and remain connected to the
network.
•Through a gateway, a WLAN can also provide a
connection to the wider Internet. 45
Bridge
• A bridge operates at data link layer. A bridge is a
repeater, with add on the functionality of filtering
content by reading the MAC addresses of source
and destination.
• It is also used for interconnecting two LANs
working on the same protocol. It has a single input
and single output port, thus making it a 2 port
device.
• Types of Bridges
• Transparent Bridges
• Source Routing Bridges 46
Switch
• A switch is a multiport bridge with a buffer and a
design that can boost its efficiency(a large number
of ports imply less traffic) and performance.
• A switch is a data link layer device. The switch can
perform error checking before forwarding data, that
makes it very efficient as it does not forward
packets that have errors and forward good packets
selectively to correct port only.
• In other words, switch divides collision domain of
hosts, but broadcast domain remains same.
47
References

• https://www.sciencedirect.com/topics/computer-sc
ience/data-link-layer

• https://www.sciencedirect.com/topics/engineering
/data-link-layer

• http://teachweb.milin.cc/datacommunicatie/tcp_o
si_model/data-link_layer.htm

• https://www.studytonight.com/computer-networks
/osi-model-datalink-layer

48

You might also like