You are on page 1of 30

03/12/31

Chapter 11

Data Link Control


and
Protocols

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 1

11--11
11 11.
1 .FRAMING
1 Flow
FLOW ANDand Error
ERROR Control
CONTROL

The most important responsibilities of the data link


layer are flow control and error control.
Collectively, these functions are known as
as::

data link control.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 2

1
03/12/31

data link control.


 Data must be checked and processed before they can be
used.
 The rate of such processing is often slower than the rate of
transmission.
 For this reason , each receiver has a buffer to store
incoming data until they are processed.
 If buffer begin to fill up, the sender must slow or halt
transmission.
Note
Flow control refers to a set of procedures
used to restrict the amount of data
that the sender can send before
waiting for acknowledgment.
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 3

data link control.

Error control: is both error detection and correction. Error


correction in data link layer is implemented simply: anytime an
error is detected in exchange, specified frames are retransmitted.
This process is called Automatic Repeat Request

Note
Error control in the data link layer is
based on automatic repeat request, which
is the retransmission of data.
Section 11.4 is excluded

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 4

2
03/12/31

PROTOCOLS
Now let us see how the data link layer can combine flow control, and
error control to achieve the delivery of data from one node to another
another..
The protocols are normally implemented in software by using one of the
common programming languages.

Stop-and-Wait ARQ

protocols Go-Back-N ARQ

Selective Repeat ARQ

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 5

1. Stop-
Stop-and
and--Wait ARQ
It is the simplest flow and error control mechanism. A transmitter
sends a frame then stops and waits for an acknowledgment.
Stop--and
Stop and--Wait ARQ has the following features:
 The sending device keeps a copy of the sent frame transmitted until
it receives an acknowledgment( ACK)

 The sender starts a timer when it sends a frame. If an ACK is not


received within an allocated time period, the sender resends it

 Both frames and acknowledgment (ACK) are numbered alternately 0


and 1( two sequence number only)

 This numbering allows for identification of frames in case of


duplicate transmission
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 6

3
03/12/31

1. Stop-
Stop-and
and--Wait ARQ
 The acknowledgment number defines the number of next expected
frame. (frame 0 received ACK 1 is sent)

 A damage or lost frame treated by the same manner by the receiver

 If the receiver detects an error in the received frame, or receives a


frame out of order it simply discards the frame

 The receiver send only positive ACK for frames received safe; it is
silent about the frames damage or lost.

 The sender has a control variable S that holds the number of most
recently sent frame (0 or 1). The receiver has control variable R, that
holds the number of the next frame expected (0,or 1)
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 7

Design of the Stop-and-Wait ARQ Protocol

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 8

4
03/12/31

Stop-and-Wait ARQ

Cases of Operations:

1. Normal operation

2. The frame is lost

3. The Acknowledgment (ACK) is lost

4. The Ack is delayed

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 9

Stop-and-Wait ARQ
1. Normal operation

 The sender will not send the


next frame until it is sure that
the current one is correctly
receive

 sequence number is necessary


to check for duplicated frames

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 10

5
03/12/31

Stop-and-Wait ARQ
2. Lost or damaged frame

A damage or lost frame


treated by the same manner
by the receiver

 No NACK when frame


is corrupted / duplicate

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 11

Stop-and-Wait ARQ

3. Lost ACK frame


Importance of frame
numbering

Dr. Gihan Naguib Behrouz A. Forouzan “Data communication and Networking”


12

6
03/12/31

In Stop-
Stop-and
and--Wait ARQ, numbering
frames prevents the retaining of
duplicate frames.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 13

Stop-and-Wait ARQ,

4. Delayed ACK and lost frame


 Importance of
ACK numbering

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 14

7
03/12/31

Numbered acknowledgments are


needed if an acknowledgment is
delayed and the next frame is lost.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 15

Piggybacking ( Bidirectional transmission)


 Is a method to combine a data frame with an acknowledgment.

 It can save bandwidth because data frame and an ACK frame


