0% found this document useful (0 votes)
4 views149 pages

ch11 Datalink Control-Ks

Chapter 11 discusses Data Link Control, focusing on the design and procedures for communication between adjacent nodes, including framing, flow control, and error control. It details types of framing (fixed-size and variable-size), flow control mechanisms to prevent overwhelming the receiver, and error control methods like Automatic Repeat Request (ARQ). The chapter also introduces various protocols for noiseless and noisy channels, emphasizing the importance of managing data transmission effectively.

Uploaded by

dhangapursaharsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views149 pages

ch11 Datalink Control-Ks

Chapter 11 discusses Data Link Control, focusing on the design and procedures for communication between adjacent nodes, including framing, flow control, and error control. It details types of framing (fixed-size and variable-size), flow control mechanisms to prevent overwhelming the receiver, and error control methods like Automatic Repeat Request (ARQ). The chapter also introduces various protocols for noiseless and noisy channels, emphasizing the importance of managing data transmission effectively.

Uploaded by

dhangapursaharsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 149

Chapter 11

Data Link Control

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

 Data link control: Deals with design & procedures for


communication between two adjacent nodes: node-to-node
communication

 Second function is media access control, or how to share link

 Data link control includes


i) FRAMING
ii) FLOW CONTROL
iii) ERROR CONTROL &
iv) Software implemented protocols that provide smooth &
reliable transmission of frames between nodes

K . Sujatha, ECE, BMSCE 2


11-1 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; the envelope
serves as the delimiter.
Topics discussed in this section:
Fixed-Size Framing
Variable-Size Framing

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

 When a message is carried in one very large frame, even


a single-bit error would require the retransmission of
whole message. When a message is divided into smaller
frames, a single-bit error affects only that small frame

 Fixed Size Framing


 Variable Size Framing
KS BMSCE 4
FRAMING- types
 (i)Fixed-size framing: no need for defining boundaries
of frames; size itself can be used as a delimiter

 Eg : ATM wide-area network, which uses frames of fixed size


called cells

 (ii)Variable-size framing (LAN): need a way to define


end of frame & beginning of next

 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

 Header, which normally carries source & destination


addresses & other control information & trailer, which
carries error detection or error correction redundant bits, are
also multiples of 8 bits

 To separate one frame from next, an 8-bit (1-byte) flag is


added at the beginning & end of a frame

 Flag, composed of protocol-dependent special characters,


signals start or end of frame
KS BMSCE 6
Figure 11.1 A frame in a character-oriented protocol

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

 To fix this problem, a byte-stuffing strategy was added


to character-oriented framing
KS BMSCE 8
Byte stuffing (or character stuffing)
 Byte stuffing (or character stuffing): special byte is added to data
section of frame when there is a character with same pattern as
flag
 Data section is stuffed with an extra byte called escape character
(ESC), which has a predefined bit pattern. Whenever receiver
encounters ESC character, it removes it from data section &
treats next character as data, not a delimiting flag
 What happens if text contains escape characters followed by a
flag?
 Receiver removes escape character, but keeps flag, which is
incorrectly interpreted as end of frame
 To solve this ,escape characters that are part of the text must also
be marked by another escape character
 In other words, if escape character is part of text, an extra one is
added to show that second one is part of text
KS BMSCE 9
Figure 11.2 Byte stuffing and unstuffing

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

 Character-oriented protocols present another problem in


data communications

 Universal coding systems in use today, such as Unicode,


have 16-bit & 32-bit characters that conflict with 8-bit
characters

 Tendency is moving toward bit-oriented protocols

11.11
KS BMSCE
Note

Byte stuffing is the process of adding 1


extra byte whenever there is a flag or
escape character in the text.

11.12
Bit-Oriented Protocols

 Bit-oriented protocol : data section of frame is a


sequence of bits to be interpreted by upper layer as text,
graphic, audio, video & so on

 In addition to headers (& possible trailers), we still need


a delimiter to separate one frame from other

 Most protocols use a special 8-bit pattern flag 01111110


