10/16/2003 CSC 257/457 - Fall 2003 1
Principles of Reliable Data
Transfer
Outline:
n
Overview of reliable data transfer
na correct protocol
n stop-and-wait
n
an efficient protocol
n sliding window
10/16/2003 CSC 257/457 - Fall 2003 2
Reliable Data Transfer
n
Our goal: end-to-end solution to achieve reliable
data transfer
n
What is reliable data transfer?
n guaranteed arrival n no error
n in order delivery
n
Why is it difficult?
n end-to-end solution has no control of underlying
communication channel, which can be error-prone and lossy
n
Where is it used in computer networks?
n reliable transport service on top of unreliable IP
n reliable data link service on top of unreliable physical layer
10/16/2003 CSC 257/457 - Fall 2003 3
Reliable Data Transfer: An
Illustration
n end-to-end protocol control over unreliable channel n consider only unidirectional data transfer for simplicity
n protocol control data may flow in either direction!
sender receiver reliable data transfer protocol (sending side) reliable data transfer protocol (receiving side)
unreliable channel (error-prone, lossy)
user data user data
user & protocol data user & protocol data
virtual reliable channel application layer transport layer network layer network layer data-link layer physical layer 10/16/2003 CSC 257/457 - Fall 2003 4
Principles of Reliable Data
Transfer
n
Characteristics of unreliable channel will determine
complexity of reliable data transfer protocol
n e.g., delay in the channel is bounded in physical layer, not sofor network layer
n
Other services may interact with RDT protocol
n e.g., flow control, congestion control
n
Here we study the principles of reliable data
transfer, so
n we don’t make assumptions about the unreliable channel n we don’t consider interaction with other services
n
Later we see what RDT is like in practice (in a
10/16/2003 CSC 257/457 - Fall 2003 5
Outline
n
Overview of reliable data transfer
n
a
correct protocol
correct
nstop-and-wait
nan
efficient protocol
efficient
n
sliding window
10/16/2003 CSC 257/457 - Fall 2003 6
Deal with Errors
n
First deal with errors, later deal with packet loss.
nACK-based solution: receiver check errors
n if correct, send back positive ACK n otherwise, send back negative NAK Sender Receiver packet1 packet2 ACK ACK packet3 correct correct Sender Receiver packet1 packet1 NAK ACK packet2 error! correct resend
What if ACK or NAK is corrupted?
Time
What if ACK or NAK is
corrupted?
n Solution 1: creating special acknowledgments for ACK and NAK.
What if they get corrupted too??
n Solution 2: treat a corrupted acknowledgements as NAK.
Duplicated packets!!
n To solve duplicated packets: sequence number for each packet. Sender Receiver packet #0 packet #0 ACK ACK packet #1 correct duplicate ⇒discard corrupted ⇒resend
Deal with Packet Loss: Timeouts
n Early timeout ⇒duplicated packet ⇒sequence number.
(not likely for data link protocol)
Sender Receiver packet #0 packet #0 ACK ACK timeout resend timeout Sender Receiver packet #0 packet #0 ACK ACK timeout resend timeout duplicate ⇒discard
10/16/2003 CSC 257/457 - Fall 2003 9
Deal with Duplicated ACKs
n Solution: each ACK carries sequence number. n With timeout, NAK is not necessary any more.
Sender Receiver packet #0 packet #0 ACK ACK timeout resend timeout duplicate ⇒discard packet #1 10/16/2003 CSC 257/457 - Fall 2003 10
Stop-and-Wait
Now we have a
correct protocol:
correct
Sender Receiver packet #0 packet #1 ACK #0 ACK #1 correct correct Time
n
Allow one outstanding (un-ACKed) packet.
nYou see why it is called
stop-
stop
-and
and-
-wait
wait?
10/16/2003 CSC 257/457 - Fall 2003 11
Efficiency of Stop-and-Wait
first packet bit transmitted, t = 0
sender receiver
RTT last packet bit transmitted, t = L / R
first packet bit arrives last packet bit arrives, send ACK
ACK arrives, send next packet, t = RTT + L / R
Channel utilization efficiency = RTT + L / RL / R
10/16/2003 CSC 257/457 - Fall 2003 12
Efficiency of Stop-and-Wait (An
Example)
n It works, but performance stinks!
n Example: 1 Gbps link, 30ms roundtrip prop. delay, 1KB (8kbits)
packet.
Ttransmit = 1 gb/sec8 kb = 8 microsec
n 266Kps throughput over 1 Gbps link ⇒0.027% efficiency! n network protocol limits use of physical resources!
L (packet length) R (transmission rate) = Throughput = L = 266Kbps Ttransmit + RTT = 8kb 0.03008sec
10/16/2003 CSC 257/457 - Fall 2003 13
Pipelined Protocols
Pipelining: sender allows multiple, “in-flight”,
yet-to-be-acknowledged packets
10/16/2003 CSC 257/457 - Fall 2003 14
Pipelining: Increased Efficiency
first packet bit transmitted, t = 0sender receiver
RTT last bit transmitted, t = L / R
first packet bit arrives last packet bit arrives, send ACK
ACK arrives, send next packet, t = RTT + L / R
last bit of 2ndpacket arrives, send ACK last bit of 3rdpacket arrives, send ACK
Increase utilization by a factor of 3! Channel util efficiency = 3*L / R .000024.030024 = 0.08%
RTT + 3*L / R=
A pipelined protocol:
Sliding Window
n
Allow multiple outstanding (un-ACKed) packets
nUpper bound on un-ACKed packets, called window
Sender Receiver
Time
…
…
Two variations: go-back-N, and selective repeat.
Go-Back-N: Sender
n “window” of up to N consecutive un-ACKed packets allowed; limit
send buffer space
n cumulative ACK – ACK with seq #n stands for ACKs all packets up
to, including seq #n
n recv ACKs in send window ⇒slidingsliding send window n timer for each in-flight packet
10/16/2003 CSC 257/457 - Fall 2003 17
Go-Back-N: Receiver
n
Send ACK for correctly-received packet with highest
in
in
-
-
order
order seq #
nn SlidingSliding receive window n
n
Out
Out
-
-
of
of
-
-
order packet:
order
n Discard (don’t buffer) -> no receiver buffering! n Optional: Re-ACK packet with highest in-order seq #
n alert sender something is wrong through duplicated ACKs n not critical for protocol correctness; but may improve
performance
10/16/2003 CSC 257/457 - Fall 2003 18
GBN in Action
10/16/2003 CSC 257/457 - Fall 2003 19
Selective Repeat
n
receiver individually acknowledges all correctly
received packets. How to deal with out-of-order
packets?
n buffer out-of-order packets for eventual in-order
delivery to upper layer
n
sender timer for each un-ACKed packet
n sender only resends packets whose timers expire
before ACKs are received
10/16/2003 CSC 257/457 - Fall 2003 20
Selective Repeat: Sender,
10/16/2003 CSC 257/457 - Fall 2003 21
Selective Repeat
data from above:
n if next available seq # inwindow, send pkt
timeout(n):
n resend pkt n, restart timer
ACK(n)
in[sendbase, sendbase+N-1]:
n mark pkt n as received n if n smallest unACKed pkt,
advance window base to next unACKed seq # (slidingsliding!)
sender
pkt n
in [rcvbase, rcvbase+N-1] n send ACK(n)n out-of-order: buffer n in-order: deliver (also
deliver buffered, in-order pkts), advance window to next not-yet-received pkt (slidingsliding!)
pkt n
in [rcvbase-N, rcvbase-1] n ACK(n)otherwise:
n ignorereceiver
10/16/2003 CSC 257/457 - Fall 2003 22Selective Repeat in Action
Sequence Number Space
nSeqNum field is finite; sequence numbers wrap
around
n 0, 1, …, S-1, 0, 1, …, S-1, 0, 1, …
n
Sequence number space must be at least as big as
the window size
⇒
S = N
n
Is this enough?
Disclaimer
n