can combined into just one frame

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 16

8
03/12/31

Stop-and-Wait ARQ,

 After each frame sent the host must wait for


an ACK
 inefficient use of bandwidth

 To improve efficiency ACK should be sent


after multiple frames

 Alternatives: Sliding Window protocol


 Go-back-N ARQ
 Selective Repeat ARQ

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 17

Pipelining

 Pipelining: A task is begun before the previous


task has ended
 There is no pipelining in stop and wait ARQ
because we need to wait for a frame to reach the
destination and be acknowledged before the next
frame can be sent
 Pipelining improves the efficiency of the
transmission

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 18

9
03/12/31

Sliding window protocols


 Sliding window protocols apply Pipelining :
 Go-Back-N ARQ
 Selective Repeat ARQ
 Sliding window protocols improve the efficiency
 multiple frames should be in transition while waiting for
ACK. Let more than one frame to be outstanding.
 Outstanding frames: frames sent but not acknowledged
 We can send up to W frames and keep a copy of these
frames(outstanding) until the ACKs arrive.
This procedures requires additional feature to be added :
sliding window
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 19

Sequence Numbers
 Sent frames are numbered sequentially
 Sequence number is stored in the header of the frame

 If the header of the frame allow m bits for the sequence


number, the sequence numbers range from 0 to (2m -1).
 If m = 3, sequence number range from 0 to 7( 8 numbers):
0, 1, 2 , 3, 4, 5, 6, 7, 0 , 1 ,…..
The sequence numbers are modulo 2m,where m is the
size of the sequence number field in bits.
Sliding window
used to hold the unacknowledged outstanding frames (frames
sent but not acknowledged)
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 20

10
03/12/31

2. Go-
Go-Back
Back--N ARQ
Sender sliding window
 The sender window is an abstract concept defining an
imaginary box of size 2m − 1 ( sequence numbers – 1)
The sender window can slide one or more slots when a valid
acknowledgment arrives. Sequence
number

If m = 3; sequence numbers = 8
and window size =7

Acknowledged
frames
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 21

Receiver sliding window

 The receive window is an abstract concept defining an


imaginary box of size 1 with one single variable Rn.
 The window slides when a correct frame has arrived;
sliding occurs one slot at a time.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 22

11
03/12/31

Control variables
Outstanding frames: frames
sent but not acknowledged

 S: hold the sequence number of the recently sent frame


 SF: holds sequence number of the first frame in the window
 SL: holds the sequence number of the last frame
 R : sequence number of the frame expected to received

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 23

2. Go-
Go-Back
Back--N ARQ

m=4

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 24

12
03/12/31

2. Go-
Go-Back
Back--N ARQ
 In Go-Back-N ARQ we use one timer for the first outstanding frame
 The receiver sends a positive ACK if a frame has arrived safe and in
order.
 if a frame is damaged or out of order ,the receiver is silent and will
discard all subsequent frames
 When the timer of an unacknowledged frame at the sender site is
expired , the sender goes back and resend all frames , beginning with
the one with expired timer.( that is why the protocol is called Go-Back-
N ARQ)
The receiver doesn't have to acknowledge each frame received . It can
send cumulative Ack for several frame
Example:
The sender has sent frame 6 , and timer expires for frame 3( frame
3 has not been acknowledge); the sender goes back and resends
frames 3, 4,5 and 6
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 25

Go-Back-N ARQ
Normal operation
m= 2

 How many frames


can be transmitted
Without acknowledgment?

 ACK1 is not
necessary if ACK2
is sent: Cumulative ACK

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 26

13
03/12/31

Go-Back-N ARQ
Damage or Lost Frame

 Correctly received
out of order packets are not
Buffered

 What is the disadvantage of


this?

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 27

Go-Back-N ARQ: sender window size

= 2m -1
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 28

14
03/12/31

Notes::
Notes

