Download presentation
Presentation is loading. Please wait.
1
CPSC 441: Reliable Transport1 Reliable Data Transfer Instructor: Carey Williamson Office: ICT 740 Email: carey@cpsc.ucalgary.cacarey@cpsc.ucalgary.ca Class Location: ICT 122 Lectures: MWF 12:00 – 12:50 Notes derived from “ Computer Networking: A Top Down Approach”, by Jim Kurose and Keith Ross, Addison-Wesley. Slides are adapted from the book’s companion Web site, with changes by Anirban Mahanti and Carey Williamson.
2
CPSC 441: Reliable Transport2 Principles of Reliable Data Transfer r important in application, transport, and link layers r top-10 list of important networking topics! r characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Sending Process Receiving Process Reliable Channel Sending Process Receiving Process Unreliable Channel RDT protocol ( sending side) RDT protocol ( receiving side) Application Layer Network Layer Transport Layer
3
CPSC 441: Reliable Transport3 Reliable Data Transfer: FSMs We’ll: r incrementally develop sender, receiver sides of reliable data transfer protocol (rdt) r consider only unidirectional data transfer m but control info will flow on both directions! r use finite state machines (FSM) to specify sender, receiver state 1 state 2 event causing state transition actions taken on state transition state: when in this “state” next state uniquely determined by next event event actions
4
CPSC 441: Reliable Transport4 Rdt1.0: Data Transfer over a Perfect Channel r underlying channel perfectly reliable m no bit errors m no loss of packets r separate FSMs for sender, receiver: m sender sends data into underlying channel m receiver read data from underlying channel Wait for call from above packet = make_pkt(data) udt_send(packet) rdt_send(data) extract (packet,data) deliver_data(data) Wait for call from below rdt_rcv(packet) sender receiver
5
CPSC 441: Reliable Transport5 Rdt2.0: channel with bit errors [stop & wait protocol] r Assumptions m All packets are received m Packets may be corrupted (i.e., bits may be flipped) m Checksum to detect bit errors r How to recover from errors? Use ARQ mechanism m acknowledgements (ACKs): receiver explicitly tells sender that packet received correctly m negative acknowledgements (NAKs): receiver explicitly tells sender that packet had errors m sender retransmits pkt on receipt of NAK r What about error correcting codes?
6
CPSC 441: Reliable Transport6 rdt2.0: FSM specification Wait for call from above snkpkt = make_pkt(data, checksum) udt_send(sndpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) udt_send(NAK) rdt_rcv(rcvpkt) && corrupt(rcvpkt) Wait for ACK or NAK Wait for call from below sender receiver rdt_send(data)
7
CPSC 441: Reliable Transport7 rdt2.0: Observations Wait for call from above snkpkt = make_pkt(data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for ACK or NAK sender rdt_send(data) 1. A stop-and-Wait protocol 2. What happens when ACK or NAK has bit errors? Approach 1: resend the current data packet? Duplicate packets
8
CPSC 441: Reliable Transport8 Handling Duplicate Packets r sender adds sequence number to each packet r sender retransmits current packet if ACK/NAK garbled r receiver discards (doesn’t deliver up) duplicate packet
9
CPSC 441: Reliable Transport9 rdt2.1: sender, handles garbled ACK/NAKs Wait for call 0 from above sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) rdt_send(data) Wait for ACK or NAK 0 udt_send(sndpkt) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isNAK(rcvpkt) ) sndpkt = make_pkt(1, data, checksum) udt_send(sndpkt) rdt_send(data) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt) udt_send(sndpkt) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isNAK(rcvpkt) ) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt) Wait for call 1 from above Wait for ACK or NAK 1
10
CPSC 441: Reliable Transport10 rdt2.1: receiver, handles garbled ACK/NAKs Wait for 0 from below sndpkt = make_pkt(NAK, chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq0(rcvpkt) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) Wait for 1 from below 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) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq1(rcvpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) sndpkt = make_pkt(NAK, chksum) udt_send(sndpkt)
11
CPSC 441: Reliable Transport11 rtd2.1: examples PKT(0) PKT(1) ACK senderreceiver x Receiver expects a pkt with seq. # 1 Duplicate pkt. senderreceiver PKT(0) ACK PKT(1) NAK PKT(1) ACK PKT(0) x x
12
CPSC 441: Reliable Transport12 rdt2.1: summary Sender: r seq # added to pkt r two seq. #’s (0,1) will suffice. Why? r must check if received ACK/NAK corrupted r twice as many states m state must “remember” whether “current” pkt has 0 or 1 seq. # Receiver: r must check if received packet is duplicate m state indicates whether 0 or 1 is expected pkt seq # r note: receiver can not know if its last ACK/NAK received OK at sender
13
CPSC 441: Reliable Transport13 rdt2.2: a NAK-free protocol r same functionality as rdt2.1, using ACKs only r instead of NAK, receiver sends ACK for last pkt received OK m receiver must explicitly include seq # of pkt being ACKed r duplicate ACK at sender results in same action as NAK: retransmit current pkt
14
CPSC 441: Reliable Transport14 rdt2.2: sender, receiver fragments Wait for call 0 from above sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) rdt_send(data) udt_send(sndpkt) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,1) ) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,0) Wait for ACK 0 sender FSM fragment Wait for 0 from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK1, chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq1(rcvpkt)) udt_send(sndpkt) receiver FSM fragment
15
CPSC 441: Reliable Transport15 rdt3.0:The case of “Lossy” Channels r Assumption: underlying channel can also lose packets (data or ACKs) r Approach: sender waits “reasonable” amount of time for ACK (a Time-Out) m Time-out value? m Possibility of duplicate packets/ACKs? r if pkt (or ACK) just delayed (not lost): m retransmission will be duplicate, but use of seq. #’s already handles this m receiver must specify seq # of pkt being ACKed
16
CPSC 441: Reliable Transport16 rdt3.0 sender sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) start_timer rdt_send(data) Wait for ACK0 rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,1) ) Wait for call 1 from above sndpkt = make_pkt(1, data, checksum) udt_send(sndpkt) start_timer rdt_send(data) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,0) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,0) ) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,1) stop_timer udt_send(sndpkt) start_timer timeout udt_send(sndpkt) start_timer timeout rdt_rcv(rcvpkt) Wait for call 0from above Wait for ACK1 rdt_rcv(rcvpkt)
17
CPSC 441: Reliable Transport17 rdt3.0 in action
18
CPSC 441: Reliable Transport18 rdt3.0 in action
19
CPSC 441: Reliable Transport19 stop-and-wait operation first packet bit transmitted, t = 0 senderreceiver D last packet bit transmitted, t = L / R first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = D + L / R
20
CPSC 441: Reliable Transport20 Pipelining: Motivation r Stop-and-wait allows the sender to only have a single unACKed packet at any time r example: 1 Mbps link (R), end-2-end round trip propagation delay (D) of 92ms, 1KB packet (L): m 1KB pkt every 100 ms -> 80Kbps throughput on a 1 Mbps link m What does bandwidth x delay product tell us? T transmit = 8kb/pkt 10**3 kb/sec = 8 ms L (packet length in bits) R (transmission rate, bps) =
21
CPSC 441: Reliable Transport21 Pipelined protocols r Pipelining: sender allows multiple, “in- flight”, yet-to-be-acknowledged pkts m range of sequence numbers must be increased m buffering at sender and/or receiver r Two generic forms of pipelined protocols m go-Back-N m selective repeat
22
CPSC 441: Reliable Transport22 Pipelining: increased utilization first packet bit transmitted, t = 0 senderreceiver D last bit transmitted, t = L / R first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = D + L / R last bit of 2 nd packet arrives, send ACK last bit of 3 rd packet arrives, send ACK Increase utilization by a factor of 3!
23
CPSC 441: Reliable Transport23 Go-Back-N r Allow up to N unACKed pkts in the network m N is the Window size r Sender Operation: m If window not full, transmit m ACKs are cumulative m On timeout, send all packets previously sent but not yet ACKed. m Uses a single timer – represents the oldest transmitted, but not yet ACKed pkt
24
CPSC 441: Reliable Transport24 GBN: sender extended FSM Wait start_timer udt_send(sndpkt[base]) udt_send(sndpkt[base+1]) … udt_send(sndpkt[nextseqnum-1]) timeout rdt_send(data) if (nextseqnum < base+N) { sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum) udt_send(sndpkt[nextseqnum]) if (base == nextseqnum) start_timer nextseqnum++ } else refuse_data(data) base = getacknum(rcvpkt)+1 If (base == nextseqnum) stop_timer else start_timer rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) base=1 nextseqnum=1 rdt_rcv(rcvpkt) && corrupt(rcvpkt)
25
CPSC 441: Reliable Transport25 GBN: receiver extended FSM ACK-only: always send ACK for correctly-received pkt with highest in-order seq # m may generate duplicate ACKs need only remember expectedseqnum r out-of-order pkt: m discard (don’t buffer) -> no receiver buffering! m Re-ACK pkt with highest in-order seq # Wait udt_send(sndpkt) default rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt,expectedseqnum) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(expectedseqnum,ACK,chksum) udt_send(sndpkt) expectedseqnum++ expectedseqnum=1 sndpkt = make_pkt(expectedseqnum,ACK,chksum)
26
CPSC 441: Reliable Transport26 GBN in action
27
CPSC 441: Reliable Transport27 Selective Repeat r receiver individually acknowledges all correctly received pkts m buffers pkts, as needed, for eventual in-order delivery to upper layer r sender only resends pkts for which ACK not received m sender timer for each unACKed pkt r sender window m N consecutive seq #’s m again limits seq #s of sent, unACKed pkts
28
CPSC 441: Reliable Transport28 Selective repeat: sender, receiver windows
29
CPSC 441: Reliable Transport29 Selective repeat data from above : r if next available seq # in window, send pkt timeout(n): r resend pkt n, restart timer ACK(n) in [sendbase,sendbase+N]: r mark pkt n as received r if n smallest unACKed pkt, advance window base to next unACKed seq # sender pkt n in [rcvbase, rcvbase+N-1] r send ACK(n) r out-of-order: buffer r in-order: deliver (also deliver buffered, in-order pkts), advance window to next not-yet-received pkt pkt n in [rcvbase-N,rcvbase-1] r ACK(n) otherwise: r ignore receiver
30
CPSC 441: Reliable Transport30 Selective Repeat Example 0123 456789 PKT0 PKT1 PKT2 PKT3 ACK0 ACK1 ACK2 ACK30 1234 56789PKT4 0 1234 56789 PKT1 ACK1 ACK4 01234 5678 9 Time-Out Sender Receiver
31
CPSC 441: Reliable Transport31 Another Example
32
CPSC 441: Reliable Transport32 Selective repeat: dilemma Example: r seq #’s: 0, 1, 2, 3 r window size=3 r receiver sees no difference in two scenarios! r incorrectly passes duplicate data as new in (a) Q: what relationship between seq # size and window size?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.