Layer 2 Data Link Layer
-
Upload
linda-pratt -
Category
Documents
-
view
121 -
download
2
description
Transcript of Layer 2 Data Link Layer
1 19\08\2011 Unit-II Data Link Layer
Layer 2
Data Link Layer
Is responsible for • Framing• Addressing• Flow and Error Control• Media access control
2 19\08\2011 Unit-II Data Link Layer
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 ControlHigh-level Data Link Control )
Unit 2: DATA LINK CONTROL
Overview
3 19\08\2011 Unit-II Data Link Layer
Data Link Layer
4 19\08\2011 Unit-II 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.
Data Link Layer
5 19\08\2011 Unit-II Data Link Layer
FRAMINGFRAMING
The data link layer needs to pack bits into The data link layer needs to pack bits into frames,frames, so that each frame so that each frame is distinguishable from another. Our postal system practices a type of is distinguishable from another. Our postal system practices a type of framing. The simple act of inserting a letter into an envelope framing. The simple act of inserting a letter into an envelope separates one piece of information from another; the envelope serves separates one piece of information from another; the envelope serves as the delimiter. 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
6 19\08\2011 Unit-II Data Link Layer
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
FRAMINGFRAMING
7 19\08\2011 Unit-II Data Link Layer
A frame in a character-oriented protocol
FRAMINGFRAMING
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.
8 19\08\2011 Unit-II Data Link Layer
Byte stuffing and unstuffingByte 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)
9 19\08\2011 Unit-II Data Link Layer
DLE STX ETX DLETransparent Data
DLE STX ETX DLEA B DLE H W
DLE STX ETX DLEA B DLE H WDLE
DLE STX ETX DLEA B DLE H W
Stuffed
Unstuffed
Before
Byte stuffing and unstuffingByte stuffing and unstuffing
DLE-Data link Escape, STX-Start of Text, ETX- End of Text
10 19\08\2011 Unit-II Data Link Layer
A frame in a bit-oriented protocol
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.
11 19\08\2011 Unit-II Data Link Layer
Bit stuffing and unstuffing
12 19\08\2011 Unit-II Data Link Layer
Flow ControlFlow Control
• Flow control refers to a set of procedures used to restrict the Flow control refers to a set of procedures used to restrict the amount of data that the sender can send before waiting for amount of data that the sender can send before waiting for acknowledgment.acknowledgment.
• Flow control is the regulation of the sender’s data rate so Flow control is the regulation of the sender’s data rate so that the receiver buffer does not become overwhelmed.that the receiver buffer does not become overwhelmed.
Error ControlError Control
Error control is both error detection and error correction.Error control is both error detection and error correction.
Error control in the data link layer is based on automatic Error control in the data link layer is based on automatic repeat request, which is the retransmission of data.repeat request, which is the retransmission of data.
Flow & Error Control
13 19\08\2011 Unit-II Data Link Layer
Protocols
NOISELESS CHANNELSNOISELESS CHANNELS
In these protocols it is assumed as an ideal channel in In these protocols it is assumed as an ideal channel in which no frames are lost, duplicated, or corrupted. which no frames are lost, duplicated, or corrupted.
14 19\08\2011 Unit-II Data Link Layer
The design of the simplest protocol with no flow or error control
Simplest Protocol
1 Event at transmitter and 1 event at receiver
15 19\08\2011 Unit-II Data Link Layer
Sender-site algorithm for the simplest protocol
Receiver-site algorithm for the simplest protocol
Simplest Protocol
16 19\08\2011 Unit-II Data Link Layer
Flow diagram
Simplest Protocol
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.
17 19\08\2011 Unit-II Data Link Layer
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 frameWait for ACKIf 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
Stop-and-Wait Protocol
18 19\08\2011 Unit-II Data Link Layer
Design of Stop-and-Wait Protocol
Stop-and-Wait Protocol
2 Events at transmitter and 1 event at receiver
19 19\08\2011 Unit-II Data Link Layer
Sender-site algorithm for Stop-and-Wait Protocol
Stop-and-Wait Protocol
20 19\08\2011 Unit-II Data Link Layer
Receiver-site algorithm for Stop-and-Wait Protocol
Stop-and-Wait Protocol
21 19\08\2011 Unit-II Data Link Layer
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.
Stop-and-Wait Protocol
22 19\08\2011 Unit-II Data Link Layer
NOISY CHANNELSNOISY CHANNELS
The Stop-and-Wait Protocol gives us an idea of how to add The Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor, flow control to its predecessor, noiseless channels noiseless channels are are nonexistent. nonexistent.
23 19\08\2011 Unit-II Data Link Layer
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
24 19\08\2011 Unit-II Data Link Layer
Stop-and-Wait Automatic Repeat Request (ARQ) Protocol
25 19\08\2011 Unit-II Data Link Layer
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)
26 19\08\2011 Unit-II Data Link Layer
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)
27 19\08\2011 Unit-II Data Link Layer
1. Normal Operation
2. Frame is lost
3. Acknowledgment is lost
4. Acknowledgment is delayed
Operation of Stop-and-Wait ARQ
Normal Operation
28 19\08\2011 Unit-II Data Link Layer
Frame is lost
Operation of Stop-and-Wait ARQ
29 19\08\2011 Unit-II Data Link Layer
Lost ACK frame
In Stop-and-Wait ARQ, numbering frames prevents the retaining of duplicate frames.
Operation of Stop-and-Wait ARQ
30 19\08\2011 Unit-II Data Link Layer
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.
Stop-and-Wait ARQ, delayed ACK
31 19\08\2011 Unit-II Data Link Layer
Stop-and-Wait ARQ Protocol
3 Events at transmitter and 1 event at receiver
32 19\08\2011 Unit-II Data Link Layer
Sender-site algorithm for Stop-and-Wait ARQ
Stop-and-Wait ARQ Protocol
33 19\08\2011 Unit-II Data Link Layer
Stop-and-Wait ARQ Protocol
Sender-site algorithm for Stop-and-Wait ARQ
34 19\08\2011 Unit-II Data Link Layer
Receiver-site algorithm for Stop-and-Wait ARQ Protocol
Stop-and-Wait ARQ Protocol
35 19\08\2011 Unit-II Data Link Layer
Flow diagram
Stop-and-Wait ARQ Protocol
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.