TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer...

26
TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from “Computer Networks A Systems Approach”, Fourth Ed.,Peterson and Davie, Morgan Kaufmann, 2007. Advanced Computer Networks TCP Sliding Windows

Transcript of TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer...

Page 1: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

TCP Sliding Windows,Flow Control,

and Congestion Control

Lecture material taken from “Computer Networks A Systems Approach”,

Fourth Ed.,Peterson and Davie,Morgan Kaufmann, 2007.

Advanced Computer Networks TCP Sliding Windows

Page 2: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sliding Windows Outline

• Generic Sliding Windows• Receiver Response Choices• Introduction to TCP Sliding Windows

– Flow control and buffers– Advertised window– Congestion control

Advanced Computer Networks TCP Sliding Windows

2

Page 3: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sliding Windows

• Normally a data link layer concept.• Our interest is understanding the TCP

mechanism at the transport layer.• Each frame is assigned a sequence number:

SeqNum.• The sender maintains three variables: send

window size (SWS), last ACK received (LAR), and last Frame sent (LFS).

Advanced Computer Networks TCP Sliding Windows

3

Page 4: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sender Variables

• SWS :: the upper bound on the number of outstanding frames (not ACKed) the sender can transmit.

• LAR :: the sequence number of the last ACK received.

• LFS :: the sequence number of the last frame sent.

Advanced Computer Networks TCP Sliding Windows

4

Page 5: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sender Invariant

LFS – LAR ≤ SWS

LAR LFS

≤ SWS

Advanced Computer Networks TCP Sliding Windows

5

Page 6: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sender Window

• An arriving ACK LAR moves right 1

sender can send one more frame.• Associate a timer with each frame the

sender transmits.• Sender retransmits the frame if the

timer times out.• Sender buffer :: up to SWS frames.

Advanced Computer Networks TCP Sliding Windows

6

Page 7: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Receiver Variables

• Receiver window size (RWS) :: the upper bound on the number of out-of-order frames the receiver is willing to accept.

• Largest acceptable frame (LAF) :: the sequence number of the largest acceptable frame.

• Last frame received (LFR) :: the sequence number of the last frame received.

Advanced Computer Networks TCP Sliding Windows

7

Page 8: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Receiver Invariant

LAF – LFR ≤ RWS

LFR LAF

≤ RWS

Advanced Computer Networks TCP Sliding Windows

8

Page 9: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Receiver Window

When a frame arrives with SeqNum:

If (SeqNum ≤ LFR or SeqNum > LAF)

the frame is discarded because it is outside the window.

If (LFR < SeqNum ≤ LAF)

the frame is accepted.

Advanced Computer Networks TCP Sliding Windows

9

Page 10: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Receiver ACK Decisions

SeqNumToAck :: largest sequence number not yet ACKed such that all frames ≤ SeqNumToAck have been received.

• Receiver ACKs receipt of SeqNumToAck and sets

LFR = SeqNumToAck

LAF = LFR + RWS

SeqNumToAck is adjusted appropriately!

Advanced Computer Networks TCP Sliding Windows

10

Page 11: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

1. ACK sequence number indicates the last frame successfully received.

- OR -

2. ACK sequence number indicates the next frame the receiver expects to receive.

Both of these can be strictly individual ACKs or represent cumulative ACKing.

Cumulative ACKs is the most common technique.

Generic ACK Choices

Advanced Computer Networks TCP Sliding Windows

11

Page 12: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

1.Use a duplicate ACK.

2. Use a selective ACK [SACK].

3. Use a negative ACK [NACK] .

Generic Responses to a Lost Packet or Frame

Advanced Computer Networks TCP Sliding Windows

12

Page 13: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

TCP Sliding Windows

* In practice, the TCP implementation switches from packet pointers to byte pointers.

• Guarantees reliable delivery of data.• Ensures data delivered in order.• Enforces flow control between sender and

receiver.• The idea is: the sender does not overrun the

receiver’s buffer.

Advanced Computer Networks TCP Sliding Windows

