Unit 3
Unit 3
Data Link Layer
Presentation Prepaired by: Prof. Atul G. Pawar,
PCCOE, Pune.
Data link layer
Note
l
1. Logical Link Control (LLC) Layer
l
Error Control
l
Flow Control
l
Framing
l
Link Managment
l
2. MAC Layer
l
Sharing of Medium using diff. Protocols
l
Packet transmission and reception service.
Prof. Atul G. Pawar, PCCOE, Pune.
1. Logical Link Control (LLC)
l
Error Control
Error control is one of its most important tasks.
l
Errorcontrol schemes typically use redundancy,
l
retransmissions, choice of transmit parameters like packet
l
sizes and transmit powers.
l
Increased error rates or increased reliability targets increase
l
the energy consumption.
l
l
Flow Control
Flowcontrol mechanisms introduce some signaling to let the
transmitter slow down transmission.
Link Managment
This mechanism involves discovery, setup, maintenance,
l
and teardown of links to neighbors
l
l
Framing
User data is fragmented and formatted into packets or frames.
l
Prof. Atul G. Pawar, PCCOE, Pune.
Functions of the Data Link Layer
cont..
Services Provided to Network Layer
Placement of DLL
Design Issues of DLL
l
Services provided to Network Layer
l
Unacknowledged connectionless service.
l
Acknowledged connectionless service.
l
Acknowledged connection-oriented service.
l
Framing
l
Error Control
l
Flow Control
• 11.
Unacknowledged connectionless service (Best Effort).
l
The receiver does not return acknowledgments to
the sender, so the sender has no way of knowing if
a frame has been successfully delivered.
l
Losses are taken care of at higher layers
l
Used on reliable medium like coax cables or
optical fiber, where the error rate is low.
l
Appropriate for voice, where delay is worse than
bad data.
• 11.
Acknowledged connectionless service.
l
Useful on unreliable medium like wireless.
l
Acknowledgements add delays.
l
Adding ack in the DLL rather than in the NL is just an
optimization and not a requirement.
l
On reliable channels, like fiber, the overhead associated
with the ack is not justified.
• 11.
Acknowledged connection-oriented service.
l
Most reliable,
l
Guaranteed service –
l Each frame sent is indeed received
l Each frame is received exactly once
l Frames are received in order
l
Special care has to be taken to ensure this in
connectionless services
• 11.
• FRAMING
• The data link layer needs to pack bits into frames, so that
each frame is distinguishable from another.
Fixed-Size Framing:
Frames can be of fixed or variable size.
Variable-Size Framing:
In variable-size framing, we need a way to define
the end of the frame and the beginning of the next.
Two approaches were used for this purpose:
Character-oriented Protocol approach
Bit-oriented Protocol approach.
• Figure A frame in a character-oriented protocol
• Byte stuffing and unstuffing
• Note
l
Byte stuffing is the process of adding 1 extra byte
whenever there is a flag or escape character in the text.
• Figure A frame in a bit-oriented protocol
• Note
l
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
l
the pattern 0111110 for a flag.
• Figure Bit stuffing and unstuffing
• FLOW AND ERROR CONTROL
• Note
l
Flow control refers to a set of procedures used
to restrict the amount of data that the sender
can send before waiting for acknowledgment.
Error Control
• Note
l
Error control in the data link layer is based on
automatic repeat request, which is the
retransmission of data.
Error Detection
and
Correction
l
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Note
l
Let us first discuss some issues related, directly or
indirectly, to error detection and correction.
Types of Errors
Redundancy
Detection Versus Correction
Forward Error Correction Versus Retransmission
Coding
Modular Arithmetic
Note
l
In block coding, we divide our message into
blocks, each of k bits, called datawords. We add r
redundant bits to each block to make the length n
= k + r. The resulting n-bit blocks are called
codewords.
Error Detection
Error Correction
Hamming Distance
Minimum Hamming Distance
Table 10.1 A code for error detection (Example 10.2)
Note
l
Almost all block codes used today belong to a
subset called linear block codes. A linear block
code is a code in which the exclusive OR
(addition modulo-2) of two valid codewords
creates another valid codeword.
Note
l
Now let us discuss a category of error-correcting codes
called Hamming codes.
l
These codes were originally designed with dmin = 3, which
means that they can detect up to two errors (s+1) or
correct one single error(2t+1).
Table 10.4 Hamming code C(7, 4) where m=3, then n=7 & k=4
Figure 10.12 The structure of the encoder and decoder for a Hamming code
A copy of a 4-bit dataword is fed into the generator that creates
three parity checks ro, r1 and r2 as shown below:
r0= a2 + a1 + a0 modulo-2
r1= a3 + a2 + a1 modulo-2
r2= a1 + a0 + a3 modulo-2
s0 = b2 + b1 + b0 + q0 modulo-2
s1 = b3 + b2 + b1 + q1 modulo-2
s2 = b1 + b0 + b3 + q2 modulo-2
Table 10.5 Logical decision made by the correction logic analyzer
Example 10.13
C(15, 11)
Figure 10.13 Burst error correction using Hamming code
10-4 CYCLIC CODES
For example:
if 1011000 is a codeword and we cyclically left-shift, then
0110001 is also a codeword.
In this case, if we call the bits in the first word ao to a6 and the
bits in the second word bo to b6.
CYCLIC REDUNDANCY CHECK
• Now let us see how the data link layer can combine
framing, flow control, and error control to achieve the
delivery of data from one node to another.
(Unrestricted Simplex)
• NOISELESS CHANNELS
Simplest Protocol
Stop-and-Wait Protocol
• Figure The design of the simplest protocol with no flow or error control
• Figure Flow diagram
• Figure Design of Stop-and-Wait Protocol
• Example
• The sender sends one frame and waits for feedback from the
receiver.
• When the ACK arrives, the sender sends the next frame.
• Figure- Flow diagram
• NOISY CHANNELS
Stop-and-Wait Automatic Repeat Request
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request
1. Stop-and-Wait Automatic Repeat Request
• Note
l
Error correction in Stop-and-Wait ARQ is done
by keeping a copy of the sent frame and
retransmitting of the frame when the timer
expires.
• Note
l
In Stop-and-Wait ARQ, we use sequence numbers to
number the frames.
l
The sequence numbers are based on modulo-2
arithmetic.
• Note
l
In Stop-and-Wait ARQ, the acknowledgment number
always announces in modulo-2 arithmetic the
sequence number of the next frame expected.
Figure : Design of the Stop-and-Wait ARQ Protocol
Example
• Note
• 11.
• Figure Send window for Go-Back-N ARQ
• Note
l
The send window is an abstract concept defining an
imaginary box of size 2m − 1 with three variables: Sf,
Sn, and Ssize.
• Note
• 11.
• Figure Receive window for Go-Back-N ARQ
• 11.
• Note
l
The receive window is an abstract concept defining
an imaginary box
l
of size 1 with one single variable R .
n
l
The window slides
l
when a correct frame has arrived; sliding occurs one
slot at a time.
• 11.
• Figure Design of Go-Back-N ARQ
• Figure Window size for Go-Back-N ARQ
• Note
l
In Go-Back-N ARQ, the size of the send window must
be less than 2m;
l
the size of the receiver window
l
is always 1.
• 11.
Flow diagram forGo-Back-N
3. Selective Repeat Automatic Repeat Request
Control Field:
The control field determines the type of frame and defines its
functionality.
Control Field for I-Frames
First bit: defines the type i.e. if control field is 0, this means the frame is
an I-frame.
Next 3 bits: called N(S),define the sequence number of the frame. (0-7)
Last 3 bits: called N(R), correspond to the acknowledgment number
when piggybacking is used.
P/F bit: when it is set (bit = 1), means poll.
It means poll when the frame is sent by a primary station to a secondary
(when the address field contains the address of the receiver).
It means final when the frame is sent by a secondary to a primary
(when the address field contains the address of the sender).
Control Field for S-Frames
Supervisory frames are used for flow and error control whenever
piggybacking is either impossible or inappropriate.
First 2 bits: of the control field is 10, this means the frame is an S-frame.
Last 3 bits: called N(R), corresponds to the acknowledgment number
(ACK) or negative acknowledgment number (NAK) depending on the
type of S-frame.
2 bits : called code is used to define the type of S-frame itself.
With 2 bits, we can have four types of S-frames, as described below:
1. Receive Ready (RR): If code = 00, it is an RR S-frame.
This kind of frame acknowledges the receipt of a safe and sound frame
or group of frames. In this case, the value N(R) field defines the
acknowledgment number.
2. Receive not ready (RNR): If code= 10, it is an RNR S-frame.
It acknowledges the receipt of a frame or group of frames, and it
announces that the receiver is busy and cannot receive more frames,
i.e. congestion control mechanism by asking the sender to slow down.
3. Reject (REJ): If code= 01, it is a REJ S-frame.
This is a NAK frame,that can be used in Go-Back-N ARQ to improve
the efficiency of the process by informing the sender, before the sender
time expires, that the last frame is lost or damaged. N(R) = NAK.
3. Selective reject (SREJ): If code = 11, it is an SREJ S-frame.
This is a NAK frame used in Selective Repeat ARQ. Note that the
HDLC Protocol uses the term selective reject instead of selective
repeat. The value of N(R) = NAK
Table 11.1 U-frame control command and response
Example 11.9
Figure 11.29 shows how U-frames can be used for
connection establishment and connection release.
Node A asks for a connection with a set
asynchronous balanced mode (SABM) frame; node
B gives a positive response with an unnumbered
acknowledgment (UA) frame. After these two
exchanges, data can be transferred between the two
nodes (not shown in the figure). After data transfer,
node A sends a DISC (disconnect) frame to release
the connection; it is confirmed by node B
responding with a UA (unnumbered
acknowledgment).
Figure 11.29 Example of connection and disconnection
Example 11.10
l
Although HDLC is a general protocol that can be
used for both point-to-point and multipoint
configurations, one of the most common protocols
for point-to-point access is the Point-to-Point
Protocol (PPP). PPP is a byte-oriented protocol.
PPP provides several services:
1. PPP defines the format of the frame to be exchanged between devices.
2. PPP defines how two devices can negotiate the establishment of the link and
the exchange of data.
3. PPP defines how network layer data are encapsulated in the data link frame.
4. PPP defines how two devices can authenticate each other.
5. PPP provides multiple network layer services supporting a variety of network
layer protocols.
6. PPP provides connections over multiple links.
7. PPP provides network address configuration. This is particularly useful when a
home user needs a temporary network address to connect to the Internet.
Figure 11.32 PPP frame format
Flag: 1-byte flag with the bit pattern 01111110.
Address: The address field is a constant value and set to 11111111.
Control: This field is set to the constant value 11000000. PPP does
not provide any flow control. Error control is also limited to error
detection. This means that this field is not needed at all.
Protocol: It defines what is being carried in the data field: either user
data or other information. This field is by default 2 bytes long, but the
two parties can agree to use only 1 byte.
Payload field: This field carries either the user data or other
information. Max. of 1500 bytes; but this can be changed during
negotiation. Padding is also use.
FCS: The frame check sequence is a 2 or 4-byte standard CRC.
Note