data link layer

23
UNIT II Data Link Layer

Upload: sajid-akram

Post on 12-Nov-2014

256 views

Category:

Education


1 download

DESCRIPTION

second layer of OSI/ISO MODEL

TRANSCRIPT

Page 1: Data link layer

UNIT II

Data Link Layer

Page 2: Data link layer

Functions of the Data Link Layer

•Provide service interface to the network layer

•Error control-Dealing with transmission errors

•Flow control-Regulating data flow

Page 3: Data link layer

Functions of the Data Link LayerRelationship between packets and frames.

Page 4: Data link layer
Page 5: Data link layer

Line disciplineLine discipline answers the questions who

should send first?The line discipline functions of data link

layer checks for establishment of links and the right of a particular device to transmit at a given time

Can be done in two waysEnquiry/acknowledgementPoll/select

Page 6: Data link layer

Line discipline: ENQ/ACKIt is used in peer to peer communicationIt is possible in when there is a dedicated

link between two devicesUsing this, a session can be initiated by

either station on a link as long as both are equal rank

Page 7: Data link layer

ENQ/ACK: how it works?

Page 8: Data link layer

Line discipline: poll/selectIt works for topologies where one device

designated as a primary station and the other devices are secondary devices

Polling: if primary wants to receive the data, it asks the secondary if they have anything to send

Select: if primary wants to send data, it asks the target secondary to get ready to receive

Addressing is required

Page 9: Data link layer
Page 10: Data link layer

Framing Separation of a message from one source to

destination or from other messages to other destinations

Frames can be of fixed or variable sizeIn fixed size framing, there is no need for

defining boundaries of a frame, eg: ATM cellsIn variable size framing, the beginning and

ending of a frame has to be defined eg: LANVariable size framing can be done in two ways:

Character orientedBit oriented

Page 11: Data link layer

Framing with character orientedHere the data to be carried are of 8 bit

characters as ASCIITo separated each frame from next, an 8

bit flag is added at the beginning and at the end of a frame

Problems dealing with the content of a flagSolution: byte stuffing

Page 12: Data link layer

Byte stuffingA special byte is added to the data section of

the frame when there is a character with the same pattern as the flag

This added extra byte is usually called the escape character, which has a predefined bit pattern

So when the receiver encounters ESC, it removes it from the data section and treats the next character as data and not as delimiting flag

Character oriented protocols are not in much use today

Page 13: Data link layer
Page 14: Data link layer

Framing with bit orientedHere the data to be transferred of a frame

consists of a sequence of bitsMost protocols use a special 8 bit pattern

flag as 01111110 as a delimiter to define the beginning and the end of a frame

Page 15: Data link layer

If the flag pattern appears in the data, then same problem arises. To solve for this, bit stuffing strategy is implemented

Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data, so that the receiver does

not mistakethe pattern 0111110 for a flag.

Page 16: Data link layer
Page 17: Data link layer

Flow control• Flow control coordinates the amount of

data that can be sent before receiving acknowledgement

• It is one of the most important functions of data link layer.

• Flow control is a set of procedures that tells the sender how much data it can transmit before it must wait for an acknowledgement from the receiver.

Page 18: Data link layer

• Receiver has a limited speed at which it can process incoming data and a limited amount of memory in which to store incoming data.

• Receiver must inform the sender before the limits are reached and request that the transmitter to send fewer frames or stop temporarily.

• Since the rate of processing is often slower than the rate of transmission, receiver has a block of memory (buffer) for storing incoming data until they are processed

Page 19: Data link layer

Types of flow controlTwo methods have been developed to

control flow of dataStop and wait Sliding window

In stop and wait, the sender waits for an ACK after every frame it sends. Only after an ACK is received, next frame is sent

In sliding window, the sender can transmit several frames before needing an ACK

Page 20: Data link layer

Stop-and-Wait Sender keeps a copy of the last

frame until it receives an acknowledgement.

For identification, both data frames and acknowledgements (ACK) frames are numbered alternatively 0 and 1.

Sender starts a timer when it sends a frame. If an ACK is not received within a allocated time period, the sender assumes that the frame was lost or damaged and resends it

Receiver send only positive ACK if the frame is intact.

ACK number always defines the number of the next expected frame

Page 21: Data link layer

Sequence Numbers• Frames from a sender are numbered

sequentially.• We need to set a limit since we need to include

the sequence number of each frame in the header.

• If the header of the frame allows m bits for sequence number, the sequence numbers range from 0 to 2 m – 1. for m = 3, sequence numbers are: 1, 2, 3, 4, 5, 6, 7.

• We can repeat the sequence number.• Sequence numbers are:

0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, …

Page 22: Data link layer

Sender Sliding Window• At the sending site, to

hold the outstanding frames until they are acknowledged, we use the concept of a window.

• The size of the window is at most 2m -1 where m is the number of bits for the sequence number.

• Size of the window can be variable, e.g. TCP.

• The window slides to include new unsent frames when the correct ACKs are received

Page 23: Data link layer

Receiver Sliding Window

• Size of the window at the receiving site is always 1 in this protocol.

• Receiver is always looking for a specific frame to arrive in a specific order.

• Any frame arriving out of order is discarded and needs to be resent.

• Receiver window slides as shown in fig. Receiver is waiting for frame 0 in part a.