In Go-
Go-Back
Back--N ARQ, the size of the sender
window must be less than 2m = (2m-1) ; the
size of the receiver window is always 1.
Bidirectional transmission : piggybacking
As Stop-and-Wait we can use piggybacking
to improve the efficiency of bidirectional
transmission . Each direction needs both a
sender window and a receiver window.
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 29

Note::
Note

Stop-and-Wait ARQ is a special case of


Go-Back-N ARQ in which the size of the
send window is 1.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 30

15
03/12/31

Design of piggybacking in Go-Back-N ARQ

To improve the efficiency of the bidirectional protocols

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 31

3. Selective Repeat ARQ


 Go-Back-N ARQ is inefficient of a noisy link.
 In a noisy link frames have higher probability of damage , which
means the resending of multiple frames.
 this resending consumes the bandwidth and slow down the
transmission.
Solution:
 Selective Repeat ARQ protocol : resent only the damage frame
 It defines a negative Acknolgment (NAK) that report the
sequence number of a damaged frame before the timer expires
 It is more efficient for noisy link, but the processing at the
receiver is more complex
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 32

16
03/12/31

Selective Repeat ARQ, sender and receiver windows

 The window size is reduced to one half of 2m


 Sender window size = receiver window size = 2m/2
 Window size = sequence number/2
 If m = 2, Window size = 4/2=2
 Sequence number = 0, 1, 2 , 3

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 33

m=3
Selective Repeat ARQ Example Sequences no=2m =8 : 0,1,2
,3,4,5,6,7
Lost frame Window size =2m/2= 8/2=4

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 34

17
03/12/31

Example (continued)
At the receiver site we need to distinguish between the
acceptance of a frame and its delivery to the network
layer. At the second arrival, frame 2 arrives and is
stored and marked, but it cannot be delivered because
frame 1 is missing. At the next arrival, frame 3 arrives
and is marked and stored, but still none of the frames
can be delivered. Only at the last arrival, when finally a
copy of frame 1 arrives, can frames 1, 2, and 3 be
delivered to the network layer. There are two conditions
for the delivery of frames to the network layer: First, a
set of consecutive frames must have arrived. Second,
the set starts from the beginning of the window.
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 35

Example (continued)

The next point is about the ACKs. Notice that only two
ACKs are sent here. The first one acknowledges only the
first frame; the second one acknowledges three frames.
In Selective Repeat, ACKs are sent when data are
delivered to the network layer. If the data belonging to n
frames are delivered in one shot, only one ACK is sent for
all of them.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 36

18
03/12/31

Note::
Note

In Selective Repeat ARQ, the size of


the sender and receiver window must
be at most one
one--half of 2m.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 37

Selective Repeat ARQ, sender window size


m=2

Window size =2m/2 Window size > 2m/2

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 38

19
03/12/31

Bandwidth Delay Product: BDP

 BDP Measures the efficiency of an ARQ systems

 Is a measure of the number of bits we can send out of


our system while waiting for news (ACK)from the
receiver. It defines the number of bits that can fill the
link.

 BDP (bits) = bandwidth X round trip delay (sec)

 Round trip delay= 2 x propagation time


Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 39

Example 1
In a Stop-and-Wait ARQ system, the bandwidth of the line is 1 Mbps,
and 1 bit takes 20 ms to make a round trip(RTT). What is the
bandwidth-delay product? If the system data frames are 1000 bits in
length, what is the utilization percentage of the link?
Solution
The bandwidth-delay product is

1  106  20  10-3 = 20,000 bits


The system can send 20,000 bits during the time it takes for the data to go
from the sender to the receiver and then back again. However, the system
sends only 1000 bits. We can say that the link utilization is
Link utilization %= (1000/20,000)x 100 = 5%.
For this reason, for a link with high bandwidth or long delay , use of
Stop-and-Wait ARQ wastes the capacity of the link.
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 40

20
03/12/31

Example 2
What is the utilization percentage of the link in
Example 1 if the link uses Go-Back-N ARQ with a 15-
frame sequence?

