16
Lecture 5: Flow Control CSE 123: Computer Networks Alex C. Snoeren HW 1 due FRIDAY

Lecture 5: Flow Control

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 5: Flow Control

Lecture 5:Flow Control

CSE 123: Computer NetworksAlex C. Snoeren

HW 1 due FRIDAY

Page 2: Lecture 5: Flow Control

Moving up the Stack

2

HTTP

TCP

IP

Ethernetinterface

HTTP

TCP

IP

Ethernetinterface

IP IP

Ethernetinterface

Ethernetinterface

SONETinterface

SONETinterface

host host

router router

Link Layer

Network Layer

Transport Layer

Application Layer

CSE 123 – Lecture 5: Flow Control

Page 3: Lecture 5: Flow Control

Simple Idea: ARQ

! Receiver sends acknowledgments (ACKs)u Sender “times out” and retransmits if it doesn’t receive them

! Basic approach is generically referred to as Automatic Repeat Request(ARQ)

Sender Receiver

Data

ACKTim

e

Tim

eout

Data

ACKTim

eout

T

Data

Sender Receiver

imeo

ut

3CSE 123 – Lecture 5: Flow Control

Page 4: Lecture 5: Flow Control

Not So Fast…

! Loss can occur on ACK channel as wellu Sender cannot distinguish data loss from ACK lossu Sender will retransmit the data frame

! ACK loss—or early timeout—results in duplicationu The receiver thinks the retransmission is new data

Sender Receiver

Data

ACKTim

eout

Data

ACKTim

eout

4

Sender Receiver

Data

ACKTim

eout

Data

ACKTim

eout

Duplicate!

CSE 123 – Lecture 5: Flow Control

Duplicate!

Page 5: Lecture 5: Flow Control

Sequence Numbers

! Sequence numbers solve this problemu Receiver can simply ignore duplicate datau But must still send an ACK! (Why?)

! Simplest ARQ: Stop-and-waitu Only one outstanding frame at a time

5

Sender Receiver

Data 0

ACK 0Tim

eout

Data 1

ACK 1Tim

eout

Sender Receiver

Data 0

ACK 0Tim

eout

Data 0

ACK 0Tim

eout Data 1

ACK 1

Ignored!

CSE 123 – Lecture 5: Flow Control

How many bits does stop-and-wait need for sequence numbers?

A. 1B. 2C. Depends on timeoutD. I don’t know

Page 6: Lecture 5: Flow Control

Stop-and-Wait Performance

! Lousy performance if time to transmit 1 packet (serialization delay) << time to get to the receiver (propagation delay)u How bad? Depends on round trip time (RTT)

! Want to utilize all available bandwidthu Need to keep more data “in flight”u How much? Called the bandwidth-delay product

! Also limited by quality of timeout (how long?)

6CSE 123 – Lecture 5: Flow Control

How many bits do we want to keep in flight?

A. Bandwidth * one-way delayB. Bandwidth * round-trip delayC. Depends on timeoutD. I don’t know

Page 7: Lecture 5: Flow Control

Pipelined Transmission

! Keep multiple packets “in flight”u Allows sender to make efficient use of the linku Sequence numbers ensure receiver can distinguish frames

! Sender buffers outstanding un-acked packetsu Receiver ACKs the highest consecutive frame received

» ACKs are cumulative (covers current frame and all previous)7

Sender ReceiverData 0

ACK 0

Data 1 Data 2Data 3 ACK 1

ACK 2

ACK 3

Sender ReceiverData 0

ACK 0

Data 1 Data 2Data 3 ACK 1

ACK 1

CSE 123 – Lecture 5: Flow Control

Page 8: Lecture 5: Flow Control

Go-Back-N

! Retransmit all packets from point of loss u Packets sent after loss event are ignored (i.e., sent again)

! Simple to implement (receiver doesn’t need to buffer)! Sender controls how much data is “in flight”

8

Sender ReceiverData 0

