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

Unit 3

Uploaded by

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

Unit 3

Uploaded by

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

Unit -3

Data Link Layer
Presentation Prepaired by: Prof. Atul G. Pawar, 
 PCCOE, Pune.
Data link layer

Note

The data link layer is responsible for moving


l
frames from one hop (node) to the next.
Fig. Hop-to-hop delivery
Data Link Layer

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

­ Error­control 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
Flow­control 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.

• 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

• When a message is divided into smaller frames, a single-bit


error affects only that small frame.
Framing Continue....

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

• The most important responsibilities of the data link layer


are flow control and error control.

• Collectively, these functions are known as data link


control.
Flow 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

Data can be corrupted during transmission.

Some applications require that errors be


detected and corrected.
INTRODUCTION

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

In a single-bit error, only 1 bit in the data unit


has changed.
Figure Single-bit error
Note

A burst error means that 2 or more bits in


the data unit have changed.
Figure 10.2 Burst error of length 8
Note

To detect or correct errors, we need to send


extra (redundant) bits with data.
Figure 10.3 The structure of encoder and decoder
Figure 10.4 XORing of two single bits or two words
BLOCK CODING

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

An error-detecting code can detect


only the types of errors for which it is
designed; other types of errors may remain
undetected.
Table 10.2 A code for error correction (Example 10.3)
Note

The Hamming distance between two words


is the number of differences between
corresponding bits.
Example 10.4
Let us find the Hamming distance between two pairs
of words.

1. The Hamming distance d(000, 011) is 2 because

2. The Hamming distance d(10101, 11110) is 3


because
Note

The minimum Hamming distance is the


smallest Hamming distance between
all possible pairs in a set of words.
Example 10.5

Find the minimum Hamming distance of the coding


scheme in Table 10.1.
Solution
We first find all Hamming distances.

The dmin in this case is 2.


Example 10.6

Find the minimum Hamming distance of the coding


scheme in Table 10.2.
Solution
We first find all the Hamming distances.

The dmin in this case is 3.


10-3 LINEAR BLOCK CODES

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

In a linear block code, the exclusive OR


(XOR) of any two valid codewords creates
another valid codeword.
Example 10.10

Let us see if the two codes we defined in Table 10.1


and Table 10.2 belong to the class of linear block
codes.

1. The scheme in Table 10.1 is a linear block code


because the result of XORing any codeword with
any other codeword is a valid codeword. For
example, the XORing of the second and third
codewords creates the fourth one.

2. The scheme in Table 10.2 is also a linear block


code. We can create all four codewords by XORing
two other codewords.
Example 10.11

In our first code (Table 10.1), the numbers of 1s in the


nonzero codewords are 2, 2, and 2. So the minimum
Hamming distance is dmin = 2. In our second code
(Table 10.2), the numbers of 1s in the nonzero
codewords are 3, 3, and 4. So in this code we have
dmin = 3.
Parity-Check Code :

The most familiar error-detecting code is the simple parity-


check code.
In this code, a k-bit dataword is changed to an n-bit
codeword where n = k + 1. The extra bit, called the parity bit,
is selected to make the total number of Is in the codeword
even.

A simple parity-check code is a


single-bit error-detecting
code in which
n = k + 1 with dmin = 2.
Table 10.3 Simple parity-check code C(5, 4)
Figure 10.10 Encoder and decoder for simple parity-check code
Example 10.12
Let us look at some transmission scenarios. Assume
the sender sends the dataword 1011. The codeword
created from this dataword is 10111, which is sent to
the receiver. We examine five cases:

1. No error occurs; the received codeword is 10111.


The syndrome is 0. The dataword 1011 is created.
2. One single-bit error changes a1 . The received
codeword is 10011. The syndrome is 1. No
dataword is created.
3. One single-bit error changes r0 . The received
codeword is 10110. The syndrome is 1. No dataword
is created.
Example 10.12 (continued)

4. An error changes r0 and a second error changes


a3 . The received codeword is 00110. The syndrome
is 0. The dataword 0011 is created at the receiver.
Note that here the dataword is wrongly created due
to the syndrome value.
5. Three bits—a3, a2, and a1—are changed by errors.
The received codeword is 01011. The syndrome
is 1. The dataword is not created. This shows that
the simple parity check, guaranteed to detect one
single error, can also find any odd number of errors.
Note

A simple parity-check code can detect an


odd number of errors.
Figure 10.11 Two-dimensional parity-check code
Figure 10.11 Two-dimensional parity-check code
Figure 10.11 Two-dimensional parity-check code
Hamming Codes :

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

