Anda di halaman 1dari 35

DATA LINK LAYER

Data Link Layer-Functions

For the effective data communication data link layer


needs to perform a number of specified functions.
Services provided to network layer
The main functionality of this layer is to transfer data from the
network layer on source machine to the network layer on
destination machine

Flow Control
The source machine should sent data at a rate which is
suitable
for destination machine to accept them

Data Link Layer-Functions


Framing

The bits to be transmitted is broken down into discrete


frames.
A frame contains user data and control fields.

Error Control
All the frames should be delivered from source to the
destination. The errors made in bits during transmission
must
be detected and corrected

Addressing
On a multipoint line, such as many machines connected
together, identity of individual machines must be specified
while transmitting data frames

Frame Format

The Data Link layer prepares a packet for transport


across the local media by encapsulating it with a header
and a trailer to create a frame
The Data Link layer frame includes:
Data - The packet from the Network layer
Header - Contains fields used for addressing and is
located at the beginning of the frame
Trailer - Contains fields are used for error detection
and
mark the end of the frame

Frame Format

Frame Synchronization

Frame synchronization or simply framing is the process of


defining and locating frame boundaries (start and end of
the frame) on a bit sequence
The frame format is designed in a way that enables the
receiver to always locate the beginning of a frame and its
various fields and should be able to separate the data field
To identify a frame and its various fields, field identifiers
are incorporated.
These are unique symbols that indicate by their presence
the beginning and end of a frame

Framing Methods

Four methods can be used to mark the start and


end of each frame:
Character count
Flag bytes with byte stuffing
Starting and ending flags, with bit
stuffing
Physical layer coding violations

Character Count

Character count, uses a header field to specify


the number of characters in the frame.
The Data Link Layer at the destination checks
the header field to know the size of the frame
and hence, the end of frame.

Character Count

The disadvantage is that if the count is garbled by a transmission error,


the destination will lose synchronization and will be unable to locate the
start of the next frame

Flag bytes with byte


stuffing

Also referred to as character stuffing


This was one of the earliest schemes for delimiting packets
containing character data, and it employees three special
control characters in ASCII for the purpose of framing
DLE is Data Link Escape, STX is Start of Text and ETX is
End of Text
Begin each frame with DLE STX and end each frame with
DLE ETX

Flag bytes with byte


stuffing

Flag bytes with byte


stuffing

The problem occurs when these character


patterns occur within the transparent data.
Solution: sender stuffs an extra DLE into the
data stream just before each occurrence of an
accidental DLE in the data stream.
The data link layer on the receiving end
unstuffs the DLE before giving the data to the
network layer.

Flag bytes with byte


stuffing

Starting and ending flags, with bit


stuffing

The method of bit stuffing allows insertion of bits


instead of the entire character (8 bits).
Bit pattern framing uses a particular sequence of
bits called a flag for framing. The flag is set as the
start and the end of the frame
Flag = 0 11 1 11 10 (begins and ends frame.)

Starting and ending flags, with


bit stuffing

To make sure this sequence doesn't appear again


before the end of the packet, a 0 is inserted after
every five consecutive 1s.
This is called Bit stuffing. The receiver discards
these stuffed 0s as soon as it encounters 5
consecutive 1s in the received data

Starting and ending flags,


with bit stuffing

Physical Layer Coding


Violation

Physical layer coding violations is applicable to


networks in which the encoding on the physical
medium contains some redundancy.

In this method Bit 1 Is encoded into highlow(10) Pair And Bit 0 Is Encoded Into lowhigh(01)pair shown in figure.
The combinations of low-low and high-high
which are not used for data may be used for
marking frame boundaries.

Flow Control

the sender transmits frames faster than the


receiver can accept or process them.
In this process of transmission, some of the
frames might be lost as they were not
processed by the receiver due to its low speed.
To prevent this situation during transmission, a
method is introduced called the Flow Control

Flow Control

Flow control will control the rate of frame


transmission to a value which can be handled by
the receiver
It uses some feedback mechanism by which, the
sender can be aware of when to the send next
frame, and not at the usual Speed of the sender
If the frame is accepted /processed by the receiver
then only will the sender send the next frame

Flow Control

There are several methods available for deciding


when a sender should send the next frame

Flow control ensures that the speed of sending the


frame, by the sender, and the speed of processing
the received frame by the receiver are compatible.
Receiver is provided with a control to regulate the
flow of incoming frames. This control is in the form
of an acknowledgment which is send by the
receiver

Flow Control

Two methods have been developed to control flow of data


across communications links:

1) Stop-and-wait
sending end sends one frame at a time and waits for
an
acknowledgment from receiver.
2) Sliding window
sending end continues sending data frames one after
another without waiting fro acknowledgments for
individual data frames

Stop and Wait

The simplest form of flow control

The message is broken into multiple frames and


only a single frame is send at a time.

The Sender waits for an ACK (acknowledgement) after


every frame

It will then send the next frame only after the ACK has
been received.

Sender keeps a copy of the last frame until it receives an


acknowledgement.

Stop and Wait

Stop and Wait

Stop and Wait

For identification, both data frames


acknowledgements
(ACK)
frames
numbered alternatively 0 and 1.

and
are

Sender has a control variable (S) that holds


the number of the recently sent frame. (0 or 1)
Receiver has a control variable R that holds
the number of the next frame expected (0 or
1).

Stop-and-Wait Adv & Disv

The advantage of stop and- wait is simplicity:


Each frame is checked and acknowledged before the
next frame is sent.
The disadvantage is inefficiency:
In stop-and-wait, at any point in time, there is only
one frame that is sent and waiting to be
acknowledged.

stop-and-wait is slow. Each frame must travel all the


way to the receiver and an acknowledgment must
travel all the way back before the next frame can be
sent.

Sliding Window

In this flow control method, the sending end continues


to transmit the data frame without waiting for
acknowledgement for the last frame.

So the link is utilized in a more efficient manner

Each data frame carries a sequence number for its


identification

If k bits are reserved for the sequence number, then the


values of sequence number ranges from 0 to 2k1

Sliding Window

The receiver acknowledges the receipt of one or more


data
frames
by
sending
back
a
numbered
acknowledgment which specifies the sequence number
of the next expected frame.

All
the
previous
data
frames
are
assumed
acknowledged on receipt of an acknowledgement

The sender sends the next n frames starting with the


last received sequence number that has been
transmitted by the receiver (ACK).

Operation of a
Sliding Window

In this mechanism we maintain two types of


windows:
sending window and receiving window

Sending window maintains sequence numbers of


frames sent out but not acknowledged and frames
which are next to be transmitted
The receiver window maintains the set of frames
permitted to accept.

Sending Window

Sending Window

beginning of a

At the
transmission,
senders window contains n frames.

the

As frames are sent out, the left boundary of


the window moves inward, shrinking the size
of the window.
Once an ACK arrives, the window expands to
allow in a number of new frames equal to the
number of frames acknowledged by that ACK.

Receiving Window

Receiving Window

At the beginning of transmission, the receiver window contains


n spaces for frames.
As new frames come in, the size of the receiver window shrink
The receiver window therefore represents not the number of
frames received but the number of frames that may still be
received before an ACK must be send
As each ACK is sent out, the receiving window expands to
include as many new placeholders as newly acknowledged
frames

Functioning of Sliding
Window

Functioning of
Sliding Window

Anda mungkin juga menyukai