Flow Control and Buffering - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

Flow Control and Buffering

Description:

Buffering by the sender, if network is unreliable: ... A damaged frame is detected. On request, sender must. Stop transmission. Re-send frames. Go-back-N ARQ ... – PowerPoint PPT presentation

Number of Views:610
Avg rating:3.0/5.0
Slides: 46
Provided by: alanwi8
Category:

less

Transcript and Presenter's Notes

Title: Flow Control and Buffering


1
Flow Control and Buffering
  • In this section
  • Buffer organization
  • Flow control
  • Go-back-N
  • Selective repeat/reject
  • Deadlock avoidance
  • Examples

2
Flow Control and Buffering
  • Flow control keep a fast transmitter from
    overrunning a slow receiver.
  • Buffering by the sender, if network is
    unreliable
  • Sender must store frames that are sent in a
    buffer until they are acknowledged by receiver.
  • Frames that are lost (that is, they are not
    acknowledged within a timeout) are retrieved from
    buffer and resent.
  • When the network is reliable
  • If sender knows that receiver always has
    available buffer space, and can accept all
    incoming frames, the sender may not need a buffer.

3
Buffer Organization
  • Chained, fixed-size buffers
  • Best for protocols where frames are of similar
    size

Frame
Frame
Frame
Unused
  • Single, large circular buffer
  • Good for heavily loadedconnections, with
    variablesized frames
  • For lightly loadedconnections, much ofbuffer
    may remainunused

Frame 1
Frame 2
Frame 3
Unused
4
Buffering at Sender versus Receiver
  • Depends on the type of traffic carried by the
    connection.
  • Low bandwidth, bursty traffic
  • Example interactive terminal session with
    occasional key strokes.
  • Avoid allocating buffers in advance.
  • Dynamic allocation as needed
  • Sender cannot be sure that receiver can always
    allocate a buffer, so sender must retain frame
    until acknowledged.
  • Buffer at sender.
  • High bandwidth, continuous traffic flow
  • Example audio, video, large file transfer
  • Receiver should allocate a full set of buffers to
    keep flow at maximum speed.

5
Adjusting Buffer Allocation
  • Sender and receiver should be able to dynamically
    adjust to changes in traffic flow.
  • Sender may be able to request receiver to
    allocate an amount of buffer space.
  • Receiver can inform sender of how much buffer
    space is available.
  • Buffers can be allocated separately per
    connection, or for all communication between the
    two hosts.
  • General method for dynamic buffer allocation
  • Use a sliding window protocol, but decouple
    buffer allocation from acknowledgments.

6
Flow control methods
  • Simple Stop-and-wait
  • Sender sends frame, and must receive positive
    acknowledgement from receiver before sending next
    frame.
  • Automatic Repeat reQuest (ARQ)
  • Frames sent with a sequence number to identify
    frames
  • Receiver will inform sender if
  • There is no more buffer space.
  • A damaged frame is detected.
  • On request, sender must
  • Stop transmission.
  • Re-send frames.

7
Go-back-N ARQ
  • Frames transmitted continuously (when available)
    up to window size N.
  • (Logically) different timer associated with each
    frame not yet acknowledged.
  • Receiver
  • Acknowledge (ACK) frame if correctly received and
    in order pass to higher layer.
  • Negative acknowledge (NACK), or ignore (possibly
    discard) corrupt, or out-of-order frame.
  • Sender
  • If NACK received, or timer expires, for frame n,
    begin resending from frame n all over again
  • ACK of frame n implicitly acknowledges up to n

8
Selective Repeat ARQ
  • As in Go-Back-N
  • Frames transmitted when available up to limit.
  • Timer associated with each unacknowledged frame.
  • Receiver NACKs or ignores corrupted frames.
  • Differences
  • Out of order, but otherwise correct, frame is
    ACKd.
  • Receiver buffers out of order frames.
  • Sender on timeout or NACK of frame n, resend
    only single frame n