The checker in the decoder creates a 3-bit syndrome (s2s1s0) in


which each bit is the parity check for 4 out of the 7 bits in the
received codeword:

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

Let us trace the path of three datawords from the sender


to the destination:
1. The dataword 0100 becomes the codeword 0100011.
The codeword 0100011 is received. The syndrome is
000, the final dataword is 0100.
2. The dataword 0111 becomes the codeword 0111001.
The 0011001 codeword is received. The syndrome is 011.
After flipping b2 (changing the 1 to 0), the final dataword
is 0111.
3. The dataword 1101 becomes the codeword 1101000.
The syndrome is 101. The codeword 0001000 is
received. After flipping b0, we get 0000,the wrong
dataword. This shows that our code cannot correct two
errors.
Example 10.14
We need a dataword of at least 7 bits. Calculate
values of k and n that satisfy this requirement.
Solution
We need to make k = n − m greater than or equal to 7, or 2m −
1 − m ≥ 7.
1. If we set m = 3, the result is n = 23 − 1 and k = 7 − 3,
or 4, which is not acceptable.
2. If we set m = 4, then n = 24 − 1 = 15 and k = 15 − 4 =
11, which satisfies the condition. So the code is

C(15, 11)
Figure 10.13 Burst error correction using Hamming code
10-4 CYCLIC CODES

Cyclic codes are special linear block codes with one


extra property. In a cyclic code, if a codeword is
cyclically shifted (rotated), the result is another
codeword.

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

In this section, we simply discuss a category


of cyclic codes called the cyclic redundancy check
(CRC) that is used in networks such as LANs and
WANs.
Table 10.6 A CRC code with C(7, 4)
Figure 10.14 CRC encoder and decoder
Figure 10.15 Division in CRC encoder
Figure 10.16 Division in the CRC decoder for two cases
• PROTOCOLS

• 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.

• The protocols are normally implemented in software by


using one of the common programming languages.
• Figure: Flow Control Protocols

(Unrestricted Simplex)
• NOISELESS CHANNELS

• Let us first assume we have an ideal channel in which no


frames are lost, duplicated, or corrupted. We introduce two
protocols for this type of channel.

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

• Next figure shows an example of communication using this


protocol.

• It is still very simple.

• 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

• Although the Stop-and-Wait Protocol gives us an idea of how


to add flow control to its predecessor,noiseless channels are
nonexistent.

• Three protocols in this section that use error control


• are as follows.


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

Nest figure shows an example of Stop-and-Wait ARQ.


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.
Flow diagram Stop-and-Wait Automatic Repeat Request
2. Go-Back-N Automatic Repeat Request

• Note

In the Go-Back-N Protocol, the sequence


numbers are modulo 2m,
l
where m is the size of the sequence number
field in bits.

• 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

The send window can slide one


l
or more slots when a valid acknowledgment arrives.

• 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

• Send window for Selective Repeat ARQ


• Receive window for Selective Repeat ARQ
Design of Selective Repeat ARQ
Selective Repeat ARQ, window size
Note

In Selective Repeat ARQ, the size of the


sender and receiver window
must be at most one-half of 2 m.
Flow diagram for Selective Repeat
HDLC

High-level Data Link Control (HDLC) is a bit-oriented


protocol for communication over point-to-point and
multipoint links. It implements the ARQ mechanisms
we discussed in this chapter.

Configurations and Transfer Modes:


HDLC provides two common transfer modes that can be used in
different configurations:
1. Normal response mode (NRM)
2. Asynchronous balanced mode (ABM).
Figure 11.25 Normal response mode
Figure 11.26 Asynchronous balanced mode
Frames
HDLC defines three types of frames:
1. Information frames (I-frames),
2. Supervisory frames (S-frames), and
3. Unnumbered frames (U-frames).
Each type of frame serves as an envelope for the transmission of a
different type of message.
I-frames are used to transport user data and control information relating
to user data (piggybacking).
S-frames are used only to transport control information.
U-frames are reserved for system management. Information carried by
U-frames is intended for managing the link itself.
Figure 11.27 HDLC frames
Flag field: 8-bit sequence with the bit pattern 01111110.
Address field: Address of the secondary station. If a primary station
created the frame, it contains a to address. If a secondary creates
the frame, it contains a from address.
Control field: 1 or 2-byte segment of the frame used for flow and
error control.
Information field: It contains the user's data from the network layer
or management information. Its length can vary from one network to
another.
FCS field: The frame check sequence (FCS) is the HDLC error
detection field. It can contain either a 2- or 4-byte CRC.
Figure 11.28 Control field format for the different frame types

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