Solution
The bandwidth-delay product is still 20,000. The system can
send up to 15 frames or 15,000 bits during a round trip. This
means :
Utilization%= (15 x 1000/20,000) x100= 75%.
Of course, if there are damaged frames, the utilization
percentage is much less because frames have to be resent.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 41

Example 3
What is the utilization percentage of the link in Example
2 if the link uses Selective repeat ARQ?

Solution

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 42

21
03/12/31

High-level Data Link Control protocol: HDLC


One of the more popular data link control protocols.
It implements the ARQ mechanisms
HDLC Station Types:
 Primary station
Controls operation of link
Frames issued are called commands
 Secondary station
Under control of primary station
Frames issued called responses
 Combined station
May issue commands and responses
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 43

HDLC Link Configurations and transfer modes

1. Normal Response Mode (NRM)


Unbalanced configuration:
Primary initiates transfer to secondary
Secondary may only transmit data in response to command from
primary

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 44

22
03/12/31

HDLC Link Configurations and transfer modes


ABM ( Asynchronous Balance Mode)

2. Asynchronous Balanced Mode (ABM)


 Balanced configuration:
Either station may initiate transmission without
receiving permission
 In ABM the link is point-to-point

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 45

HDLC frame types


1. I-Frame: Information frames
2. S- Frame: Supervisory frames
3. U-Frame: Unnumbered frames

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 46

23
03/12/31

HDLC frame

Flag: 8-bit ; 01111110 that identifies the beginning and end of the
frame
FCS: frame check sequence is error detection field
Address: contain the address of the secondary station . It can be one
byte or more . If the address is more than one bytes , all bytes end with
zero except the last byte ends with one. Ending each intermediate byte
with 0 indicates to the receiver.
Control Field : determine the type of frame and defines its
functionality.
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 47

Control field format for the different frame types

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 48

24
03/12/31

I-frame

Information: contains the user’s information.


Control field:
 The first bit (0) defines the frame type (I-Frame)
 N(s): defines the sequence number of the frame.
 N(R) : Acknowledgment number when piggybacking is used.
 P/F: set to 1 with dual purpose:
Poll: frame sent by the primary station (the address field contains the address of
the receiver).
Final: frame sent by secondary station (the address field contain the address of
the sender).
Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 49

S-frame control field in HDLC

Frame type ACK or NACK


number
The Code field define four types of S-frames:
1. Receiver ready (RR): receiver ready to accept more I-frames
2. Receiver not ready (RNR): receiver not ready to accept more I
frames
3. Reject (REJ): This is NAK Frame that can be used in Go-Back-N to
improve the efficiency .

4. Selective Reject (SREJ): NAK frame used in Selective repeat


Behrouz A. Forouzan “Data communication and Networking”
Dr. Gihan Naguib 50

25
03/12/31

U-frame control field in HDLC

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 51

Example of piggybacking without error

The following figure 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.
Dr. Gihan Naguib Behrouz A. Forouzan “Data communication and Networking”
52

26
03/12/31

Example of piggybacking without error(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.

Dr. Gihan Naguib Behrouz A. Forouzan “Data communication and Networking”


53

Example of piggybacking without error

GO- back-NARQ

Dr. Gihan Naguib Behrouz A. Forouzan “Data communication and Networking”


54

27
03/12/31

Example of piggybacking with error

The following figure 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.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 55

Example of piggybacking with error

Go- Back-N using


REJ S-Frame

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 56

28
03/12/31

Data transparency

Bit stuffing is the process of adding


one extra 0 whenever there are five
consecutive 1s in the data so that the
receiver does not mistake the
data for a flag.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 57

Bit stuffing and removal

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 58

29
03/12/31

Bit unstuffing in HDLC

< 15< >= 15

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 59

Reading from the text book

 Chapter 11 from 4th edition (section


11.2,11.3, 11.5, and 11.6
 Cover only those contents which are
related to topics covered in class.

Behrouz A. Forouzan “Data communication and Networking”


Dr. Gihan Naguib 60

30

You might also like