0% found this document useful (0 votes)
6 views

Unit 2

Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Unit 2

Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

Layer 2

Data Link Layer


Is responsible for
• Framing
• Addressing
• Flow and Error Control
• Media access control

19\08\2011 Unit-II Data Link Layer 1


Unit 2: DATA LINK CONTROL
Overview
Framing
Flow and Error Control Protocols
Noiseless Channels
• Simplest Protocol
• Stop and Wait
Noisy Channels
• Stop-and-Wait Automatic Repeat Request (ARQ)
• Go-back-N Automatic Repeat Request,
• Selective repeat Automatic Repeat Request
HDLC (High-level Data Link Control )

19\08\2011 Unit-II Data Link Layer 2


Data Link Layer

19\08\2011 Unit-II Data Link Layer 3


Data Link Layer

Main functions of the data link layer are data link


control and media access control.
Provides a well-defined service interface to the network
layer.
Determines how the bits of the physical layer are
grouped into frames (framing).
Deals with transmission errors (CRC and ARQ).
Regulates the flow of frames.
Performs general link layer management.

19\08\2011 Unit-II Data Link Layer 4


FRAMING
The data link layer needs to pack bits into frames, so that each frame
is distinguishable from another. Our postal system practices a type of
framing. The simple act of inserting a letter into an envelope
separates one piece of information from another; the envelope serves
as the delimiter.

Frames are the packets of information at the Data


Link Layer
Frames are logical delineations in data
• helps flow and error control
Frames contain
• Data
• Source and Destination address information
• Error detection or correction information
19\08\2011 Unit-II Data Link Layer 5
FRAMING
Frame Size
A frame could contain an entire data message but this is not efficient.
• An error in a large frame could require retransmission, wasting time and bandwidth
• Forward error correction is too difficult using large frames

Frame Orientation
Character (8-bit/single byte) oriented protocol
Bit-oriented protocol

19\08\2011 Unit-II Data Link Layer 6


FRAMING

A frame in a character-oriented protocol


Frame begins and ends with a predefined 8-bit configuration.
Frames are delimited by flags.
The header normally carries the source address and the trailer
which carries error detection or correction bits
To separate frame Flag is added at the beginning and end of
the frame.
Byte stuffing is required to prevent misinterpretation of the flag
pattern appearing in the data.

19\08\2011 Unit-II Data Link Layer 7


Byte stuffing and unstuffing

Byte stuffing is the process of adding 1 extra byte whenever


there is a flag or escape character in the text.
This byte is usually escape character (ESC)

19\08\2011 Unit-II Data Link Layer 8


Byte stuffing and unstuffing

DLE STX Transparent Data ETX DLE

Before

DLE STX A B DLE H W ETX DLE


Stuffed

DLE STX A B DLE DLE H W ETX DLE


Unstuffed

DLE STX A B DLE H W ETX DLE

DLE-Data link Escape, STX-Start of Text, ETX- End of Text

19\08\2011 Unit-II Data Link Layer 9


Bit Oriented Protocol

A frame in a bit-oriented protocol

Data section is a sequence of bits.


The standard start and end flag consists of these 8 bits:
01111110
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 mistake the pattern 01111110
for a flag.

19\08\2011 Unit-II Data Link Layer 10


Bit stuffing and unstuffing

19\08\2011 Unit-II Data Link Layer 11


Flow & Error Control
Flow Control

• Flow control refers to a set of procedures used to restrict the


amount of data that the sender can send before waiting for
acknowledgment.

• Flow control is the regulation of the sender’s data rate so


that the receiver buffer does not become overwhelmed.

Error Control
Error control is both error detection and error correction.
Error control in the data link layer is based on automatic
repeat request, which is the retransmission of data.

19\08\2011 Unit-II Data Link Layer 12


Protocols

NOISELESS CHANNELS
In these protocols it is assumed as an ideal channel in
which no frames are lost, duplicated, or corrupted.

19\08\2011 Unit-II Data Link Layer 13


Simplest Protocol
The design of the simplest protocol with no flow or error control

1 Event at transmitter and 1 event at receiver


19\08\2011 Unit-II Data Link Layer 14
Simplest Protocol
Sender-site algorithm for the simplest protocol

Receiver-site algorithm for the simplest protocol

19\08\2011 Unit-II Data Link Layer 15


Simplest Protocol

Flow diagram

 The sender sends a sequence of frames to the receiver.


 To send three frames, three events occur at the sender site
and three events at the receiver site.
 Note that the data frames are shown by tilted boxes; the
height of the box defines the transmission time difference
between the first bit and the last bit in the frame.
19\08\2011 Unit-II Data Link Layer 16
Stop-and-Wait Protocol
If frames are arrived at the receiver before processing,
frames must be stored.
Normally receiver does not have sufficient storage space.
This may discard the next arrival frames.
To prevent this :
Source transmits single frame
Wait for ACK
If received frame damaged, discard it
• If no ACK, retransmit
If ACK damaged, transmitter will not recognize it
• Transmitter will retransmit
• Receiver gets two copies of frame

19\08\2011 Unit-II Data Link Layer 17


