Lecture 5: Reliable Transmission and Flow ControlLecture 5: Reliable Transmission and Flow Control....
Transcript of Lecture 5: Reliable Transmission and Flow ControlLecture 5: Reliable Transmission and Flow Control....
CSE 123: Computer NetworksAaron Schulman
Lecture 5:Reliable Transmission andFlow Control
Picking up the Pieces! Link layer is lossy
u We deliberately throw away corrupt frames!u Infrequent bit errors still lead to occasional frame errors
» 10,000+ bits in each frame
! Things get even harrier if we consider multiple linksu In a few lectures, we’ll start sending frames on long tripsu Each intermediate stop might lose, corrupt, reorder, etc.u Regardless of cause, we’ll call loss events drops
! We want to provide reliable, in-order deliveryu Can—and will—do this at multiple layers
2CSE 123 – Lecture 5: Reliable Transmission
Moving up the Stack
3
HTTP
TCP
IP
Ethernetinterface
HTTP
TCP
IP
Ethernetinterface
IP
IP
Ethernetinterface
Ethernetinterface
SONETinterface
SONETinterface
host host
router router
Application Layer
Transport Layer
Network Layer
Link Layer
CSE 123 – Lecture 5: Reliable Transmission
Reliable Transmission! The packet-based version of the same problem
u How do we reliably send a message when packets (not just bits) can be lost/corrupted in the network?
! Two optionsu Detect a loss/corruption and retransmit
u Send data redundantly to tolerate loss/corruption
4CSE 123 – Lecture 5: Reliable Transmission
Simple Idea: ARQ
! Receiver sends acknowledgments (ACKs)! Sender assumes transmission didn’t make when
doesn’t receive an ACK after some time (timeout)! 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
5CSE 123 – Lecture 5: Reliable Transmission
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
6
Sender Receiver
Data
ACKTim
eout
Data
ACKTim
eout
Duplicate!
CSE 123 – Lecture 5: Reliable Transmission
Sequence Numbers
! Sequence numbers solve this problemu Receiver can simply ignore duplicate datau But must still send an ACK! (Why?)
! Simplest ARQ also solves this problem: Stop-and-waitu Only one outstanding frame at a time
7
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: Reliable Transmission
Stop-and-Wait Performance
! Lousy performance if time to xmit 1 pkt << prop. delayu How bad?
! Want to utilize all available bandwidthu Need to keep more data “in flight”u How much? Called the bandwidth-delay product
! Also limited by accuracy of timeout:period of time when sender is confident it is lost.u More on picking timeouts at the end of the lecture
8CSE 123 – Lecture 5: Reliable Transmission
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)
9
Sender Receiver
Data 0
ACK 0
Data 1 Data 2Data 3 ACK 1
ACK 2
ACK 3
Sender Receiver
Data 0
ACK 0
Data 1 Data 2Data 3 ACK 1
ACK 1 Ignored!
CSE 123 – Lecture 5: Reliable Transmission
Go-Back-N
! Retransmit all packets from point of loss u Packets sent after lost packet (or ACK) are ignored
(i.e., sent again)! Simple to implement
(receiver only has to track one packet at a time)! Sender controls how much data is “in flight”
10
Sender Receiver
Data 0
ACK 0
Data 1 Data 2Data 3 ACK 1
ACK 1
Data 2
Sender Receiver
Data 0
ACK 0
Data 1 Data 2Data 3 ACK 1
ACK 3
Data 4
ACK 2
timeo
ut
CSE 123 – Lecture 5: Flow Control
Send Window (sender buffer)! Bound on number of
outstanding packetsu Window “opens” upon
receipt of new ACKu Window resets entirely
upon a timeout! Limits amount of waste
u Don’t need to remember allpackets ever sent
u Go-Back-N might still lead to sending lots of duplicates
» We can do better with selective retransmission:only retransmit missed packets 11
ACK 1
ACK 0
Data 1
Sender Receiver
Data 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
Sliding Window! Single mechanism that supports:
u Multiple outstanding packetsu Reliable deliveryu In-order deliveryu Flow control: Don’t send more than receiver can handle
! 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
12CSE 123 – 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 Repeat: timer per packet, resend as needed
≦ Window Size
“Last” ACK Last Sent
… …Sender:
13CSE 123 – Lecture 5: Flow Control
Sliding Window – Receiver
! Receiver buffers too:u data may arrive out-of-orderu or faster than can be consumed by higher layers
» Flow control: tell sender how much receive window is left! Sender will only send enough packets to fill the receive window
Receive Window
“Last” Received Largest Accepted
… …Receiver:
14CSE 123 – Lecture 5: Flow Control
Deciding When to Retransmit! How does sender know when a packet has been lost?
u Ultimately sender uses timeouts to decide when to retransmit
! But how long should the timeout 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 link latency: round-trip time (RTT)u Which can vary greatly for reasons well see later
15CSE 123 – 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 out-of-order ACKsfrom receiver imply that a packet was lost
! Knowing something is lost, we can be proactive!u Negative ACK
» Receiver requests missing packetu Fast retransmit
» When sender receives multiple duplicate acknowledgements resends missing packet
16CSE 123 – Lecture 5: Flow Control
Fast retransmit
! Don’t bother waitingfor timeoutu Receipt of duplicate
acknowledgement (dupACK) indicates loss
u Retransmit immediately
! Used in TCPu Need to be careful if
frames can be reorderedu Today’s TCP identifies a
loss if there are three duplicate ACKs in a row 17
ACK 1
ACK 0
Data 1
Sender Receiver
Data 0
Data 2
Data 2
Data 3ACK 1
Data 4
CSE 123 – Lecture 5: Flow Control
For Next Time
! Read 5-5.1 in P&D
! Homework out Friday and due in 1 week
! (Keep) going on the project…
18CSE 123 – Lecture 5: Flow Control