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

Communication Networks Lecture 09 - Flow Control, Error Control (Read-Only)

The document discusses data link layer protocols including stop-and-wait ARQ and go-back-N ARQ protocols. It describes the functions of data link layer like framing, flow control, and error control. It provides details on the algorithms, working, and advantages/disadvantages of stop-and-wait and go-back-N ARQ protocols.

Uploaded by

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

Communication Networks Lecture 09 - Flow Control, Error Control (Read-Only)

The document discusses data link layer protocols including stop-and-wait ARQ and go-back-N ARQ protocols. It describes the functions of data link layer like framing, flow control, and error control. It provides details on the algorithms, working, and advantages/disadvantages of stop-and-wait and go-back-N ARQ protocols.

Uploaded by

AGILAN I
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Lecture : 09

Communication Networks

Dr. G. Balamurugan
Assistant Professor
Department of Electronics Engineering
MIT Campus, Anna University.

Dr. G. Balamurugan
1
Department of Electronics Engineering, MIT Campus
UNIT II DATA LINK LAYER AND NETWORK
INTERCONNECTION
Logical link control Functions:- Framing, Flow control , Error
control: CRC, LLC protocols:- HDLC, P to P. Medium access
layer:- Random access, Controlled access, Channelization,
IEEE standards:- 802.3, 802.4 and 802.5. Internetworking,
Interconnection issues, Interconnection devices:- Repeaters,
Hubs, Routers/switches and Gateways.

Dr. G. Balamurugan
2
Department of Electronics Engineering, MIT Campus
Data Link Layer (DLL)

Dr. G. Balamurugan
3
Department of Electronics Engineering, MIT Campus
Data Link Layer
LLC layer for LANs is concerned with
Network Layer the transmission of a link level protocol
data unit (PDU) between two stations,
without the necessity of an intermediate
switching node

Logical Link Control sublayer


Datalink Layer
Medium Access sublayer

Medium access (MAC) sub-layer is


primarily used in broadcast or shared
channel networks.
MAC protocols enable two stations (or
Physical Layer
nodes) using a shared communication
resource to establish, maintain and
terminate a connection.
Dr. G. Balamurugan
4
Department of Electronics Engineering, MIT Campus
3. Flow control
 Flow control tells the sender how much data it can transmit before it must
wait for an acknowledgment (ACK) from the receiver.
 Receiver has a limited speed at which it can process incoming data and a
limited amount of memory in which to store incoming data.
 Receiver must inform the sender before the limits are reached and request
that the transmitter to send fewer frames or stop temporarily.
 Since the rate of processing is often slower than the rate of transmission,
receiver has a block of memory (buffer) for storing incoming data until
they are processed.

Dr. G. Balamurugan
5
Department of Electronics Engineering, MIT Campus
4. Error Control
• Error control includes both error detection and error correction.
• Error control allows the receiver to inform the sender of any frames lost
or damaged in transmission. [Automatic repeat request (ARQ)]
• Error control in the data link layer is based on automatic repeat request
(ARQ). Whenever an error is detected, specified frames are
retransmitted.

Dr. G. Balamurugan
6
Department of Electronics Engineering, MIT Campus
Flow control Protocols

Dr. G. Balamurugan
7
Department of Electronics Engineering, MIT Campus
A1. Simplest Protocol
( Noiseless Channel )
1. Simplest protocol has no Flow control and Error control mechanism.
2. It is unidirectional protocol in which data frames are travelling in only
one direction, from the sender to receiver.
3. Simplest protocol assumes that the processing time of the receiver is
small and negligible.
4. The sender sends a sequence of frames without even thinking about the
receiver.

Note: Unlimited buffer


and speed for the
receiver

Dr. G. Balamurugan
8
Department of Electronics Engineering, MIT Campus
Algorithm: Sender-site algorithm for the simplest protocol

Algorithm: Receiver-site algorithm for the simplest protocol

Dr. G. Balamurugan
9
Department of Electronics Engineering, MIT Campus
Flow Diagram : Simplest Protocol

Sender Receiver

Request
Arrival
Request
Request Arrival

Request Arrival
Note: Unlimited buffer and
Request Arrival speed for the receiver
Arrival

