0% found this document useful (0 votes)
143 views47 pages

Reliable Data Transfer

The document describes a computer networking class that focuses on reliable data transfer. It provides an overview of the class topics, textbooks, and approach. It then discusses the principles of reliable data transfer and describes how to implement a basic reliable data transfer protocol in increasing levels of complexity to handle unreliable network channels.

Uploaded by

Navan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views47 pages

Reliable Data Transfer

The document describes a computer networking class that focuses on reliable data transfer. It provides an overview of the class topics, textbooks, and approach. It then discusses the principles of reliable data transfer and describes how to implement a basic reliable data transfer protocol in increasing levels of complexity to handle unreliable network channels.

Uploaded by

Navan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Data Communications & Networks

Session 7 – Main Theme


Reliable Data Transfer

Dr. Jean-Claude Franchitti

New York University


Computer Science Department
Courant Institute of Mathematical Sciences

Adapted from course textbook resources


Computer Networking: A Top-Down Approach, 6/E
Copyright 1996-2013
J.F. Kurose and K.W. Ross, All Rights Reserved

1
Agenda

1 Session Overview

2 Reliable Data Transfer

3 Summary and Conclusion

2
What is the class about?

 Course description and syllabus:


» http://www.nyu.edu/classes/jcf/csci-ga.2262-001/
» http://cs.nyu.edu/courses/Fall13/CSCI-GA.2262-
001/index.html

 Textbooks:
» Computer Networking: A Top-Down Approach (6th Edition)
James F. Kurose, Keith W. Ross
Addison Wesley
ISBN-10: 0132856204, ISBN-13: 978-0132856201, 6th Edition (02/24/12)

3
Course Overview

 Computer Networks and the Internet


 Application Layer
 Fundamental Data Structures: queues, ring buffers, finite state machines
 Data Encoding and Transmission
 Local Area Networks and Data Link Control
 Wireless Communications
 Packet Switching
 OSI and Internet Protocol Architecture
 Congestion Control and Flow Control Methods
 Internet Protocols (IP, ARP, UDP, TCP)
 Network (packet) Routing Algorithms (OSPF, Distance Vector)
 IP Multicast
 Sockets

4
Course Approach

 Introduction to Basic Networking Concepts (Network Stack)


 Origins of Naming, Addressing, and Routing (TCP, IP, DNS)
 Physical Communication Layer
 MAC Layer (Ethernet, Bridging)
 Routing Protocols (Link State, Distance Vector)
 Internet Routing (BGP, OSPF, Programmable Routers)
 TCP Basics (Reliable/Unreliable)
 Congestion Control
 QoS, Fair Queuing, and Queuing Theory
 Network Services – Multicast and Unicast
 Extensions to Internet Architecture (NATs, IPv6, Proxies)
 Network Hardware and Software (How to Build Networks, Routers)
 Overlay Networks and Services (How to Implement Network Services)
 Network Firewalls, Network Security, and Enterprise Networks
5
Reliable Data Transfer Session in Brief

 Principles of Reliable Data Transfer


 Reliable Data Transfer: Getting Started
 Reliable Data Transfer: Operational Details
 Other Reliable Data Transfer Protocols
 Conclusion

6
Icons / Metaphors

Information

Common Realization

Knowledge/Competency Pattern

Governance

Alignment

Solution Approach

77
Agenda

1 Session Overview

2 Reliable Data Transfer

3 Summary and Conclusion

8
Reliable Data Transfer Session in Brief

 Principles of Reliable Data Transfer


 Reliable Data Transfer: Getting Started
 Reliable Data Transfer: Operational Details
 Other Reliable Data Transfer Protocols

9
Principles of Reliable Data Transfer

 Important in app., transport, link layers


 Top-10 list of important networking topics!

 Characteristics of unreliable channel will determine


complexity of reliable data transfer protocol (rdt)
10
Reliable Data Transfer Session in Brief

 Principles of Reliable Data Transfer


 Reliable Data Transfer: Getting Started
 Reliable Data Transfer: Operational Details
 Other Reliable Data Transfer Protocols

11
Reliable Data Transfer: Getting Started

rdt_send(): called from above, deliver_data(): called by