sequence number
x 1
x
x 1
x 2
x 3
x 4
x 5
x 6
received and delivered to user
received and buffered
not yet received
9
Comparison
  • Go-back-N ARQ
  • Simplicity in buffering and protocol processing
    at sender and receiver.
  • If receiver discards bad or out of order
    messages, no receiver buffering is required.
  • More retransmission traffic with unreliable
    network.
  • Selective repeat ARQ
  • More receiver buffering required.
  • More complex buffer management for both sender
    and receiver.
  • Saves bandwidth avoids retransmission of
    correct frames.

10
Sliding Window, Go-Back-N (1)
  • Assumption Frames contain a k bit sequence
    number
  • Sequence numbers cycle modulo 2k
  • Next sequence number after 2k 1 is 0.
  • More on this later!
  • Initially, sender requests a certain number of
    frame buffers from receiver, using a special
    control message.
  • Receiver replies with number of buffers granted
  • This defines a window size for sender.
  • Each time sender sends a frame, it increments its
    sequence number, starts a timer, and decrements
    its buffer allocation.
  • If timeout occurs, frame is assumed to be lost
    and must be re-sent, followed by all subsequent
    frames.

11
Sliding Window, Go-Back-N (2)
  • If senders buffer allocation reaches zero, it
    must stop sending until more buffers are granted
    by receiver.
  • Receiver sends acknowledgments that include
  • Highest sequence number of consecutively numbered
    frames that have been successfully received (the
    Go-Back-N rule).
  • Number of buffers available.
  • Based on acknowledgment number, sender knows how
    many frames can be discarded from sending buffer.

12
Go-Back-N Example (1)
Assumption sequence number is 4 bits
A Message B Comment
  • ? ltack 15, win 4gt ? B grants window size 4
    A sets window to 0-3
  • ? ltseq 0, data m0gt ? A adjusts window to
    1-3
  • ? ltseq 1, data m1gt ? A adjusts window to
    2-3
  • ? ltseq 2, data m2gt ... Message lost, but
    A thinks window is 3
  • ? ltack 1, win 3gt ? B grants window size 3,
    following message 1 2-4 A adjusts
    window to 3-4
  • ? ltseq 3, data m3gt ? A adjusts window to
    4

13
Go-Back-N Example (2)
A Message B Comment
.
  • ? ltseq 4, data m4gt ? A has to stop sending
    new frames window
  • ? ltseq 2, data m2gt ? A times out for
    acknowledging frame 2 and resends
  • ? ltseq 3, data m3gt ? Resend of frame 3
  • ? ltseq 4, data m4gt ? Resend of frame 4
  • ? ltack 4, win 0gt ? B acknowledges up
    to frame 4, but has no buffers yet, so
    A is still blocked with window

14
Go-Back-N Example (3)
A Message B Comment
.
  • ? ltack 4, win 1gt ? B grants window size
    1 after message 4 A sets window to 5
  • ? ltack 4, win 2gt ? B grants window size
    2 after message 4 A sets window to
    5-6
  • ? ltseq 5, data m5gt ? A adjust window to
    6
  • ? ltseq 6, data m6gt ? A adjust window to
  • ? ltack 6, win 0gt ? Both messages
    received by B, but A is still blocked
  • ... ltack 6, win 4gt ? B grants window size
    4 7-10 but message never arrives at A