13

Page 14: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Application process

Write

bytes

TCP

Send buffer

Segment Segment Segment

Transmit segments

Application process

Read

bytes

TCP

Receive buffer

■ ■ ■

Figure 5.3 TCP Managing a Byte Stream

P&D slide

Advanced Computer Networks TCP Sliding Windows

14

Page 15: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Figure 5.8 Relationship between TCP Send Buffer and TCP Receive

Buffer

Sending application

LastByteWrittenTCP

LastByteSentLastByteAcked

Receiving application

LastByteReadTCP

LastByteRcvdNextByteExpected

(a) (b)

P&D slide

Advanced Computer Networks TCP Sliding Windows

15

Page 16: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Receiver’s Advertised Window

• The big difference in TCP is that the size of the sliding window size at the TCP receiver is not fixed.

• The receiver advertises an adjustable window size (AdvertisedWindow field in TCP header).

• Sender is limited to having no more than AdvertisedWindow bytes of unACKed data at any time.

Advanced Computer Networks TCP Sliding Windows

16

Page 17: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Figure 5.4 TCP Header Format

P&D slide

Advanced Computer Networks TCP Sliding Windows

17

Page 18: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Figure 5.5 Simplified TCP

P&D slide

Advanced Computer Networks TCP Sliding Windows

18

Page 19: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

• The discussion is similar to the previous sliding window mechanism except we add the complexity of sending and receiving application processes that are filling and emptying their local buffers.

• Also we introduce the complexity that buffers are of finite size without worrying about where the buffers are stored.

MaxSendBuffer

MaxRcvBuffer

TCP Flow Control

Advanced Computer Networks TCP Sliding Windows

19

Page 20: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

• The receiver throttles the sender by advertising a window size no larger than the amount it can buffer.

On TCP receiver side:

LastByteRcvd - LastByteRead ≤ MaxRcvBuffer

to avoid buffer overflow!

TCP Flow Control

Advanced Computer Networks TCP Sliding Windows

20

Page 21: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

TCP receiver advertises:

AdvertisedWindow = MaxRcvBuffer -

(LastByteRcvd - LastByteRead)

i.e., the amount of free space available in the receiver’s buffer.

TCP Flow Control

Advanced Computer Networks TCP Sliding Windows

21

Page 22: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

The TCP sender must adhere to the AdvertisedWindow from the receiver such that

LastByteSent – LastByteAcked ≤ AdvertisedWindow

or use EffectiveWindow

EffectiveWindow = AdvertisedWindow – (LastByteSent –

LastByteAcked)

TCP Flow Control

Advanced Computer Networks TCP Sliding Windows

22

Page 23: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sender Flow Control Rules:1. EffectiveWindow > 0 for sender to send more

data.

2. LastByteWritten – LastByteAcked ≤ MaxSendBufferequality here send buffer is full!! TCP sender process must block the sender application.

TCP Flow Control

Advanced Computer Networks TCP Sliding Windows

23

Page 24: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

TCP Congestion Control• CongestionWindow :: a variable held by

the TCP source for each connection.

* TCP is modified such that the maximum number of bytes of unacknowledged data allowed is the minimum of CongestionWindow and AdvertisedWindow.

MaxWindow :: min (CongestionWindow , AdvertisedWindow)

Advanced Computer Networks TCP Sliding Windows

24

Page 25: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

TCP Congestion Control

Finally, we have thatEffectiveWindow = MaxWindow –

(LastByteSent – LastByteAcked)

The idea :: the source’s effective window can be no faster than the slowest of the network (i.e., its core routers) or the destination Host.

The TCP source receives implicit and/or explicit indications of congestion by which to reduce the size of CongestionWindow.

Advanced Computer Networks TCP Sliding Windows

25

Page 26: TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,

Sliding Windows Summary

• Generic Sliding Windows• Receiver Response Choices• Introduction to TCP Sliding Windows

– Flow control and buffers– Advertised window– Congestion control

Advanced Computer Networks TCP Sliding Windows

26