as the delimiter to define beginning & end of frame

KS BMSCE 13
Figure 11.3 A frame in a bit-oriented protocol

11.14
Bit-Oriented Protocols

 Same type of problem encountered as in byte-oriented protocols


 If flag pattern appears in data - need to inform receiver that this
is not end of frame

 Stuffing 1 single bit (instead of 1 byte) to prevent pattern from


looking like a flag - bit stuffing
 In bit stuffing, if a 0 & five consecutive 1 bits are encountered, an
extra 0 is added

 Extra stuffed bit is eventually removed from data by receiver


 Note that the extra bit is added after one 0 followed by five 1s
regardless of value of next bit - guarantees that flag field
sequence does not inadvertently appear in the frame

KS BMSCE 15
Note

Bit stuffing is the process of adding one


extra 0 if 011111 is encountered in data,
so that the receiver does not mistake
the pattern 0111110 for a flag.

11.16
Figure 11.4 Bit stuffing and unstuffing

11.17
11-2 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.

Topics discussed in this section:


Flow Control
Error Control

11.18
Flow Control
 Flow control coordinates the amount of data that can be
sent before receiving an acknowledgment

 Flow control is a set of procedures that tells sender how


much data it can transmit before it must wait for an
acknowledgment from receiver

 Flow of data must not be allowed to overwhelm receiver

 Any receiving device has a limited speed at which it can


process incoming data & limited amount of memory in
which to store incoming data
KS BMSCE 19
Flow Control
 Receiving device must be able to inform sending device before
those limits are reached & to request transmitting device to send
fewer frames or stop temporarily

 Incoming data must be checked & processed before they can be


used
 Rate of such processing is often slower than rate of transmission

 Each receiving device has a block of memory, called a buffer,


reserved for storing incoming data until they are processed

 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

 It allows receiver to inform sender of any frames lost or


damaged in transmission & coordinates retransmission
of those frames by sender

 In data link layer, error control refers to methods of


error detection & retransmission

 Error control in data link layer is often implemented


simply: Any time an error is detected in an exchange,
specified frames are retransmitted -Automatic Repeat
Request (ARQ) KS BMSCE 21
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.

Aka: Don’t overwhelm the receiver!

11.22
Note

Error control in the data link layer is


based on automatic repeat request,
which is the retransmission of data.

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

 Two types of Protocol:


Protocols that can be used for noiseless (error-free)
channels and those that can be used for noisy (error-
creating) channels

 Protocols in first category cannot be used in real life, but


they serve as a basis for understanding protocols of noisy
channels

KS BMSCE 25
Protocols
 Unidirectional -data frames travel from one node, called
sender, to another node, called receiver

 Special frames acknowledgment(ACK)& negative


acknowledgment (NAK) can flow in the opposite direction for
flow & error control purposes, data flow in only one direction

 In a real-life network, data link protocols are implemented as


bidirectional; data flow in both directions

 In these protocols the flow & error control information such


as ACKs & NAKs is included in data frames in a technique
called piggybacking
KS BMSCE 26
Figure 11.5 Taxonomy of protocols discussed in this chapter

11.27
11-4 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.

Topics discussed in this section:


Simplest Protocol
Stop-and-Wait Protocol

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

 Data link layer of receiver immediately removes header from


frame & hands data packet to its network layer, which can
also accept packet immediately
 Receiver can never be overwhelmed with incoming frames
 No need for flow control in this scheme
 Data link layer at the sender site gets data from its network
layer, makes a frame out of data & sends it
29
Figure 11.6 The design of the simplest protocol with no flow or error control

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

 Receiver will not have enough storage space if it is receiving data


from many sources- result in discarding of frames or denial of
service

 To prevent receiver from becoming overwhelmed with frames-tell


sender to slow down - feedback from receiver to sender

 Stop-and-Wait Protocol : sender sends one frame, stops until it