ACK 0

Data 1 Data 2Data 3 ACK 1

ACK 1

Data 2

Sender ReceiverData 0

ACK 0

Data 1 Data 2Data 3 ACK 1

ACK 3

Data 4

ACK 2

timeo

ut

CSE 123 – Lecture 5: Flow Control

Ignored!

Page 9: Lecture 5: Flow Control

Send Window! Bound on number of outstanding packets

u Window “opens” upon receipt of new ACKu Window resets entirely upon a timeout

! Limits amount of wasteu Still lots of duplicates in Go-Back-Nu We can do better with selective retransmission

9

ACK 1

ACK 0

Data 1

Sender ReceiverData 0

Data 2

Data 2

Tim

eout

Data 3ACK 1

Data 4

ACK 1

Data 3Data 4

Go-Back-N Examplewith window size 3

CSE 123 – Lecture 5: Flow Control

Page 10: Lecture 5: Flow Control

Sliding Window! Single mechanism that supports:

u Multiple outstanding packetsu Reliable deliveryu In-order deliveryu Flow control

! Sender and receiver each maintain “window” abstractions to track outstanding packetsu At the core of all modern ARQ protocols

! Go-Back-N is a special caseu Receive window size of one

10CSE 123 – Lecture 5: Flow Control

Page 11: Lecture 5: Flow Control

Sliding Window – Sender

! Window bounds outstanding unACKed datau Implies need for buffering at sender

! “Last” ACK applies to in-order data! What to do on a timeout?

u Go-Back-N: resend all unacknowledged data on timeoutu Selective Retransmit: timer per packet, resend as needed

≦ Window Size

“Last” cumulative ACK Last Sent

… …Sender:

11CSE 123 – Lecture 5: Flow Control

Page 12: Lecture 5: Flow Control

Sliding Window – Receiver

! Receiver buffers too:u data may arrive out-of-orderu or faster than can be consumed

» Flow control: tell sender how much buffer left at receiver! Receiver sends an ACK for every segment:

u Cumulative, Selective (exempt missing frames), or Negative (only missing frames)

Receive Window

“Last” in order Largest Acceptable

… …Receiver:

12CSE 123 – Lecture 5: Flow Control

Page 13: Lecture 5: Flow Control

Deciding When to Retransmit! How do you know when a packet has been lost?

u Ultimately sender uses timers to decide when to retransmit

! But how long should the timer be?u Too long: inefficient (large delays, poor use of bandwidth)u Too short: may retransmit unnecessarily (causing extra traffic)

! Right timer is based on the round-trip time (RTT)u Which can vary greatly for reasons well see later

13CSE 123 – Lecture 5: Flow Control

Page 14: Lecture 5: Flow Control

Can we shortcut the timeout?! Timeout is long in practice

u Lots of variation in RTT and timeout must be conservative

! If packets are usually in order then duplicate cumulative ACKs imply that a packet was lostu Fast retransmit

» When sender receives multiple duplicate acknowledgements resends missing packet

14CSE 123 – Lecture 5: Flow Control

Duplicate ACKs for packet N indicate which packet was lost?

A. Packet N-1B. Packet NC. Packet N+1D. Packet N+2E. You can’t tell

Page 15: Lecture 5: Flow Control

Fast retransmit! Don’t bother waiting

u Receipt of duplicate acknowledgement (dupACK) indicates loss

u Retransmit immediately

! Used in TCPu Need to be careful if frames can be reorderedu TCP Reno identifies a loss if there are three

duplicate ACKs in a row

15

ACK 1

ACK 0

Data 1

Sender ReceiverData 0

Data 2

Data 2

Data 3ACK 1

Data 4

CSE 123 – Lecture 5: Flow Control

Page 16: Lecture 5: Flow Control

For Next Time

! Read 5-5.2 in P&D

! HW 1 due at the beginning of class Friday

! (Keep) going on the project…

16CSE 123 – Lecture 5: Flow Control