ch10_FlowControl&Error02

advertisement
Flow&Error Control
R. Supakorn
1
Flow Control
• Flow control refers to
a set of procedure used to restrict the amount of
data that the sender can send before waiting for
an acknowledgement
2
3
Stop and Wait
4
Sliding Window
5
Sender Sliding Window
6
Receiver Sliding Window
7
Sliding Window Example
8
Sender
9
Receiver
10
11
Stop-and-wait ARQ
• The simplest flow and error control mechanism
• Features
– Sending device keeps the copy of the last frame
transmitted
– For identification purpose :
• Both data frames and acknowledgement frames are numbered
alternately 0 and 1
– A data 0 frame is acknowledged by and ACK 1
frame
12
Stop-and-wait ARQ
• Features : lost/damaged frames
– When receives a damaged frame, a receiver :
• Discards the frame
• Does not send an acknowledgement
– When receives out of order frames
• Means lost frames
• Discards this frame
13
Stop-and-wait ARQ
• Features : control variables
– A sender has a control variable called S
• Hold the number of recently sent frame (0 or 1)
– A receiver has a variable called R
• Holds the number of next frame expected (0 or 1)
14
Stop-and-wait ARQ
• Features : a timer
– The sender starts a timer when it sends a frame
– If an acknowledgement is not received within
the allotted time period, the sender :
• Assumes that the frame was lost
• Resends the frame
15
Stop-and-wait ARQ
• Features : an acknowledgement mechanism
– The receiver
• Sends only positive acknowledgement for good frames
• Stays silent for damaged/lost frames
– The acknowledgement number always defines the
number of next expected frame
16
Stop-and-wait ARQ
• Operations
–
–
–
–
Normal operation
Lost or damaged frame
Lost acknowledgement
Delayed acknowledgement
17
Stop-and-wait ARQ
• Operations: normal operation
Sender
Receiver
Frame 0
s=0
=
R 0
ACK 1
s=1
Frame 1
=
R 1
ACK 0
s=0
time
.
.
.
time
18
Stop-and-wait ARQ
• Operations: lost frame
Sender
Receiver
s=0
Frame 0
=
R 0
ACK 1
Frame 1
s=1
s=1
Time-out
Frame 1
=
R 1
lost
=
R 1
ACK 0
s=0
time
=
R 0
time
19
Stop-and-wait ARQ
• Operation : lost acknowledgement
Sender
Receiver
s=0
Frame 0
=
R 0
ACK 1
s=1
=
Frame 1
R 1
ACK 0
s=1
Frame 1
Time-out
=
R 0
Expecting frame 0, frame
1 is discarded
ACK 0
s=0
time
time
20
Stop-and-wait ARQ
• Operation : delayed acknowledgement
Sender
Receiver
s=0
Time-out
Frame 0
ACK 1
s=0
s=1
time
=
Frame 0
s=1
discarded
=
R 0
R 1
Expecting frame 1, frame
0 is discarded
Frame 1
=
R 0
ACK 1
ACK 0
time
21
Go-Back-N ARQ
• Overcomes inefficiency of Stop-and-Wait ARQsender continues sending enough frames to keep
channel busy while waiting for ACKs
• A window of Ws outstanding frames is allowed
• m-bit sequence numbers are used for both-frmaes
and ACKs, and Ws=2m-1
22
Go-Back-N ARQ (cont.)
23
Sender Sliding Window
• All frames are stored in a buffer,
outstanding frames are enclosed in window
– Frames to the left of the window are already
acknowledged and can be purged
– Frames to the right of the window cannot be
sent until the window slides over them
– Whenever a new ACK arrives, the window
slides to include new unsent frames
– Once the window gets full (max# of
outstanding frames is reached), entire window
gets resent
24
Sender Sliding Window (cont.)
25
Receiver Sliding Window (cont.)
• The size of receiver window is always 1
– Receiver is always looking for a specific frame to
arrive in a specific order
– Any frame arriving out of order is discarded and needs
to be resent
26
Go-Back-N with timeout
• Go-Back-N works correctly as long as the sender
has unlimited supply of packets that need to be
transmitted
– But, in case when ACK packets arrive sporadically,
there may not be Ws-1 subsequent transmissions =>
window will not be exhausted, retransmissions will not
be triggered
– This problem can be resolved by modifying Go-Back-N
such that:
• Set a timer for each sent frame
• Resend all outstanding frames either when the window gets
full or when the timer of first frame expires
27
Go-Back-N with timeout (cont.)
28
Lost frame in Go-Back-N with timeout
29
Sequence numbers and window size
• m bit allotted within a header for sequence
numbers => 2m possible sequence numbers
–
–
–
–
How long should the sender window be?
W > 2m connot be accepted => ambiguous ACKs
W = 2m can still cause some ambiguity
W = 2m – 1 acceptable
30
Sequence numbers and window size
31
Selective Repeat ARQ
•
Go-Back-N is NOT suitable for ‘noisy links’ –incase of a
lost/damaged frame a whole window of frames need to be
resent
•
excessive retransmissions use up the bandwidth and slow
down transmission
•
Selective Repeat ARQ overcomes the limitationsof Go-BackN by adding 2 new features
(1) receiver window > 1 frame, so that out-of-order but error-free
frames can be accepted
(2) retransmission mechanism is modified –only individual
frames are retransmitted
•
Selective Repeat ARQ is used in TCP!!!
32
Selective Repeat ARQ (cont.)
33
Selective Repeat ARQ (cont.)
Receiver:
• window advances whenever next in-order frame
arrives
• out-of-order frames are accepted only if their
sequence numbers satisfy Rnext< Rframe< Rnext+ Ws-1
• a negative ACK (NAK) with sequence number Rnext
is sent whenever an out-of-sequence frame is
observed
34
Selective Repeat ARQ (cont.)
Sender:
• window advances whenever an ACK arrives
• if a timer expires, the corresponding frame
is resent, and the timer is reset
• whenever a NAK arrives, Rnextframe is
resent
35
Selective Repeat ARQ (cont.)
36
Window size – WS and WR
• m bits allotted within a header for sequence
numbers => 2m possible sequence numbers
– how big should the windows be!?
– WSand WR= 2m-1 cannot be accepted due to
possible ambiguity
– W = 2m/2 = 2m-1 acceptable !!!
37
Window size – WS and WR (cont.)
38
HDLC
General HDLC Frame
Two types of control frames
I (information) frames N(R) ack#,N(S)seq#
S (supervisory) frames
p/f = poll/final
39
HDLC control field
• SS=00 RR
- Receiver Ready to accept more I-frames
• SS=01 REJ
- Go-Back-N retransmission request for an I-frame
• SS=10 RNR
- Receiver Not Ready to accept more I-frames
• SS=11 SREJ
- Selective retransmission request for an I-frame
40
HDLC operation
41
HDLC operation (cont.)
A
0
1
2
3
4
5
0
1
2
3
0
1
2
3
4
5
0
1
2
3
0
1
2
3
4
5
0
1
2
3
2
3
4
3
4
0
0
0
1
1
1
2
2
3
4
5
5
0
0
5
0
1
1
1
2
2
2
3
3
3
I,0,0
I,1,0
I,2,0
I,3,0
I,4,0
I,5,0
0
1
2
3
4
5
0
1
2
3
0
1
2
3
4
5
0
1
2
3
0
1
2
3
4
5
0
1
2
3
2
3 I,3,0
0
1
2
3
4
5
0
1
I,0,0
I,1,0
I,2,0
B
I,0,0
I,1,0
I,2,0
I,3,0
I,4,0
,F
R R, 4
I,5,0
I,0,0
I,1,0
I,2,0
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