15
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 15, win 4
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
16
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
17
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
18
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
19
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
0
m0
ack 1, win 3
1
1
m1
1
1
m1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
20
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
m3
3
3
m3
3
3
m3
4
4
m4
4
4
m4
21
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
m3
2
m4
3
2
2
m2
4
3
m3
3
3
m3
4
4
4
m4
4
4
m4
22
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
2
m2
2
m2
3
3
3
m3
4
4
4
m4
23
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
3
m3
3
m3
4
4
4
m4
24
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
3
m3
3
m3
4
4
4
m4
4
m4
25
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 4, win 0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
2
m2
3
3
m3
3
3
m3
3
m3
4
4
m4
4
4
m4
4
m4
26
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 4, win 1
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
5
5
m5
5
5
m5
27
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 4, win 2
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
5
5
m5
5
5
m5
6
6
m6
6
6
m6
28
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
5
5
m5
5
5
m5
5
m5
6
6
m6
6
6
m6
29
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
5
5
m5
5
5
m5
6
6
m6
6
6
m6
6
m6
30
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
5
5
m5
5
5
m5
5
m5
ack 6, win 0
6
6
m6
6
6
m6
6
m6
7
7
m7
7
7
m7
8
8
m8
8
8
m8
9
9
m9
9
9
m9
10
10
m10
10
10
m10
31
Go-Back-N Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
ack 6, win 4
5
5
m5
5
5
m5
6
6
m6
6
6
m6
7
7
m7
7
7
m7
8
8
m8
8
8
m8
9
9
m9
9
9
m9
10
10
m10
10
10
m10
32
Avoiding deadlocks
  • Note that control frames (the acknowledgments /
    buffer allocations) are not themselves sequenced,
    timed out, or confirmed.
  • As seen at point 19 in previous example,
    deadlocks are possible if buffer allocations may
    be lost.
  • To avoid this, both hosts should periodically
    send status updates
  • In previous example, B would not be receiving new
    frames.
  • B would send ltstatus, ack 6, win 4gt
    periodically.
  • Hopefully, one of these messages will get
    through, and A will restart.
  • A may also send ltstatus, ack 6, win 0gt
    periodically while blocked.
  • On receiving inconsistent status message, B would
    retransmitltack 6, win 4gt.

33
Window size versus Sequence Numbers
  • A sequence number consisting of m bits allows for
    n 2m sequence numbers
  • Suppose we allow a window of size n 1
  • example m 2, n 4, window 5
  • Ensure that the sequence number range is much
    larger than potential window sizes

1 ? ltack 3, win 5gt ? B grants 5
buffers 2 ? ltseq 0, data m0gt ? Message
received 3 ? ltseq 1, data m1gt ? Message
lost 4 ? ltseq 2, data m2gt ? Message
lost 5 ? ltseq 3, data m3gt ? Message
lost 6 ? ltseq 0, data m4gt ?? A thinks it is
out of buffers 7 ? ltack 0, win 4gt ? Was it
line 2 or line 6 that this refers to?
34
Selective Repeat
  • Here is the same example, but using selective
    Repeat
  • In particular
  • Frame 2 will be lost on the first send attempt
  • Receiver will NACK frame 2 after frame 3 arrives
  • However, frame 3 is kept at receiver
  • Sender will resend frame 2 after NACK arrives
  • Receiver should not adjust window size with a
    NACK message

35
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 15, win 4
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
36
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
37
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
38
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
39
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
0
m0
ack 1, win 3
1
1
m1
1
1
m1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
40
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
3
m3
4
4
m4
4
4
m4
41
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
nack 2
2
2
m2
2
2
m2
3
3
m3
3
3
m3
3
m3
4
4
m4
4
4
m4
42
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
m3
2
m2
3
2
2
m2
2
3
m3
3
3
m3
4
3
m3
4
4
m4
4
4
m4
43
Selective Repeat Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
1
1
m1
1
1
m1
m3
2
m2
3
2
2
m2
2
3
m3
3
3
m3
4
3
m3
4
4
m4
4
4
m4
m4
4
44
Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 4, win 0
1
1
m1
1
1
m1
2
2
m2
2
2
m2
2
m2
3
3
m3
3
3
m3
3
m3
4
4
m4
4
4
m4
4
m4
45
Example
B
A
seq.
data
seq.
data
0
0
m0
0
0
m0
ack 4, win 1
1
1
m1
1
1
m1
2
2
m2
2
2
m2
3
3
m3
3
3
m3
4
4
m4
4
4
m4
5
5
m5
5
5
m5
Write a Comment
User Comments (0)
About PowerShow.com