(e.g., by app.). Passed data to rdt to deliver data to upper
deliver to receiver upper layer

send receive
side side

udt_send(): called by rdt, rdt_rcv(): called when packet


to transfer packet over arrives on rcv-side of channel
unreliable channel to receiver

12
Reliable Data Transfer: Getting Started

We’ll:
 Incrementally develop sender, receiver sides of reliable
data transfer protocol (rdt)
 Consider only unidirectional data transfer
 But control info will flow on both directions!
 Use finite state machines (FSM) to specify sender,
receiver event causing state transition
actions taken on state transition
state: when in this
state state
“state” next state event
1 2
uniquely actions
determined by next
event
13
Reliable Data Transfer Session in Brief

 Principles of Reliable Data Transfer


 Reliable Data Transfer: Getting Started
 Reliable Data Transfer: Operational Details
 Other Reliable Data Transfer Protocols

14
Rdt1.0 - Reliable Transfer Over a Reliable Channel

 Underlying channel perfectly reliable


 No bit errors
 No loss of packets
 Separate FSMs for sender, receiver:
 Sender sends data into underlying channel
 Receiver read data from underlying channel

Wait for rdt_send(data) Wait for rdt_rcv(packet)


call from call from extract (packet,data)
above packet = make_pkt(data) below deliver_data(data)
udt_send(packet)

sender receiver
15
Rdt2.0: Channel with Bit Errors

 Underlying channel may flip bits in packet


 Checksum to detect bit errors
 The question: how to recover from errors:
 Acknowledgements (ACKs): receiver explicitly tells sender that
pkt received OK
 Negative acknowledgements (NAKs): receiver explicitly tells
sender that pkt had errors
 Sender retransmits pkt on receipt of NAK
 New mechanisms in rdt2.0 (beyond rdt1.0):
 Error detection
 Receiver feedback: control msgs (ACK,NAK) rcvr->sender

16
Rdt2.0: FSM Specification

rdt_send(data)
snkpkt = make_pkt(data, checksum) receiver
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)

rdt_rcv(rcvpkt) && isACK(rcvpkt)


Wait for
L
call from
sender below

rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)

17
Rdt2.0: Operation with No Error

rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)

rdt_rcv(rcvpkt) && isACK(rcvpkt)


Wait for
L call from
below

rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)

18
Rdt2.0: Error Scenario

rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)

rdt_rcv(rcvpkt) && isACK(rcvpkt)


Wait for
L call from
below

rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)

19
Rdt 2.0 Has a Fatal Flaw!

What happens if Handling duplicates:


ACK/NAK corrupted?  Sender retransmits current
 Sender doesn’t know what pkt if ACK/NAK garbled
happened at receiver!  Sender adds sequence
 Can’t just retransmit: number to each pkt
possible duplicate  Receiver discards (doesn’t
deliver up) duplicate pkt
stop and wait
Sender sends one packet,
then waits for receiver
response

20
Rdt2.1: Sender Handles Garbled ACK/NAKs

rdt_send(data)
sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt) rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) ||
Wait for Wait for
ACK or
isNAK(rcvpkt) )
call 0 from
NAK 0 udt_send(sndpkt)
above
rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt) rdt_rcv(rcvpkt)
&& isACK(rcvpkt) && notcorrupt(rcvpkt)
&& isACK(rcvpkt)
L
L
Wait for Wait for
ACK or call 1 from
rdt_rcv(rcvpkt) && NAK 1 above
( corrupt(rcvpkt) ||
isNAK(rcvpkt) ) rdt_send(data)

udt_send(sndpkt) sndpkt = make_pkt(1, data, checksum)


udt_send(sndpkt)

21
Rdt2.1: Receiver Handles Garbled ACK/NAKs

rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)


&& has_seq0(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt)
sndpkt = make_pkt(NAK, chksum) sndpkt = make_pkt(NAK, chksum)
udt_send(sndpkt) udt_send(sndpkt)
Wait for Wait for
rdt_rcv(rcvpkt) && 0 from 1 from rdt_rcv(rcvpkt) &&
not corrupt(rcvpkt) && below below not corrupt(rcvpkt) &&
has_seq1(rcvpkt) has_seq0(rcvpkt)
sndpkt = make_pkt(ACK, chksum) sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt) udt_send(sndpkt)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq1(rcvpkt)

extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)

22
Rdt 2.1: Discussion

Sender: Receiver:
 Seq # added to pkt  Must check if received
 Two seq. #’s (0,1) will packet is duplicate
suffice. Why? » State indicates whether
0 or 1 is expected pkt
 Must check if received seq #
ACK/NAK corrupted
 Note: receiver can not
 Twice as many states know if its last
» state must “remember” ACK/NAK received OK
whether “current” pkt
has 0 or 1 seq. #
at sender

23
Rdt2.2: A NAK-Free Protocol

 Same functionality as rdt2.1, using ACKs only


 Instead of NAK, receiver sends ACK for last pkt
received OK
 Receiver must explicitly include seq # of pkt being
ACKed
 Duplicate ACK at sender results in same action
as NAK: retransmit current pkt

24
Rdt2.2: Sender, Receiver Fragments

rdt_send(data)
sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) ||
Wait for Wait for
ACK isACK(rcvpkt,1) )
call 0 from
above 0 udt_send(sndpkt)
sender FSM
fragment rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) && && isACK(rcvpkt,0)
(corrupt(rcvpkt) || L
has_seq1(rcvpkt)) Wait for receiver FSM
0 from
udt_send(sndpkt) below fragment
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq1(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK1, chksum)
udt_send(sndpkt)
25
Rdt 3.0: Channels with Errors and Loss

New Assumption: Approach: sender waits


 Underlying channel can “reasonable” amount of
also lose packets (data or time for ACK
 Retransmits if no ACK
ACKs)
received in this time
» checksum, seq. #, ACKs,
retransmissions will be of  If pkt (or ACK) just
help, but not enough delayed (not lost):
» Retransmission will be
duplicate, but use of seq. #’s
already handles this
» Receiver must specify seq #
of pkt being ACKed
 Requires countdown timer

26
Rdt3.0: Sender

rdt_send(data)
rdt_rcv(rcvpkt) &&
sndpkt = make_pkt(0, data, checksum) ( corrupt(rcvpkt) ||
udt_send(sndpkt) isACK(rcvpkt,1) )
rdt_rcv(rcvpkt) start_timer L
L Wait for Wait
for timeout
call 0from
ACK0 udt_send(sndpkt)
above
start_timer
rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt) rdt_rcv(rcvpkt)
&& isACK(rcvpkt,1) && notcorrupt(rcvpkt)
stop_timer && isACK(rcvpkt,0)
stop_timer
Wait Wait for
timeout for call 1 from
udt_send(sndpkt) ACK1 above
start_timer rdt_rcv(rcvpkt)
rdt_send(data) L
rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) || sndpkt = make_pkt(1, data, checksum)
isACK(rcvpkt,0) ) udt_send(sndpkt)
start_timer
L

27
Rdt3.0 in Action

28
Rdt3.0 in Action

29
Performance of Rdt 3.0

 Rdt3.0 works, but performance stinks


 Example: 1 Gbps link, 15 ms e-e prop. delay,
1KB packet:
Ttransmit = L (packet length in bits) 8kb/pkt
= = 8 microsec
R (transmission rate, bps) 10**9 b/sec

» U sender: utilization – fraction of time sender busy


sending
U L/R .008
sender
= = = 0.00027
RTT + L / R 30.008 microsec
onds
» 1KB pkt every 30 msec -> 33kB/sec thruput over 1
Gbps link
» network protocol limits use of physical resources!
30
Rdt 3.0: Stop-and-Wait Operation

sender receiver
first packet bit transmitted, t = 0
last packet bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send ACK

ACK arrives, send next


packet, t = RTT + L / R

U L/R .008
sender
= = = 0.00027
RTT + L / R 30.008 microsec
onds

31
Reliable Data Transfer Session in Brief

 Principles of Reliable Data Transfer


 Reliable Data Transfer: Getting Started
 Reliable Data Transfer: Operational Details
 Other Reliable Data Transfer Protocols
 Conclusion

32
Pipelined Protocols

Pipelining: sender allows multiple, “in-flight”, yet-to-


