Title: Window Sizes and Flow Control
1Window Sizes and Flow Control
- Two factors that can affect each other are
- the maximum window size allowed by a protocol
- the number of bits available for sequence numbers
- If m bits are available for sequence numbers,
then there are 2m possible sequence numbers (0
... 2m -- 1). - We want to avoid the situation where a window
could include two messages that are different,
but have the same sequence number. - Clearly, the window size W should be such that W
lt 2m - However, there may be additional constraints, so
this is not the final value.
2Window sizes at the receiver
- Although window sizes are usually with reference
to the sender, there is effectively a receiving
window as well. - The receivers window size is determined by the
set of messages it is willing to accept at any
given time. - For Go-back-N, the receivers window size is
straightforward it is always 1. - Suppose that a receiver is expecting message N
. - Any message with sequence number lt N is assumed
to have been received already, and the message is
a duplicate created by a resend. - Any message with sequence number gt N is discarded
as being out of order. - In this context, the lt and gt operators take
into account that for m bit sequence numbers,
2m1 lt 0 lt 1
3Go-back-N window limits
- Since Go-back-N does not look ahead, all other
sequence numbers are considered to be
distinguishable. - If the protocols acknowledgements are for the
next expected sequence number, we cannot use the
entire space. - 3 bit sequence numbers, send 0 through 7 ?
acknowledgment number is 0. - Is it that 0 through 7 were received, or that no
messages were received? - 5 bit sequence number, send 0 through 6 ?
acknowledgement number is 0 - Can only be interpreted as no messages
received. - 5 bit sequence number, send 0 through 6 ?
acknowledgment number is 7 - Can only be interpreted as all messages
received. - Result The maximum window size for go-back-N is
2m 1 when sequence numbers have m bits.
4Window sizes, Go-back-N
5Selective Repeat Receivers Window (1)
- For Selective Repeat, the receivers window size
is more complicated. - There are three types of messages that could be
received. Suppose that a receiver is expecting
message M. It could actually receive - the message we are expecting M
- a resend of a previous message lt M
- a message ahead of the one we expect gt M
- Since our space of sequence numbers is circular
through 0, there has to be a limit on how far we
can look ahead from message M for acceptable
messages. - That is, there needs to be a division point at
which we distinguish a previous message from a
future message. - Why? If we have unlimited look ahead, message M
1 might be saved as a future message even
though it is more likely to be a resend.
6Selective Repeat Receivers Window (2)
- To distinguish the past from the future, we
will divide the sequence number space in halves,
based on our current expected sequence number. - If we have 2m possible sequence numbers
- 2m1 sequence numbers lt N are considered to be
the past - 2m1 1 sequence numbers gt N are considered to
be the future. - One sequence number, N, is our expected message.
- Out of the entire space, 2m1 sequence numbers
will be accepted and 2m1 sequence numbers will
be rejected. - In this context, the lt and gt operators take
into account that for m bit sequence numbers,
2m1 lt 0 lt 1
7Selective Repeat Receivers Window (3)
- Example 3 bit sequence numbers, next expected
message is 2 - Past 6, 7, 0, 1
- Present 2
- Future 3, 4, 5
- If a message with sequence number 6, 7, 0, or 1
arrives, it will be assumed to be a resend and
discarded. - If a message with sequence number 2, 3, 4, or 5
arrives, it will be saved in buffer and accepted. - Result The maximum window size for selective
repeat is 2m1 when sequence numbers have m bits.
8Window sizes, selective repeat
9Question
- Suppose that a protocol is using Go-Back-N flow /
error control, and the protocol uses 5 bits of
sequence numbers. What is the largest sending
window size that can be used safely? What could
go wrong if a larger window size is used? - What if Selective Repeat was being used?
10Solution
- Largest window size that can be used safely is 31
(25 1). - Why? Here is what could go wrong if we could
send 32 messages. - Suppose that the receiver tells us that the next
message expected is message 0. We send messages
0 through 31 that is, 32 messages in total
and the receiver tells us that it now expects
message 0. - This could be interpreted by the sender in two
ways - All 32 messages that we sent were received
successfully, and so the receiver is now
expecting message (311) 0, assuming that only
5 bits are available to store sequence numbers. - All 32 messages were lost, and the receiver is
still expecting the original message 0. Wait
for the timeout and resend the messages.
11Solution (if the window size is 25)
28
29
30
31
0
1
2
3
4
5
28
29
30
31
0
1
2
3
32 messages were sent
Sender cant tell if the messages were lost or
received
1
2
3
28
29
30
31
0
Send 0
12Solution
- There there could be several causes for why it
appears to the sender that all 32 messages are
lost - All 32 messages were, in fact, lost
- All of the acknowledgments were lost, but the
messages were actually received successfully. - Various combinations of the above.
- Note that the sender cannot tell the difference
between a lost message and a lost acknowledgment.
It has to assume the message is lost and await a
timeout to resend.
13Solution (if the window size is 25-1)
28
29
30
31
0
1
2
3
4
5
28
29
30
31
0
1
2
3
31 messages were sent
Sender knows which 0 to send
28
29
30
31
0
1
2
3
Send 0
14Solution
- 31 messages in the window is safe.
- If all 31 messages, presumably numbered 0
through 30, are lost, the receiver will tell us
it still expects message 0. - Since there is at least one sequence number we
havent used (i.e. 31), the receiver cannot be
expecting the next 0 and so it must be
expecting the previous 0. - All of this only applies to Go-back-N
15Same question, selective repeat
- If we are using Selective Repeat, then only half
of the sequence number space can be used, because
the receiver is willing to look ahead for
messages out of sequence. - Allow the receiver to use half of the sequence
number space for taking in out of sequence
messages, and the other half for resends. - With 32 sequence numbers available
- If we are currently expecting message 16 from the
receivers point of view, then at the receiver - Messages with sequence numbers 0 to 15 arriving
at the receiver are assumed to be resends. - A message with sequence number 16 is what we
want. - Messages with sequence numbers 16 to 31 are
assumed to be new messages to be kept while
waiting for message 16 to arrive.
16Selective Repeat (window size is 25-1)
Sender Window
7
8
9
17
18
20
10
11
12
13
14
16
19
15
21
22
23
31
24
25
26
27
28
30
29
Frames sent but not received ACK
Frames that can be sent
Receiver Window
7
8
9
17
18
20
10
11
12
13
14
16
19
15
21
22
23
31
24
25
26
27
28
30
29
Frames already received
Frames that can be received and stored
Next Expected Frame
Frames which have arrived out of order
17Selective Repeat Solution
- In the case where a message 0 through 14 arrives,
it may be because - The message was selectively rejected, and the
receiver had asked for a resend. - An acknowledgment had been lost, and the sender
timed out. Even though the receiver has the
message, it has appeared again. - If a message 2 shows up, the receiver needs to
be able to distinguish between the previous 2
and the next 2. - Result maximum window size for sender is 2m1,
where m is the number of bits in the sequence
number. Therefore, if we have 5 bits in the
sequence number, the maximum selective reject
window size is 25-1 24 16.
18What about the receiver?
- From the receivers point of view, the window
size is - 1 for Go-back-N
- There is only one message sequence number that
will be accepted by the receiver. - 2m1 for Selective repeat
- Up to this many sequence numbers can be accepted
by the receiver.