Figure 11.30 shows an exchange using


piggybacking. Node A begins the exchange of
information with an
I-frame numbered 0 followed by another I-frame
numbered 1. Node B piggybacks its
acknowledgment of both frames onto an I-frame of
its own. Node B’s first
I-frame is also numbered 0 [N(S) field] and contains a
2 in its N(R) field, acknowledging the receipt of A’s
frames 1 and 0 and indicating that it expects frame 2
to arrive next. Node B transmits its second and third
I-frames (numbered 1 and 2) before accepting further
frames from node A.
Example 11.10 (continued)

Its N(R) information, therefore, has not changed: B


frames 1 and 2 indicate that node B is still
expecting A’s frame 2 to arrive next. Node A has
sent all its data. Therefore, it cannot piggyback an
acknowledgment onto an I-frame and sends an S-
frame instead. The RR code indicates that A is still
ready to receive. The number 3 in the N(R) field
tells B that frames 0, 1, and 2 have all been
accepted and that A is now expecting frame
number 3.
Figure 11.30 Example of piggybacking without error
Example 11.11
Figure 11.31 shows an exchange in which a frame is
lost. Node B sends three data frames (0, 1, and 2), but
frame 1 is lost. When node A receives frame 2, it
discards it and sends a REJ frame for frame 1. Note
that the protocol being used is Go-Back-N with the
special use of an REJ frame as a NAK frame. The
NAK frame does two things here: It confirms the
receipt of frame 0 and declares that frame 1 and any
following frames must be resent. Node B, after
receiving the REJ frame, resends frames 1 and 2.
Node A acknowledges the receipt by sending an RR
frame (ACK) with acknowledgment number 3.
Figure 11.31 Example of piggybacking with error
POINT-TO-POINT PROTOCOL

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

PPP is a byte-oriented protocol using byte


stuffing with the escape byte 01111101.
Figure 11.33 Transition phases
Figure 11.34 Multiplexing in PPP
Figure 11.35 LCP packet encapsulated in a frame
Table 11.2 LCP packets
Table 11.3 Common options
Authentication Protocols

PPP is designed for use over dial-up links where verification of


user identity is necessary.
Authentication means validating the identity of a user who needs to
access a set of resources.
PPP has created two protocols for authentication:
1. Password Authentication Protocol (PAP) and
2. Challenge Handshake Authentication Protocol (CHAP)
Note that these protocols are used during the authentication
phase.
Password Authentication Protocol (PAP):

PAP is a simple authentication procedure with a two-step process:


1. The user who wants to access a system sends an
authentication identification (usually the user name) and a
password.
2. The system checks the validity of the identification and
password and either accepts or denies connection.
Figure 11.36 PAP packets encapsulated in a PPP frame
Figure 11.37 CHAP packets encapsulated in a PPP frame
Figure 11.38 IPCP packet encapsulated in PPP frame
Table 11.4 Code value for IPCP packets
Figure 11.40 Multilink PPP
Example 11.12

Let us go through the phases followed by a network


layer packet as it is transmitted through a PPP
connection. Figure 11.41 shows the steps. For
simplicity, we assume unidirectional movement of data
from the user site to the system site (such as sending
an e-mail through an ISP).

The first two frames show link establishment. We have


chosen two options (not shown in the figure): using
PAP for authentication and suppressing the address
control fields. Frames 3 and 4 are for authentication.
Frames 5 and 6 establish the network layer connection
using IPCP.
Example 11.12 (continued)

The next several frames show that some IP packets are


encapsulated in the PPP frame. The system (receiver)
may have been running several network layer
protocols, but it knows that the incoming data must be
delivered to the IP protocol because the NCP protocol
used before the data transfer was IPCP.

After data transfer, the user then terminates the data


link connection, which is acknowledged by the system.
Of course the user or the system could have chosen to
terminate the network layer IPCP and keep the data link
layer running if it wanted to run another NCP protocol.
Figure 11.41 An example
Figure 11.41 An example (continued)
Several services are missing in PPP:
1. PPP does not provide flow control. A sender can send several
frames one after another with no concern about overwhelming the
receiver.
2. PPP has a very simple mechanism for error control. A CRC field is
used to detect errors. If the frame is corrupted, it is silently discarded;
the upper-layer protocol needs to take care of the problem. Lack of
error control and sequence numbering may cause a packet to be
received out of order.
3. PPP does not provide a sophisticated addressing mechanism to
handle frames in a multipoint configuration.

You might also like