be-acknowledged pkts
 Range of sequence numbers must be increased
 Buffering at sender and/or receiver

 Two generic forms of pipelined protocols: go-Back-N,


selective repeat
33
Pipelining: Increased Utilization

sender receiver
first packet bit transmitted, t = 0
last bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send ACK
last bit of 2nd packet arrives, send ACK
last bit of 3rd packet arrives, send ACK
ACK arrives, send next
packet, t = RTT + L / R

Increase utilization
by a factor of 3!

U 3*L/R .024
sender
= = = 0.0008
RTT + L / R 30.008 microsecon
ds

34
Go-Back-N

Sender:
 k-bit seq # in pkt header
 “window” of up to N, consecutive unack’ed pkts allowed

 ACK(n): ACKs all pkts up to, including seq # n - “cumulative


ACK”
 May receive duplicate ACKs (see receiver)
 Timer for each in-flight pkt
 timeout(n): retransmit pkt n and all higher seq # pkts in
window 35
GBN: Sender Extended FSM

rdt_send(data)
if (nextseqnum < base+N) {
sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum)
udt_send(sndpkt[nextseqnum])
if (base == nextseqnum)
start_timer
nextseqnum++
}
L else
refuse_data(data)
base=1
nextseqnum=1
timeout
start_timer
Wait
udt_send(sndpkt[base])
rdt_rcv(rcvpkt) udt_send(sndpkt[base+1])
&& corrupt(rcvpkt) …
udt_send(sndpkt[nextseqnum-1])
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
base = getacknum(rcvpkt)+1
If (base == nextseqnum)
stop_timer
else
start_timer
36
GBN: Receiver Extended FSM

default
udt_send(sndpkt) rdt_rcv(rcvpkt)
&& notcurrupt(rcvpkt)
L && hasseqnum(rcvpkt,expectedseqnum)
expectedseqnum=1 Wait extract(rcvpkt,data)
sndpkt = deliver_data(data)
make_pkt(expectedseqnum,ACK,chksum) sndpkt = make_pkt(expectedseqnum,ACK,chksum)
udt_send(sndpkt)
expectedseqnum++

 ACK-only: always send ACK for correctly-received pkt


with highest in-order seq #
 May generate duplicate ACKs
 Need only remember expectedseqnum
 Out-of-order pkt:
 Discard (don’t buffer) -> no receiver buffering!
 Re-ACK pkt with highest in-order seq #
37
GBN In Action

38
Selective Repeat

 Receiver individually acknowledges all correctly


received pkts
 Buffers pkts, as needed, for eventual in-order delivery
to upper layer
 Sender only resends pkts for which ACK not
received
 Sender timer for each unACKed pkt
 Sender window
 N consecutive seq #’s
 Again limits seq #s of sent, unACKed pkts

39
Selective Repeat: Sender, Receiver Windows

40
Selective Repeat

sender receiver
Data from above: Pkt n in [rcvbase, rcvbase+N-
 If next available seq # in 1]
window, send pkt  Send ACK(n)
Timeout(n):  Out-of-order: buffer
 Resend pkt n, restart  In-order: deliver (also
timer
deliver buffered, in-
ACK(n) in order pkts), advance
[sendbase,sendbase+N]:
window to next not-yet-
 Mark pkt n as received received pkt
 If n smallest unACKed
pkt, advance window Pkt n in [rcvbase-N,rcvbase-1]
base to next unACKed  ACK(n)
seq #
Otherwise:
 Ignore
41
Selective Repeat in Action

42
Selective Repeat: Dilemma

 Example:
 Seq #’s: 0, 1, 2, 3
 Window size=3
 Receiver sees no difference
in two scenarios!
 Incorrectly passes duplicate
data as new in (a)
 Q: what relationship
between seq # size and
window size?

43
Agenda

1 Session Overview

2 Reliable Data Transfer

3 Summary and Conclusion

44
Summary

 Principles of Reliable Data Transfer


 Reliable Data Transfer: Getting Started
 Reliable Data Transfer: Operational Details
 Other Reliable Data Transfer Protocols

45
Assignments & Readings

 Readings
» Chapter 3 (sections 3.1-3.4)
 Assignment #6

46
Next Session: Networks - Part I

47

You might also like