receives confirmation from receiver & then sends next frame -
unidirectional communication for data frames, but auxiliary ACK
frames travel from other direction
KS BMSCE 35
Figure 11.8 Design of Stop-and-Wait Protocol

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

 In other words, after a frame is sent, the algorithm must


ignore another network layer request until that frame is
acknowledged

 Two arrival events cannot happen one after another because


channel is error-free & does not duplicate frames

 ACK is received, canSend is set to true to allow sending of


next frame
KS BMSCE 38
Noiseless channel: (2)Stop-and-Wait Protocol
 Requests from network layer may happen one after another
without an arrival event in between

 We need to prevent immediate sending of data frame

 Although there are several methods, we have used a simple


canSend variable that can either be true or false. When a
frame is sent, the variable is set to false to indicate that a new
network request cannot be sent until canSend is true

 When an ACK is received, canSend is set to true to allow


sending of next frame

KS BMSCE 39
Algorithm 11.4 Receiver-site algorithm for Stop-and-Wait Protocol

11.40
Noiseless channel: (2)Stop-and-Wait Protocol

Analysis:

 Very similar to previous Algorithm with one exception

 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

 Flow diagram shows an eg of communication using this


protocol

 Sender sends one frame & waits for feedback from


receiver

 When the ACK arrives, sender sends the next frame

 Note that sending two frames in the protocol involves


the sender in four events and the receiver in two events

KS BMSCE 43
11-5 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.

We discuss three protocols in this section that use


error control.
Topics discussed in this section:
Stop-and-Wait Automatic Repeat Request (ARQ)
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request

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

 Detection of errors is manifested by silence of receiver


 Lost frames more difficult to handle than corrupted ones
 Solution is to number frames
 Sender keeps a copy of sent frame - Same time, it starts a
timer- If timer expires & there is no ACK for sent frame,
frame is resent, copy is held & the timer is restarted

KS BMSCE 45
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request

 Since an ACK frame can also be corrupted & lost, it too


needs redundancy bits & a sequence number

 ACK frame for this protocol has a sequence number


field

 In this protocol, sender simply discards a corrupted ACK


frame or ignores an out-of-order one

46
Noisy channel: (1) Stop-and-Wait ARQ Overview

 Sender waits “reasonable” amount of time for ACK


 Thus Sender needs a countdown timer
 Start the timer when a packet is sent
 retransmits if no ACK received within the timeout period

 if pkt (or ACK) just delayed (not lost):


 retransmission will create duplicate packet

 Thus it requires packet sequence number & ack number to be

used
 Only two numbers are used: 0, 1

 Receiver’s Ack number is what is expected next


 After receiving Pkt 0, sends back ACK 1
 After receiving Pkt 1, sends back ACK 0

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

Rn is the sequence number of


the next packet expected
11.51
Figure 11.11 Flow diagram for Example 11.3

11.52
Noisy channel: (1) Stop-and-Wait Automatic Repeat Request

 Figure 11.11 shows an example of Stop-and-Wait ARQ

 Frame a is sent & acknowledged


 Frame 1 is lost & resent after time-out
 Resent frame 1 is acknowledged & timer stops
 Frame a is sent & acknowledged, but acknowledgment
is lost
 Sender has no idea if frame or acknowledgment is lost,
so after time-out, it resends frame 0, which is
acknowledged

53
Note

In Stop-and-Wait ARQ, the


acknowledgment number always
announces in modulo-2 arithmetic the
sequence number of the next frame
expected.

11.54
Stop-and-wait operation

sender receiver

first packet bit


transmitted, t = 0
first packet bit arrives
RTT last packet bit arrives, send
ACK

ACK arrives, send next


packet, t = RTT + L / R

L: packet bit length


R: link bandwidth (bps)

Utilization = L/R / (RTT+L/R)


11.55
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. If the system data frames are 1000 bits
in length, what is the utilization percentage of the link?

Solution

L = 1000 bits, R = 1Mbps, RTT = 20ms