Time Time

Dr. G. Balamurugan
10
Department of Electronics Engineering, MIT Campus
A2. Stop and wait Protocol
( Noiseless Channel )

Dr. G. Balamurugan
11
Department of Electronics Engineering, MIT Campus
1. Stop and wait Protocol
( Noiseless Channel )
Algorithm : Sender-site algorithm for Stop-and-Wait Protocol

Dr. G. Balamurugan
12
Department of Electronics Engineering, MIT Campus
1. Stop and wait Protocol
( Noiseless Channel )

Algorithm: Receiver-site algorithm for Stop-and-Wait Protocol

Dr. G. Balamurugan
13
Department of Electronics Engineering, MIT Campus
Flow Diagram : Stop and wait Protocol
Advantage:
Sender Receiver
Simplicity: Each frame is
checked and ACK before the
Request
next frame is sent.
Arrival

Request Disadvantage:
Arrival Inefficiency:
Slow (half duplex link )
Forward channel : Data
Time Time Reverse channel: ACK

Dr. G. Balamurugan
14
Department of Electronics Engineering, MIT Campus
Flow control Protocols
Error control in the data link layer is based on automatic repeat
request (ARQ), done by keeping a copy of the sent frame and
retransmitting of the frame when the timer expires.

Dr. G. Balamurugan
15
Department of Electronics Engineering, MIT Campus
Noisy Channel
• Noiseless channels are nonexistent
• We need to add error control to our protocols.
• Redundancy bits to data frame.
• In our previous protocols, there was no way to identify a
corrupted frame.

Automatic Repeat Request:


• Automatic repeat request (ARQ) is a protocol for error control in
data transmission.
• When the receiver detects an error in a packet, it automatically
requests the transmitter to resend the packet. This process is
repeated until the packet is error free .
Dr. G. Balamurugan
16
Department of Electronics Engineering, MIT Campus
B1. Stop-and-Wait ARQ Protocol
• For retransmission to work, four features added to flow control mechanism
1. Sending device keeps a copy of the last frame transmitted until it receives
an ACK for that frame.
2. For identification purpose, both data and ACK frames are numbered
alternately 0 and 1.
Data0 frame is ACK  by an ACK 1 frame.
number allows for identification of data frames in case of duplicate
transmission.
3. Sender has a control variable (S) that holds the number of the recently
sent frame (0 or 1) Receiver has a control variable (R) that holds the
number of the next frame expected (0 or 1).
4. If an error is discovered in a data frame, indicating that it has been
corrupted
5. Sending device is equipped with a timer. If an expected ACK is not
received within an allotted time, the sender assumes that the last data
frame was lost. Dr. G. Balamurugan
17
Department of Electronics Engineering, MIT Campus
Stop-and-Wait ARQ Protocol

Cases of Operations:

1. Normal operation

2. The frame is lost / damaged

3. The Acknowledgment (ACK) is lost

4. The Ack is delayed

Dr. G. Balamurugan
18
Department of Electronics Engineering, MIT Campus
Case 1: Normal operation
Sender Receiver

S=0
R=0
Deliver
Timeout R=1
S=1
Deliver
R=0
Timeout

Time Time
Control variable
S – holds number of the recently sent frame
R – holds number of the expected frame
Dr. G. Balamurugan
19
Department of Electronics Engineering, MIT Campus
Case 2: Lost or damaged frame
Sender Receiver

S=0 R=0
Deliver

S=1 R=1

Timeout

Deliver
R=0

Time Time
Dr. G. Balamurugan
20
Department of Electronics Engineering, MIT Campus
Case 3: Lost ACK frame
Sender Receiver

S=0 R=0
Deliver

S=1 R=1

Deliver

Timeout R=0
S=1
Frame 0 expected;
discard

R=0
S=0

Time Dr. G. Balamurugan Time


21
Department of Electronics Engineering, MIT Campus
Case 4: Delayed ACK and Lost frame
Sender Receiver

S=0 R=0
Deliver

Timeout R=1
Frame 0 expected;
discard
S=1
R=1
Timeout

