0% found this document useful (0 votes)
214 views13 pages

Data Link Layer Intro

The data link layer performs several key functions: 1. It frames data by adding header and trailer bits to packets so the receiver knows the packet boundaries. 2. It handles physical addressing by adding the source and destination MAC addresses to each frame. 3. It performs error checking by computing checksums for each frame and retransmitting corrupted frames.

Uploaded by

Harsha Jadav
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
214 views13 pages

Data Link Layer Intro

The data link layer performs several key functions: 1. It frames data by adding header and trailer bits to packets so the receiver knows the packet boundaries. 2. It handles physical addressing by adding the source and destination MAC addresses to each frame. 3. It performs error checking by computing checksums for each frame and retransmitting corrupted frames.

Uploaded by

Harsha Jadav
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 13

Data link layer

Introduction
Data Link Layer is second layer of OSI Layered Model. This
layer is one of the most complicated layers and has
complex functionalities and liabilities. Data link layer hides
the details of underlying hardware and represents itself to
upper layer as the medium to communicate.
• Data link layer has two sub-layers:
• Logical Link Control: It deals with protocols, flow-control,
and error control
• Media Access Control: It deals with actual control of media
Page 2

Functions of Data-link Layer :


• Framing: Framing is a function of the data link layer. It provides
a way for a sender to transmit a set of bits that are meaningful
to the receiver. This can be accomplished by attaching special
bit patterns to the beginning and end of the frame.
• Physical addressing: After creating frames, the Data link layer
adds physical addresses (MAC address) of the sender and/or
receiver in the header of each frame.
• Error control: Data link layer provides the mechanism of error
control in which it detects and retransmits damaged or lost
frames
Page 3
• Flow Control: The data rate must be constant on both
sides else the data may get corrupted thus, flow control
coordinates the amount of data that can be sent before
receiving acknowledgement.
• Access control: When a single communication channel is
shared by multiple devices, the MAC sub-layer of the
data link layer helps to determine which device has
control over the channel at a given time.
• Synchronization: When data frames are sent on the link, both
machines must be synchronized in order to transfer to take
place.
Page 4

Framing:
• To provide service to the network layer, the data link layer must use the
service provided to it by the physical layer.
• What the physical layer does is accept a raw bit stream and attempt to
deliver it to the destination. This bit stream is not guaranteed to be
error free.
• . It is up to the data link layer to detect and, if necessary, correct errors.
• The usual approach is for the data link layer to break the bit stream up
into discrete frames and compute the checksum for each frame. When
a frame arrives at the destination, the checksum is recomputed. If the
newly computed checksum is different from the one contained in the
frame, the data link layer knows that an error has occurred.
Page 4

• Breaking the bit stream up into frames is more difficult.


• One way to achieve this framing is to insert time gaps between
frames, much like the spaces between words in ordinary text.
• However, networks rarely make any guarantees about timing,.
Since it is too risky to count on timing to mark the start and
end of each frame, other methods have been devised. The
four methods:
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags, with bit stuffing.
4. Physical layer coding violations.
Page 5
• 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.
• This technique is shown in Fig.2.1 (a) for four frames of sizes 5,
5, 8, and 8 characters, respectively. The trouble with this
algorithm is that the count can be garbled by a transmission
error. For example, if the character count of 5 in the second
frame of Fig(b) becomes a 7, the destination will get out of
synchronization and will be unable to locate the start of the
next frame.
Figure: A character stream. (a) Without errors.
(b) With one error.
Page 7
• Even if the checksum is incorrect so the destination knows
that the frame is bad, it still has no way of telling where the
next frame starts.
• The second framing method having each frame start and end
with special bytes. In the past, the starting and ending bytes
were different, but in recent years most protocols have used
the same byte, called a flag byte, as both the starting and
ending delimiter, as shown in Fig2.2.(a) as FLAG.
Fig2.2: (a) A frame delimited by flag bytes (b) Four examples of
byte sequences before and after byte stuffing
Page 9
• A serious problem occurs with this method when binary data, such
as object programs or floating-point numbers, are being transmitted.
It may easily happen that the flag byte's bit pattern occurs in the
data.
• This situation will usually interfere with the framing. One way to
solve this problem is to have the sender's data link layer insert a
special escape byte (ESC) just before each ''accidental'' flag byte in
the data.
• The data link layer on the receiving end removes the escape byte
before the data are given to the network layer. This technique is
called byte stuffing or character stuffing. Thus, a framing flag byte
can be distinguished from one in the data by the absence or
presence of an escape byte before it.
Page 10
• Of course, the next question is: What happens if an escape byte
occurs in the middle of the data? The answer is that it, too, is stuffed
with an escape byte. Thus, any single escape byte is part of an
escape sequence, whereas a doubled one indicates that a single
escape occurred naturally in the data. Some examples are shown in
Fig2.2.(b). In all cases, the byte sequence delivered after de stuffing
is exactly the same as the original byte sequence.
• The new 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.
Page 11
• 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 de stuffs (i.e., deletes) the 0 bit. Just as byte stuffing is
completely transparent to the network layer in both computers, so is bit
stuffing. If the user data contain the flag pattern, 01111110, this flag is
transmitted as 011111010 but stored in the receiver's memory as
01111110.
Page 12

• Figure above : Bit stuffing. (a) The original data. (b) The
data as they appear on the line. (c) The data as they
are stored in the receiver's memory after destuffing.

You might also like