Bandwidth-delay product =(1x106)x (20x10-3) = 20,000 bits
Utilization = 1000/ 20000 = 5%

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

first packet bit transmitted, t = 0


last bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send ACK
nd
last bit of 2 packet arrives, send ACK
rd
last bit of 3 packet arrives, send ACK
ACK arrives, send next
packet, t = RTT + L / R

Increase utilization
by a factor of 3!

Utilization = 3*L/R / (RTT+L/R)


3-
KS BMSCE
57
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

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

 Several frames can be sent before receiving


acknowledgments - copy of frames retained until
acknowledgments arrive
 Frames from sending station are numbered sequentially
 Need to set a limit - If header of frame allows m bits for
sequence number, sequence numbers range from 0 to m2 – 1
 we can repeat sequence Eg m=4 sequence numbers are 0,
1,2,3,4,5,6, 7,8,9, 10, 11, 12, 13, 14, 15,0,
1,2,3,4,5,6,7,8,9,10, 11. .
 In other words, sequence numbers are modulo - 2m

KS BMSCE
61
Noisy channel: (2) Go-Back-N ARQ - Sliding Window

 Sliding window : an abstract concept that defines range


of sequence numbers
 Sender & receiver need to deal with only part of possible
sequence numbers- range which is concern of sender :
send sliding window; receiver: receive sliding window

 Send window is an imaginary box covering sequence


numbers of data frames which can be in transit
 Window position: some of these sequence numbers
define frames that have been sent; others define those
that can be sent
 Maximum size of window is 2m - 1
62
Figure 11.12 Send window for Go-Back-N ARQ

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

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.

out-of-order pkt:
discard (don’t buffer) -> no receiver buffering!
Re-ACK pkt with highest in-order seq #

11.68
Note

Stop-and-Wait ARQ is a special case of


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

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)

If (Sf ==Sn ) // the window is empty


StopTimer();
Else
{ StartTimer();

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

Cumulative acknowledgments can help if acknowledgments are delayed or lost


11.76
Figure 11.17 Flow diagram for Example 11.7
Typo in Textbook!

StopTimer

StartTimer

11.77
Example 11.7

Figure 11.17 shows what happens when a frame is lost. Frames 0,


1, 2, and 3 are sent. However, frame 1 is lost. The receiver receives
frames 2 and 3, but they are discarded because they are received
out of order. The sender receives no acknowledgment about frames
1, 2, or 3. Its timer finally expires. The sender sends all outstanding
frames (1, 2, and 3) because it does not know what is wrong. Note
that the resending of frames 1, 2, and 3 is the response to one
single event. When the sender is responding to this event, it cannot
accept the triggering of other events. This means that when ACK 2
arrives, the sender is still busy with sending frame 3.

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

Better protocol: selective repeat ARQ

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)

 Solution: Receiver individually acknowledges all correctly


received pkts
 buffers pkts, as needed, for eventual in-order delivery to upper layer

 sender only resends pkts for which ACK not received


 sender keeps timer for each unACKed pkt

 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

 Noisy link - frame has a higher probability of damage,-


resend multiple frames -uses up bandwidth & slows down
transmission

 Only damaged frame is resent - Selective Repeat ARQ

 It is more efficient for noisy links, but processing at receiver


is more complex
11.82
Noisy channel: (3) Selective Repeat ARQ - window
 Selective Repeat Protocol uses two windows: send &
receive window

 Send window size is 2m-1 - receive window same size

 Eg, if m = 4, sequence numbers go from 0 to 15, but the


size of window is just 8 (it is 15 in the Go-Back-N
Protocol)

 Smaller window size means less efficiency in filling pipe,


but the fact that there are fewer duplicate frames can
compensate for this
11.83
Noisy channel: (3) Selective Repeat ARQ - window
 Handling of the request event is similar to that of the
previous protocol except that one timer is started for
each frame sent

 Arrival event is more complicated here


 An ACK or a NAK frame may arrive- If a valid NAK