Deliver
R=0
S=0
Dr. G. Balamurugan
22
Department of Electronics Engineering, MIT Campus
Stop & Wait ARQ : Algorithm
Algorithm: Receiver-site algorithm for Stop-and-Wait ARQ Protocol

(continued)
Dr. G. Balamurugan
23
Department of Electronics Engineering, MIT Campus
Stop & Wait ARQ : Algorithm
Algorithm: Sender-site algorithm for Stop-and-Wait ARQ (continued)

Dr. G. Balamurugan
24
Department of Electronics Engineering, MIT Campus
Stop & Wait ARQ : Algorithm
Algorithm: Receiver-site algorithm for Stop-and-Wait ARQ Protocol

Dr. G. Balamurugan
25
Department of Electronics Engineering, MIT Campus
Summary : Stop & Wait ARQ
Why data frames need to be numbered?

In Stop-and-Wait ARQ, numbering


frames prevents the retaining of
duplicate frames.

Why ACK frames need to be numbered?

Numbered acknowledgments are needed if an


acknowledgment is delayed and the next frame is lost.

Dr. G. Balamurugan
26
Department of Electronics Engineering, MIT Campus
Disadvantage of Stop-and-Wait ARQ
• After each frame sent, the host must wait for an ACK
 Inefficient use of bandwidth

• Solution to improve efficiency : ACK should be sent after


multiple frames.

• Alternatives: Sliding Window protocol


 Go-back-N ARQ
 Selective Repeat ARQ

Dr. G. Balamurugan
27
Department of Electronics Engineering, MIT Campus
Sliding Window
• In the sliding window method of flow control, Sender can transmit
several frames before waiting for an ACK.
• Number of un-ACKed frames is called the window.
Sender Receiver
Window

 Capacity of the link can be used efficiently.


 Receiver ACK only some of the frames, using a single ACK to confirm
the receipt of multiple data frames.
Dr. G. Balamurugan
 Made famous by TCP Department of Electronics Engineering, MIT Campus
28
Sliding Window
• Sequence numbers
 Sent frames are numbered sequentially
 Sequence number is stored in the header
if the number of bits to store the sequence number is m then
sequence number goes from 0 to 2^m - 1.
For example m = 3, sequence numbers are: 0,1, 2, 3, 4, 5, 6, 7.
We can repeat the sequence number.
Sequence numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5,
6, 7, 0, 1, …

Dr. G. Balamurugan
29
Department of Electronics Engineering, MIT Campus
Sliding Window
Sliding window of the sender
Tx shrinks from left when frames of
data are sent.

The sliding window of the sender


expands to the right when ACK
are received.

Sliding window of the receiver


Rx shrinks from left when frames
of data are received.

The sliding window of the


receiver expands to the right
when ACK are sent.
Dr. G. Balamurugan
30
Department of Electronics Engineering, MIT Campus
Sliding Window Example

Dr. G. Balamurugan
31
Department of Electronics Engineering, MIT Campus
Sliding Window : Why window size is
(2^m)-1 ?

Timeout

Assume m=2 & window size:4 Consider (2^m)


Dr. G. Balamurugan
Department of Electronics Engineering, MIT Campus 32
Sliding Window : Why window size is
(2^m)-1 ?
Assume m=2 & window size:3 Consider (2^m)-1

Timeout

Transmitter Correctly identify that all frames are lost or corrupted.


Dr. G. Balamurugan
Duplicate frame Department of Electronics Engineering, MIT Campus
is correctly discarded – if ACK is lost 33
Flow control Protocols
Error control in the data link layer is based on automatic repeat
request (ARQ), done by keeping a copy of the sent frame and
retransmitting of the frame when the timer expires.

Dr. G. Balamurugan
34
Department of Electronics Engineering, MIT Campus
Go-Back-N ARQ
 We can send up to W frames before worrying about ACKs.

 We keep a copy of these frames until the ACKs arrive.

 Frames must be received in the correct order

 If a frame is lost, the lost frame and all of the following frames must be
retransmitted

Sequence Numbers:
 Frame header contains m bits for sequence number

 That allows up to 2m different frame numbers