Stop-and-Wait Protocol
Design of Stop-and-Wait Protocol

2 Events at transmitter and 1 event at receiver


19\08\2011 Unit-II Data Link Layer 18
Stop-and-Wait Protocol
Sender-site algorithm for Stop-and-Wait Protocol

19\08\2011 Unit-II Data Link Layer 19


Stop-and-Wait Protocol

Receiver-site algorithm for Stop-and-Wait Protocol

19\08\2011 Unit-II Data Link Layer 20


Stop-and-Wait Protocol

Flow diagram

• The sender sends one frame and waits for feedback from
the receiver.
• When the ACK arrives, the sender sends the next frame.
• Sending two frames in the protocol involves the sender in
four events and the receiver in two events.
19\08\2011 Unit-II Data Link Layer 21
NOISY CHANNELS

The Stop-and-Wait Protocol gives us an idea of how to add


flow control to its predecessor, noiseless channels are
nonexistent.

19\08\2011 Unit-II Data Link Layer 22


Error Detection
Additional bits added by transmitter for error detection code
Parity
• Value of parity bit is such that character has even (even parity) or odd
(odd parity) number of ones
• Even number of bit errors goes undetected
Error Control
Detection and correction of errors
Lost frames
Damaged frames
Automatic repeat request
• Error detection
• Positive acknowledgment
• Retransmission after timeout
• Negative acknowledgement and retransmission

19\08\2011 Unit-II Data Link Layer 23


Stop-and-Wait Automatic Repeat
Request (ARQ) Protocol

19\08\2011 Unit-II Data Link Layer 24


Stop-and-Wait Automatic Repeat Request (ARQ) Protocol
Stop-and-Wait ARQ adds a error control mechanism to Stop-
and-Wait
Error correction is done by keeping a copy of the sent frame
and retransmitting of the frame when the timer expires.
Sequence numbers are used to number the frames.
The sequence numbers are based on modulo-2 arithmetic.
The acknowledgment number always announces in modulo-2
arithmetic the sequence number of the next frame expected.
Sender keeps the copy of the last frame transmitted until it
receives an ACK for that frame.
Data frame uses seq No; an ACK uses an ack No.
Sender has a control variable Sn that holds the sequence No
for the next frame to be sent (0 or 1)
Receiver has a control variable Rn that holds the sequence
number for the next frame to be expected (0 or 1)
19\08\2011 Unit-II Data Link Layer 25
Stop-and-Wait ARQ Protocol
Sequence Numbering.
Protocol specifies that frames need to be numbered and
process is called Sequence Numbering.
The sequence numbers are modulo 2m, where m is the size of
the sequence number field in bits.
Sequence numbers start from 0 to 2m-1 and then repeated.
Protocol need only x and x+1 sequence number (not x+2)
x=0 and x+1=1 i.e., sequence is 0,1,0,1 (Modulo-2 arithmetic)
Acknowledgement Numbering.
Acknowledgement numbers always announce the sequence
number of the next frame expected by the receiver
If frame 0 has arrived safe and sound, receiver sends an ACK
frame with acknowledgement 1 (meaning frame 1 is expected
next)
19\08\2011 Unit-II Data Link Layer 26
Operation of Stop-and-Wait ARQ
1. Normal Operation
2. Frame is lost
3. Acknowledgment is lost
4. Acknowledgment is delayed
Normal Operation

19\08\2011 Unit-II Data Link Layer 27


Operation of Stop-and-Wait ARQ

Frame is lost

19\08\2011 Unit-II Data Link Layer 28


Operation of Stop-and-Wait ARQ
Lost ACK frame
In Stop-and-Wait ARQ, numbering frames prevents the
retaining of duplicate frames.

19\08\2011 Unit-II Data Link Layer 29


Stop-and-Wait ARQ, delayed ACK
The value of R at the receiver site is still 1, which means the
receiver expects to see frame 1.
Numbered acknowledgments are needed if an
acknowledgment is delayed and the next frame is lost.

19\08\2011 Unit-II Data Link Layer 30


Stop-and-Wait ARQ Protocol

3 Events at transmitter and 1 event at receiver


19\08\2011 Unit-II Data Link Layer 31
Stop-and-Wait ARQ Protocol
Sender-site algorithm for Stop-and-Wait ARQ

19\08\2011 Unit-II Data Link Layer 32


Stop-and-Wait ARQ Protocol
Sender-site algorithm for Stop-and-Wait ARQ

19\08\2011 Unit-II Data Link Layer 33


Stop-and-Wait ARQ Protocol
Receiver-site algorithm for Stop-and-Wait ARQ Protocol

19\08\2011 Unit-II Data Link Layer 34


Stop-and-Wait ARQ Protocol
Flow diagram
Frame 0 is sent and
acknowledged.
Frame 1 is lost and
resent after the time-
out.
The resent frame 1 is
acknowledged and the
timer stops.
Frame 0 is sent and
acknowledged, but the
acknowledgment is lost.
The sender has no idea
if the frame or the
acknowledgment is lost,
so after the time-out, it
resends frame 0, which
is acknowledged.
19\08\2011 Unit-II Data Link Layer 35

You might also like