frame arrives, we just resend the corresponding frame
 If a valid ACK arrives, we use a loop to purge the
buffers, stop the corresponding timer & move the left
wall of the window

 Time-out event is simpler here; only the frame which


times out is resent.\
11.84
Figure 11.20 Design of Selective Repeat ARQ

11.85
Figure 11.18 Send window for Selective Repeat ARQ

Figure 11.19 Receive 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

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

Topics discussed in this section:


Configurations and Transfer Modes
Frames
Control Field

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)

(1) Normal Response Mode:


 Station configuration is unbalanced - one primary station &

multiple secondary stations- primary station can send


commands; a secondary station can only respond - used for
both point-to-point & multiple-point links

(2) Asynchronous Balanced Mode:


 Configuration is balanced - Link is point-to-point & each

station can function as a primary & a secondary (acting as


peers- Common mode today
11.98
Figure 11.25 Normal response mode

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)

 I-frames : used to transport user data & control information


relating to user data (piggybacking)

 S-frames : used only to transport control information

 U-frames : reserved for system management-Information


carried by U-frames is intended for managing link itself

11.101
Frame Format

 Each frame in HDLC may contain up to six fields

 a beginning flag field, an address field, a control field,


an information field, a frame check sequence (FCS) field
& an ending flag field

 In multiple-frame transmissions, ending flag of one


frame can serve as beginning flag of next frame

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

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.

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

11.114
Figure 11.30 Example of piggybacking without error

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

11.116
Figure 11.31 Example of piggybacking with error

11.117
11-7 POINT-TO-POINT PROTOCOL

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.

Topics discussed in this section:


Framing
Transition Phases
Multiplexing
Multilink PPP

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:

1. PPP does not provide flow control

2. Has a very simple mechanism for error control-


A CRC field is used to detect errors- If frame is
corrupted, it is silently discarded; upper-layer protocol
needs to take care of problem

3. Does not provide a sophisticated addressing


mechanism to handle frames in a multipoint
configuration
11.120
Figure 11.32 PPP frame format

PPP is a byte-oriented protocol

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

PPP is a byte-oriented protocol using


byte stuffing with the escape byte
01111101.

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

Authenticate: phase is optional- two nodes may decide not to skip


this phase- However, if they decide to proceed with authentication,
they send several authentication packets-If result is successful,
connection goes to networking phase else termination phase

11.125
Figure 11.33 Transition phases

Network: negotiation for network layer protocols takes place- PPP


specifies that two nodes establish a network layer agreement before
data at network layer can be exchanged- reason is that PPP supports
multiple protocols at network layer- If a node is running multiple
protocols simultaneously at network layer, receiving node needs to
know which protocol will receive data

Open: data transfer takes place- connection remains in this phase


until one of endpoints wants to terminate connection

Terminate: connection is terminated- Several packets are exchanged


between two ends for house cleaning & closing link

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

Link Control Protocol (LCP) is responsible for establishing, maintaining,


configuring & terminating links
also provides negotiation mechanisms to set options between two endpoints-
Both endpoints of link must reach an agreement about options before link can
be established
All LCP packets are carried in payload field of PPP frame with protocol field
set to C021 in hexadecimal - code field defines type of LCP packet

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

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.

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

17. A sender sends a series of packets to the same


destination using 5-bit sequence numbers. If the
sequence number starts with 0, what is the sequence
number after sending 100 packets?

A five-bit sequence number can create sequence


numbers from 0 to 31. The sequence number in the
Nth packet is (N mod 32). This means that the 101th
packet has the sequence number (101 mod 32) or 5.

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.

Transmission time for 1 window = 7000 bits / 1,000,000 bits = 7 ms


Data frame trip time = 5000 km / 200,000 km = 25 ms
ACK transmission time = 0 (It is usually negligible)
ACK trip time = 5000 km / 200,000 km = 25 ms
Delay for 1 window = 7 + 25 + 25 = 57 ms.
Total delay = 143 × 57 ms = 8.151 s

11.149

You might also like