Dr. G. Balamurugan
35
Department of Electronics Engineering, MIT Campus
Go-Back-N ARQ
• The problem of “Stop and Wait” is not able to send multiple packets
• Sliding Window Protocol allows multiple frames to be in transit
• Receiver has buffer of 1 (called window size) frames
• Transmitter can send up to W frames without ACK
• Each frame is numbered using Sequence number bounded by size of
the sequence number field (k bits)
• Once the first frames in the window is ACKed
Transmitter
– ACKed frames are removed from the buffer
– More frames are transmitted
– Receiver expects one frame at a time
– Result: The window slides to the right
Receiver

Dr. G. Balamurugan
36
Department of Electronics Engineering, MIT Campus
Go-back-N : Control Variables
• S holds the sequence number of recently sent frame
• SF holds the sequence number of the first frame
• SL holds the sequence number of the last frame
• Receiver only has the one variable, R, that holds the sequence number of
the frame it expects to receive. If the seq. no. is the same as the value of
R, the frame is accepted, otherwise rejected.

Dr. G. Balamurugan
37
Department of Electronics Engineering, MIT Campus
Acknowledgement (ACK)
• Receiver sends positive ACK if a frame arrived safe and in order.

• If the frames are damaged/out of order, receiver is silent and discard all subsequent

frames until it receives the one it is expecting.

• The silence of the receiver causes the timer of the unacknowledged frame to expire.

• Then the sender resends all frames, beginning with the one with the expired timer.

• For example, suppose the sender has sent frame 6, but the timer for frame 3 expires

(i.e. frame 3 has not been acknowledged), then the sender goes back and sends

frames 3, 4, 5, 6 again. Thus it is called Go-Back-N-ARQ

• The receiver does not have to acknowledge each frame received, it can send one

cumulative ACK for several frames.

Dr. G. Balamurugan
38
Department of Electronics Engineering, MIT Campus
Case 1. Go-back-N (Normal Operation)
 Sender keeps track of
Sender Receiver
the outstanding frames and
updates the variables
andwindows as the ACKs
arrive.

Time Time
Dr. G. Balamurugan
39
Department of Electronics Engineering, MIT Campus
Case 2: Go-Back-N (damaged/lost/delayed)ACK
Sender Receiver
• If an ACK is damaged/lost,
we can have two situations:
(1) If the next ACK arrives
before the expiration of any
timer, there is no need for
retransmission of frames
because ACKs are
cumulative in this protocol.
(2) If ACK1, ACK2, and
ACk3 are lost, ACK4 covers
them if it arrives before the
timer
• expires.
• If ACK4 arrives after time-
out, the last frame and all the
frames after that are resent.
Timeout
• Receiver never resends an
ACK.
• A delayed ACK also triggers
Time Time the resending of frames
Dr. G. Balamurugan
40
Department of Electronics Engineering, MIT Campus
Disadvantage of Go-back-N
 Inefficient
 all out of order received packets are discarded at receiver

 This is a problem in a noisy link


 many frames must be retransmitted -> bandwidth consuming

 Solution
 re-send only the damaged frames

 Selective Repeat ARQ


 avoid unnecessary retransmissions

Dr. G. Balamurugan
41
Department of Electronics Engineering, MIT Campus
Go-Back-N ARQ, sender window size

Dr. G. Balamurugan
42
Department of Electronics Engineering, MIT Campus
Selective Repeat ARQ
• Go-Back-N always discards out-of-order frames
– Losing one frame may result in retransmission of multiple
frames
– Very inefficient in noisy link
• Selective Repeat ARQ allows frames to be received out of order
– Therefore, receive window > 1

Send and Receive Windows


•Sender and receiver share window space equally
•For m-bit sequence numbers
Send window: up to 2m-1
Receive window: up to 2m-1
Dr. G. Balamurugan
43
Department of Electronics Engineering, MIT Campus
Selective Repeat ARQ
Note: Size of the sender and receiver windows must be at most one-half of 2m.
Send Window

Receive Window

Dr. G. Balamurugan
44
Department of Electronics Engineering, MIT Campus
Selective Repeat ARQ, lost frame
• Frames 0 and 1 are accepted
when received because they
are in the range specified by
the receiver window. Same for
frame 3.
• Receiver sends a NAK2 to
show that frame 2 has not
been received and then sender
resends only frame 2 and it is
accepted as it is in the range
of the window.

