ch11 Datalink Control-Ks
ch11 Datalink Control-Ks
K.Sujatha
Associate Professor
Dept of ECE , BMSCE
11.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
DATA LINK CONTROL FUNCTION
11.3
FRAMING
Framing in data link layer separates a message from one
source to destination, or from other messages to other
destinations, by adding a sender address & a destination
address
Two approaches
(a) character-oriented approach
(b) bit-oriented approach
KS BMSCE 5
(ii)Variable size framing: (a)Character-Oriented Protocols
In a character-oriented protocol, data to be carried are 8-bit
characters from a coding system such as ASCII
11.7
(ii)Variable size framing:(a)Character-Oriented Protocols
Character-oriented framing was popular when only text
was exchanged by data link layers - flag could be
selected to be any character not used for text
communication
Now : graphs, audio & video- Any pattern used for flag
could also be part of information
If this happens , receiver, when it encounters this pattern
in middle of data, thinks it has reached end of the frame
11.10
Byte stuffing (or character stuffing)
Byte stuffing is the process of adding 1 extra byte
whenever there is a flag or escape character in text
11.11
KS BMSCE
Note
11.12
Bit-Oriented Protocols
KS BMSCE 13
Figure 11.3 A frame in a bit-oriented protocol
11.14
Bit-Oriented Protocols
KS BMSCE 15
Note
11.16
Figure 11.4 Bit stuffing and unstuffing
11.17
11-2 FLOW AND ERROR CONTROL
11.18
Flow Control
Flow control coordinates the amount of data that can be
sent before receiving an acknowledgment
If the buffer begins to fill up, receiver must be able to tell sender
to halt transmission until it is once again able to receive
KS BMSCE 20
Error Control
Error control is both error detection & error correction
11.22
Note
11.23
11-3 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.
11.24
Protocols
Data link layer combines framing, flow control & error
control to achieve delivery of data from one node to
another using protocols that are normally implemented in
software by using one of common programming languages
KS BMSCE 25
Protocols
Unidirectional -data frames travel from one node, called
sender, to another node, called receiver
11.27
11-4 NOISELESS CHANNELS
11.28
NOISELESS CHANNELS -(I) Simplest Protocol
(I) Simplest Protocol: Unidirectional protocol in which data
frames are travelling in only one direction
Assume receiver can immediately handle any frame it
receives with a processing time that is small enough to be
negligible
11.30
Noiseless channel: (I) Simplest Protocol:
Sender site cannot send a frame until its network layer has
a data packet to send
Receiver site cannot deliver a data packet to its network
layer until a frame arrives
If protocol is implemented as a procedure, we need to
introduce the idea of events in protocol
Procedure at sender site is constantly running; there is no
action until there is a request from network layer
Procedure at receiver site is also constantly running, but
there is no action until notification from physical layer
arrives
Both procedures are constantly running because they do
not know when corresponding events will occur
31
Algorithm 11.1 Sender-site algorithm for the simplest protocol
11.32
Algorithm 11.2 Receiver-site algorithm for the simplest protocol
11.33
Figure 11.7 Flow diagram for Example 11.1
11.34
Noiseless channel: (2)Stop-and-Wait Protocol
If data frames arrive at receiver site faster than they can be
processed, frames must be stored until their use
11.36
Algorithm 11.3 Sender-site algorithm for Stop-and-Wait Protocol
11.37
Noiseless channel: (2) Stop-and-Wait Protocol
Two events can occur: request from network layer or an
arrival notification from physical layer- responses to these
events must alternate
KS BMSCE 39
Algorithm 11.4 Receiver-site algorithm for Stop-and-Wait Protocol
11.40
Noiseless channel: (2)Stop-and-Wait Protocol
Analysis:
After the data frame arrives, the receiver sends an ACK frame
to acknowledge the receipt & allow the sender to send the next
frame
KS BMSCE 41
Figure 11.9 Flow diagram for Example 11.2
11.42
Noiseless channel: (2)Stop-and-Wait Protocol
KS BMSCE 43
11-5 NOISY CHANNELS
11.44
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request
Stop-and-Wait ARQ, adds a simple error control
mechanism to Stop-and-Wait Protocol
When frame arrives at receiver site, it is checked & if it is
corrupted, it is silently discarded
KS BMSCE 45
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request
46
Noisy channel: (1) Stop-and-Wait ARQ Overview
used
Only two numbers are used: 0, 1
KS BMSCE
3-47
Figure 11.10 Design of the Stop-and-Wait ARQ Protocol
11.48
Algorithm 11.5 Sender-site algorithm for Stop-and-Wait ARQ
Modulo-2 addition
11.49 (continued)
Algorithm 11.5 Sender-site algorithm for Stop-and-Wait ARQ
(continued)
11.50
Algorithm 11.6 Receiver-site algorithm for Stop-and-Wait ARQ Protocol
Modulo-2 addition
11.52
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request
53
Note
11.54
Stop-and-wait operation
sender receiver
Solution
For this reason, for a link with a high bandwidth or long delay, the use of Stop-
and-Wait ARQ wastes the capacity of the link.
11.56
Pipelining: increased utilization
sender receiver
Increase utilization
by a factor of 3!
Solution
11.58
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request
Example 11.4
Assume that, 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. 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
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 only 1000/20,000, or 5 percent. For this reason, for a
link with a high bandwidth or long delay, the use of Stop-and-Wait
ARQ wastes the capacity of the link.
59
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request
Example 11.5
What is the utilization percentage of the link in Example 11.4 if
we have a protocol that can send up to 15 frames before
stopping and worrying about the acknowledgments?
Solution
The bandwidth-delay product is still 20,000 bits. The system
can send up to 15 frames or 15,000 bits during a round trip.
This means the utilization is 15,000/20,000, or 75 percent.
Of course, if there are damaged frames, the utilization
percentage is much less because frames have to be resent.
60
Noisy channel: (2) Go-Back-N Automatic Repeat Request
KS BMSCE
61
Noisy channel: (2) Go-Back-N ARQ - Sliding Window
11.63
Noisy channel: (2) Go-Back-N ARQ - Send Window
Window at any time divides sequence numbers into four regions
First region, from far left to left wall of window, defines sequence
numbers belonging to frames that are already acknowledged
Sender does not worry about these frames & keeps no copies of
them
Second region, colored in Figure 11.12a, defines range of
sequence numbers belonging to frames that are sent & have an
unknown status- sender needs to wait to find out if these frames
have been received or were lost- outstanding frames
Third range, white in figure, defines range of sequence numbers
for frames that can be sent; however, corresponding data packets
have not yet been received from network layer
Fourth region defines sequence numbers that cannot be used until
window slides
KS BMSCE 64
Note
The send window is an abstract concept defining an
imaginary box of size 2m − 1 with three variables:
Sf, Sn, and Ssize.
The send window can slide one
or more slots when a valid acknowledgment arrives.
Cumulative ACK
rACK(n): ACKs all pkts up to and include seq # n-1 have been
received may receive duplicate ACKs (see receiver)
rA single timer for the oldest transmitted but un-acked pkt
rtimeout: retransmit all pkts in window (up to N packets)
11.65
Figure 11.13 Receive window for Go-Back-N ARQ
Receive window makes sure that correct data frames are received & that
correct acknowledgments are sent - size of receive window is always 1
11.66
Noisy channel: (2) Go-Back-N ARQ - Receive Window
Receive window makes sure that correct data frames are received & that
correct acknowledgments are sent - size of receive window is always 1
Receiver is always looking for arrival of a specific frame- Any frame
arriving out of order is discarded & needs to be resent
Need only one variable Rn (receive window, next frame expected)
Sequence numbers to left of window belong to frames already received
& acknowledged; sequence numbers to right of this window define
frames that cannot be received
Any received frame with a sequence number in these two regions is
discarded
Frame with a sequence no. matching value of Rn is accepted &
acknowledged
Receive window also slides, but only one slot at a time
When a correct frame is received (and a frame is received only one at a
time), window slides
67
Note
out-of-order pkt:
discard (don’t buffer) -> no receiver buffering!
Re-ACK pkt with highest in-order seq #
11.68
Note
11.69
Figure 11.14 Design of Go-Back-N ARQ
11.70
Noisy channel: (2) Go-Back-N ARQ - send Window size
Why the size of send window must be less than 2m – 1 ?
As an example, we choose m =2, which means the size of window
can be 2m - 1, or 3
Figure 11.15 compares window size of 3 against window size of 4
If size of window is 3 (less than 22) & all three acknowledgments
are lost, frame timer expires & all three frames are resent- receiver
is now expecting frame 3, not frame 0, so duplicate frame is
correctly discarded
On other hand, if size of window is 4 (equal to 22) & all
acknowledgments are lost, sender will send a duplicate of frame 0
However, this time the window of receiver expects to receive
frame 0, so it accepts frame 0, not as a duplicate, but as the first
frame in the next cycle. This is an error.
71
Noisy channel: (2) Go-Back-N ARQ - send Window size
72
Algorithm 11.7 Go-Back-N sender algorithm
(continued)
11.73
Algorithm 11.7 Go-Back-N sender algorithm (continued)
Typo in Textbook!
11.74
Algorithm 11.8 Go-Back-N receiver algorithm
11.75
Figure 11.16 Flow diagram for Example 11.6
Typo in Textbook!
StopTimer
StartTimer
StopTimer
StartTimer
11.77
Example 11.7
11.78
Example 11.7 (continued)
The physical layer must wait until this event is completed and the
data link layer goes back to its sleeping state. We have shown a
vertical line to indicate the delay. It is the same story with ACK 3;
but when ACK 3 arrives, the sender is busy responding to ACK 2. It
happens again when ACK 4 arrives. Note that before the second
timer expires, all outstanding frames have been sent and the timer
is stopped.
11.79
Example 11.17 shows that because of one packet lost, all following
packets will need to be retransmitted, even if they have arrived at
the destination A great waste of bandwidth
11.80
Noisy channel: (3) Selective Repeat ARQ
Problem with Go-back-N:
Sender: resend many packets with a single lose
Receiver: discard many good received (out-of-order) packets
Very inefficient when N becomes bigger (in high-speed network)
sender window
N consecutive seq #’s
again limits seq #s of sent, unACKed pkts
11.81
Noisy channel: (3) Selective Repeat ARQ
Go-Back-N ARQ simplifies process at receiver site - receiver
keeps track of only one variable & there is no need to buffer
out-of-order frames; they are simply discarded - this protocol
is very inefficient for noisy link
11.85
Figure 11.18 Send window for Selective Repeat ARQ
11.86
Algorithm 11.9 Sender-site Selective Repeat algorithm
(continued)
11.87
Algorithm 11.9 Sender-site Selective Repeat algorithm (continued)
11.88 (continued)
Algorithm 11.9 Sender-site Selective Repeat algorithm (continued)
11.89
Algorithm 11.10 Receiver-site Selective Repeat algorithm
11.90
Algorithm 11.10 Receiver-site Selective Repeat algorithm
11.91
11.92
Figure 11.23 Flow diagram for Example 11.8
11.93
Piggybacking
Three protocols-> unidirectional: data frames flow in only one
direction-control information such as ACK & NAK frames can
travel in other direction
In real life, data frames normally flow in both directions- control
information also needs to flow in both directions
Piggybacking is used to improve efficiency of bidirectional
protocols
When a frame is carrying data from A to B, it can also carry
control information about arrived (or lost) frames from B; when a
frame is carrying data from B to A, it can also carry control
information about the arrived (or lost) frames from A.
11.94
Design of piggybacking in Go-Back-N ARQ
Each node now has two windows: send window & receive
window
Both need to use a timer & are involved in three types of
events: request, arrival & time-out
Arrival event is complicated - handle control information as
well as frame - Both concerns must be taken care of in one
event
Request event uses only send window at each site; arrival
event needs to use both windows
Both sites must use the same algorithm
Algorithm is complicated because it needs to combine two
arrival events into one
11.95
Figure 11.24 Design of piggybacking in Go-Back-N ARQ
11.96
11-6 HDLC
11.97
Configurations and Transfer Modes
HDLC provides two common transfer modes that can be used in
different configurations: normal response mode (NRM) &
asynchronous balanced mode (ABM)
11.99
Figure 11.26 Asynchronous balanced mode
11.100
Frames
To provide flexibility necessary to support all options
possible in modes & configurations, HDLC defines three
types of frames: information frames (I-frames), supervisory
frames (S-frames), & unnumbered frames (U-frames)
11.101
Frame Format
11.102
Figure 11.27 HDLC frames
11.103
Fields
Fields & their use in different frame types
(1) Flag field : 8-bit sequence with bit pattern 01111110 that identifies both
beginning & end of a frame - serves as synchronization pattern for receiver
(2) Address field: address of secondary station- If primary station created frame-
> contains to address- If secondary creates frame-> contains from address-can be 1
byte or several bytes long, depending on needs of network
One byte can identify up to 128 stations (l bit used for another purpose)
Larger networks require multiple-byte address fields
If address field is only 1 byte, last bit is always a 1- If address is more than 1 byte,
all bytes but last one will end with 0; only last will end with 1- Ending each
intermediate byte with 0 indicates to receiver that there are more address bytes to
come
11.104
Fields
(3) Control field: Control field is a 1- or 2-byte segment of frame
used for flow & error control
(4) Information field: Information field contains user's data
from network layer or management information- length can vary
from one network to another
(5) FCS field: Frame check sequence (FCS) is the HDLC error
detection field - can contain either a 2- or 4-byte
11.105
Control Field - I-Frames
o I-frames are designed to carry user data from network layer
o Can include flow & error control information (piggybacking)
o First bit defines type- If first bit of control field is 0 -> frame is an I-frame
o Next 3 bits, called N(S), define sequence number of frame- can define sequence number
between 0 & 7
o Last 3 bits, called N(R), correspond to acknowledgment number when piggybacking is used
o Single bit between N(S) & N(R) is called P/F bit
o The P/F field is a single bit with a dual purpose
o Has meaning only when it is set (bit = 1) & can mean poll or final
o poll when frame is sent by a primary station to a secondary (when address field contains
address of receiver)
o final when frame is sent by a secondary to primary (when address field contains address
of sender)
11.106
Control Field- S-Frames
o Supervisory frames are used for flow & error control whenever piggybacking is either
impossible or inappropriate
o S-frames do not have information fields
o If first 2 bits of control field is 10 -> frame is an S-frame
o Last 3 bits, called N(R), corresponds to acknowledgment number (ACK) or negative
acknowledgment number (NAK) depending on type of S-frame
o 2 bits called code is used to define type of S-frame itself-> 4 types of S-frame
Control Field- S-Frames
o 2 bits called code is used to define type of S-frame itself-> 4 types of S-frame
o (1) Receive ready R(R): 00 -> RR S-frame - acknowledges receipt of safe & sound frame
or group of frames- value N(R) field defines acknowledgment number
o (2) Receive not ready (RNR): 10->RNR S-frame- RR frame with additional functions-
acknowledges receipt of a frame or group of frames & announces that receiver is busy &
cannot receive more frames- acts as kind of congestion control mechanism by asking sender
to slow down- value of N(R) is acknowledgment number
o (3) Reject (REJ): 01-> REJ S-frame- NAK frame that can be used in Go-Back-N ARQ to
improve the efficiency of process by informing sender, before sender time expires, that last
frame is lost or damaged- value of N(R) is the negative acknowledgment number
o (4) Selective reject (SREJ): 11-> SREJ S-frame-NAK frame used in Selective Repeat ARQ-
HDLC Protocol uses the term selective reject instead of selective repeat- value of N(R) is
negative acknowledgment number
Control Field- U Frames
Unnumbered frames are used to exchange session management & control information
between connected devices
Unlike S-frames, U-frames contain an information field, but one used for system
management information, not user data
As with S-frames, however, much of information carried by U-frames is contained in
codes included in control field
U-frame codes are divided into two sections: a 2-bit prefix before the P/F bit and a 3-bit
suffix after the P/F bit
Together, these two segments (5 bits) can be used to create up to 32 different types of U-
frames
11.109
Figure 11.28 Control field format for the different frame types
11.110
Table 11.1 U-frame control command and response
11.111
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).
11.112
Example 11.10
11.113
Example 11.10 (continued)
11.114
Figure 11.30 Example of piggybacking without error
11.115
Example 11.11
11.116
Figure 11.31 Example of piggybacking with error
11.117
11-7 POINT-TO-POINT PROTOCOL
11.118
PPP provides several services:
1. PPP defines format of frame to be exchanged
between devices
2. Defines how two devices can negotiate
establishment of link & exchange of data
3.How network layer data are encapsulated in data
link frame
4. Two devices can authenticate each other
5. Provides multiple network layer services supporting
a variety of network layer protocols
6. Provides connections over multiple links
7. Provides network address configuration-
particularly useful when a home user needs a
temporary network address to connect to Internet
11.119
To keep PPP simple- several services are missing:
11.121
PPP Frame Format
Flag: 1-byte flag with bit pattern 01111110- PPP is byte-oriented -
flag is treated as a byte
Address: constant value & set to 11111111 (broadcast address)-
During negotiation , two parties may agree to omit this byte
Control: constant value 11000000 (imitating unnumbered frames in
HDLC)- PPP does not provide any flow control -Error control is also
limited to error detection -this field is not needed at all & again, two
parties can agree, during negotiation, to omit this byte
Protocol: defines what is being carried in data field: either user data or
other information.- by default 2 bytes long, but two parties can agree to
use only I byte
Payload field -user data or other information - data field is a sequence
of bytes with default of a maximum of 1500 bytes; but this can be
changed during negotiation- is byte stuffed if flag byte pattern appears
in this field- Because there is no field defining the size of the data field,
padding is needed if the size is less than maximum -default value or
maximum negotiated value
FCS: frame check sequence (FCS) ( is simply a 2-byte or 4-byte)
11.122
Note
11.123
Figure 11.33 Transition phases
A PPP connection goes through phases which can be shown in a
transition phase diagram
11.124
Figure 11.33 Transition phases
A PPP connection goes through phases
Dead: link is not being used- no active carrier (at physical layer) &
line is quiet
Establish: When one node starts commn, connection goes into this
phase- options are negotiated between two parties-If negotiation is
successful, system goes to authentication phase (if required) or
directly to networking phase-link control protocol packets are used
for this purpose- Several packets may be exchanged here
11.125
Figure 11.33 Transition phases
11.126
Figure 11.34 Multiplexing in PPP
Although PPP is a data link layer protocol, PPP uses another set of other protocols to
establish link, authenticate parties involved & carry network layer data -3 sets of protocols
are defined to make PPP powerful: Link Control Protocol (LCP), two Authentication
Protocols (APs) & several Network Control Protocols (NCPs)
11.127
Figure 11.35 LCP packet encapsulated in a frame
11.128
Table 11.2 LCP packets
11.129
Table 11.3 Common options
11.130
Figure 11.36 PAP packets encapsulated in a PPP frame
11.131
Figure 11.37 CHAP packets encapsulated in a PPP frame
11.132
Figure 11.38 IPCP packet encapsulated in PPP frame
11.133
Table 11.4 Code value for IPCP packets
11.134
Figure 11.39 IP datagram encapsulated in a PPP frame
11.135
Figure 11.40 Multilink PPP
11.136
Example 11.12
11.137
Example 11.12 (continued)
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.
11.138
Figure 11.41 An example
11.139
Figure 11.41 An example (continued)
11.140
Exercise Problems
11.141
Exercise Problems
11.142
Exercise Problems
11.143
Exercise Problems
19. Design a bidirectional algorithm for the Simplest Protocol using
piggybacking. Note that the both parties need to use the same algorithm.
11.144
Exercise Problems
27. The timer of a system using the Stop-and-Wait ARQ
Protocol has a timeout of 6ms. Draw the flow
diagram for four frames if the round trip delay is 4ms.
Assume no data frame or control frame is lost or
damaged.
Since there are no lost or damaged frames and the round
trip time is less than the time-out, each frame is sent
only once.
11.145
Exercise Problems
27. Since there are no lost or damaged frames and the round trip
time is less than the time-out, each frame is sent only once.
11.146
28. Repeat Ex 27 if the time-out is 4 ms and the round trip delay is 6.
11.147
29. Repeat Exercise 27 if the first frame (frame 0) is lost.
In this case, only the first frame is resent; the acknowledgment for
other frames arrived on time.
11.148
Exercise Problems
31.A system uses the Go-back-N ARQ Protocol with window size of 7. If each
packet carries 1000 bits of data, how long does it take to send 1 million bits of
data if the distance between the sender and receiver is 5000 km and the
propagation speed is 2 x 108 m? Ignore transmission, waiting, and processing
delays. We assume no data or control frame is lost or damaged. Ignore the
overhead due to the header and trailer.
11.149