Dr. G. Balamurugan
45
Department of Electronics Engineering, MIT Campus
Selective Repeat ARQ: Window Size

Dr. G. Balamurugan
46
Department of Electronics Engineering, MIT Campus
Issues – Buffer Size
• Go-back-n ARQ
—sender needs to keep a buffer equal to window size
• for possible retransmissions
—receiver does not need any buffer (for flow/error control)
•For m-bit sequence numbers
Send window: up to 2m -1 Receive window: Expecting Frame
• Selective repeat ARQ
—sender needs to keep a buffer of window size for
retransmissions
—receiver keeps a buffer equal to sender window size
•For m-bit sequence numbers
Send window: up to 2m-1 Receive window: up to 2m-1
Dr. G. Balamurugan
47
Department of Electronics Engineering, MIT Campus
Piggybacking
( Bidirectional transmission)
• Data are transferred both ways
• ACK are "piggybacked" with
data frames

• A method to combine a data


frame with ACK.

• Instead of sending separately,


station A sends a data frame that
includes an ACK.

• Station B does the same thing.

• Piggybacking saves bandwidth.

Dr. G. Balamurugan
48
Department of Electronics Engineering, MIT Campus
Summary
• Flow control is the regulation of the sender’s data rate so that the receiver buffer does
not become overwhelmed.
• Error control is both error detection and error correction.
• In Stop-and-Wait ARQ, the sender sends a frame and waits for an acknowledgment
from the receiver before sending the next frame.
• In Go-Back-N ARQ, multiple frames can be in transmit at the same time. If there is an
error, retransmission begins with the last unacknowledged frame even if subsequent
frames have arrived correctly. Duplicate frames are discarded.
• In Selective Repeat ARQ, multiple frames can be in transit at the same time. If there is
an error, only the unacknowledged frame is retransmitted.
• Flow control mechanisms with sliding windows have control variables at both sender
and receiver sites.
• Piggybacking couples an acknowledgment with a data frame.
Dr. G. Balamurugan
49
Department of Electronics Engineering, MIT Campus
• In a Go-Back-N ARQ, if the window size is 63, what is the range of sequence
numbers? 0-62

• In Go-Back-N ARQ, if frames 4, 5, and 6 are received successfully, the


7
receiver may send an ACK _______ to the sender.

Exactly 10
• For Stop-and-Wait ARQ, for 10 data packets sent, _______ acknowledgments
are needed.

• In _______ framing, there is no need for defining the boundaries of frames.


fixed-size
• In ________ framing, we need a delimiter (flag) to define the boundary of
two frames. variable-size

Dr. G. Balamurugan
50
Department of Electronics Engineering, MIT Campus
• TheStop-and-Wait
_______Protocol has flow control, but not error control.

• The _______Protocol has both flow control and error control.


Stop-and-Wait ARQ, Go-Back-N ARQ, Selective-Repeat ARQ

• In the _____ Protocol, the sender sends its frames one after
another with no regard to the receiver. Simplest

• In the _____ Protocol, the sender sends one frame, stops until it
receives confirmation from the receiver, and then sends the next
frame. Stop-and-Wait

• In the _________Protocol, if no acknowledgment for a frame has


arrived, we resend all outstanding frames. Go-Back-N ARQ

• In the _________ protocol we avoid unnecessary transmission by


sending only frames that are corrupted. Selective-Repeat ARQ
Dr. G. Balamurugan
51
Department of Electronics Engineering, MIT Campus
• In Go-Back-N ARQ, if 5 is the number of bits for the sequence number,
then the maximum size of the send window must be _____31

• In Go-Back-N ARQ, if 5 is the number of bits for the sequence


number, then the maximum size of the receive window must be
_____
1

• In Selective Repeat ARQ, if 5 is the number of bits for the


sequence number, then the maximum size of the send window
must be _____
16

• In Selective Repeat ARQ, if 5 is the number of bits for the


sequence number, then the maximum size of the receive window
must be _____
16 Dr. G. Balamurugan
52
Department of Electronics Engineering, MIT Campus
Dr. G. Balamurugan
53
Department of Electronics Engineering, MIT Campus

You might also like