9 Pipelined Protocols and RTT Slides adapted from

  • Slides: 23
Download presentation
9: Pipelined Protocols and RTT Slides adapted from: J. F Kurose and K. W.

9: Pipelined Protocols and RTT Slides adapted from: J. F Kurose and K. W. Ross, 1996 -2010 Transport Layer 3 -1

Stop and Wait v Rdt 3. 0 also called Stop and Wait § Sender

Stop and Wait v Rdt 3. 0 also called Stop and Wait § Sender sends one packet, then waits for receiver response v What is wrong with stop and wait? § Slow!! Must wait full round trip time between each send v Obvious Fix? § Instead send lots, then stop and wait § Call this a pipelined protocol because many packets in the pipeline at the same time 3: Transport Layer 3 a-2

Pipelined protocols Pipelining: sender allows multiple, “in-flight” yet-tobe-acknowledged packets § range of sequence numbers

Pipelined protocols Pipelining: sender allows multiple, “in-flight” yet-tobe-acknowledged packets § range of sequence numbers must be increased to be able to distinguish them all § Additional buffering at sender and/or receiver § Once allow multiple “in-flight” consider that channel may reorder the packets 3: Transport Layer 3 a-3

How bad is Stop and Wait? v v Depends on network conditions example: 1

How bad is Stop and Wait? v v Depends on network conditions example: 1 Gbps link, 15 ms end-to-end prop. delay, 1 KB packet: Ttransmit = Utilization = U = m m r 1 kb = 1 microsec 10**9 b/sec 1 microsec Utilization of the = = 0. 003% channel 30. 001 msec 1 KB pkt every 30 msec -> 33 k. B/sec throughput over 1 Gbps link network protocol limits use of physical resources! In general, smaller packets, longer RTT and higher maximum bandwidth, all make the situation worse 3: Transport Layer 3 a-4

rdt 3. 0: stop-and-wait operation sender receiver first packet bit transmitted, t = 0

rdt 3. 0: stop-and-wait operation sender receiver first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R RTT first packet bit arrives last packet bit arrives, send ACK arrives, send next packet, t = RTT + L / R Transport Layer 3 -5

Pipelining: increased utilization sender receiver first packet bit transmitted, t = 0 last bit

Pipelining: increased utilization sender receiver first packet bit transmitted, t = 0 last bit transmitted, t = L / R RTT ACK arrives, send next packet, t = RTT + L / R first packet bit arrives last packet bit arrives, send ACK 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 with window size of 3 Transport Layer 3 -6

Filling the pipeline How much in-flight data is needed to “fill the pipeline”? v

Filling the pipeline How much in-flight data is needed to “fill the pipeline”? v Similar to question of how much water needed to fill a pipe (area of crosssection * length of pipe) v v For networks, it is bandwidth*delay 3: Transport Layer 3 a-7

Pipelined Protocols Go-back-N: big picture: v sender can have up to N unacked packets

Pipelined Protocols Go-back-N: big picture: v sender can have up to N unacked packets in pipeline v rcvr only sends cumulative acks § doesn’t ack packet if there’s a gap v sender has timer for oldest unacked packet § if timer expires, retransmit all unack’ed packets Selective Repeat: big pic v sender can have up to N unack’ed packets in pipeline v rcvr sends individual ack for each packet v sender maintains timer for each unacked packet § when timer expires, retransmit only unack’ed packet Transport Layer 3 -8

Go-Back-N Sender: v v v k-bit seq # in pkt header “window” of up

Go-Back-N Sender: v v v 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 window of packets timeout(n): retransmit pkt n and all higher seq # pkts in window Transport Layer 3 -9

GBN: sender extended FSM rdt_send(data) L base=1 nextseqnum=1 if (nextseqnum < base+N) { sndpkt[nextseqnum]

GBN: sender extended FSM rdt_send(data) L base=1 nextseqnum=1 if (nextseqnum < base+N) { sndpkt[nextseqnum] = make_pkt(nextseqnum, data, chksum) udt_send(sndpkt[nextseqnum]) if (base == nextseqnum) //one timer per window start_timer nextseqnum++ } else refuse_data(data) //or just block the caller Wait rdt_rcv(rcvpkt) && corrupt(rcvpkt) /*don’t do anything if receiver feedback corrupt */ timeout start_timer //resend all packets in window udt_send(sndpkt[base]) udt_send(sndpkt[base+1]) … udt_send(sndpkt[nextseqnum-1]) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) base = getacknum(rcvpkt)+1 //cummulative ack If (base == nextseqnum) stop_timer //have acked all outstanding else //send any data this allows us room in window to send Transport Layer 3 -10 start_timer //start timer for remaining base to nextseqnum

GBN: receiver extended FSM default udt_send(sndpkt) L Wait expectedseqnum=1 sndpkt = make_pkt(expectedseqnum, ACK, chksum)

GBN: receiver extended FSM default udt_send(sndpkt) L Wait expectedseqnum=1 sndpkt = make_pkt(expectedseqnum, ACK, chksum) rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt, expectedseqnum) extract(rcvpkt, data) deliver_data(data) 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 v out-of-order pkt: § discard (don’t buffer) ->receiver buffering is not required but can help if want to! § Re-ACK pkt with highest in-order seq # Transport Layer 3 -11

GBN in action Loss of one packet (pkt 2) causes retransmissi on of 4

GBN in action Loss of one packet (pkt 2) causes retransmissi on of 4 packets (2 -5) Transport Layer 3 -12

Selective Repeat GBN forces sender to retransmit all packets in window even if some

Selective Repeat GBN forces sender to retransmit all packets in window even if some have been correctly received v To avoid that we need a finer granularity of acknowledgement v § individual acknowledgements vs cumulative acknowledgements 3: Transport Layer 3 a-13

Selective Repeat v receiver individually acknowledges all correctly received pkts § buffers pkts, as

Selective Repeat v receiver individually acknowledges all correctly received pkts § buffers pkts, as needed, for eventual in-order delivery to upper layer v sender only resends pkts for which ACK not received § sender timer for each un. ACKed pkt v sender window § N consecutive seq #’s § again limits seq #s of sent, un. ACK’ed pkts Transport Layer 3 -14

Selective repeat: sender, receiver windows Transport Layer 3 -15

Selective repeat: sender, receiver windows Transport Layer 3 -15

Selective repeat sender data from above : v if next available seq # in

Selective repeat sender data from above : v if next available seq # in window, send pkt timeout(n): v receiver pkt n in [rcvbase, rcvbase+N-1] v v v resend pkt n, restart timer ACK(n) in [sendbase, sendbase+N]: v v mark pkt n as received if n smallest un. ACKed pkt, advance window base to next un. ACKed seq # send ACK(n) out-of-order: buffer in-order: deliver (also deliver buffered, in-order pkts), advance window to next not-yet-received pkt n in v [rcvbase-N, rcvbase-1] ACK(n) otherwise: v ignore Transport Layer 3 -16

Selective repeat in action Loss of one pkt causes retransmission of just that pkt

Selective repeat in action Loss of one pkt causes retransmission of just that pkt Transport Layer 3 -17

Selective Repeat vs GBN Selective Repeat requires individual acknowledgements rather than chance for cumulative

Selective Repeat vs GBN Selective Repeat requires individual acknowledgements rather than chance for cumulative acknowledgements v GBN results in unnecessary retransmission of data correctly received v Sender can choose to buffer out of order and avoid unnecessary retransmission (but not required) – in selective repeat receiver can acknowledge these out of order packets v 3: Transport Layer 3 a-18

Pipelined protocols Sequence Number Dilemma Example: v v v seq #’s: 0, 1, 2,

Pipelined protocols Sequence Number Dilemma Example: v v v seq #’s: 0, 1, 2, 3 window size=3 receiver sees no difference in two scenarios! incorrectly passes duplicate data as new in (a) Similar to the problem we saw in stop and wait until we added seq 0 and 1 3: Transport Layer 3 a-19

Sequence Number Space v v Q: what relationship between seq # size and window

Sequence Number Space v v Q: what relationship between seq # size and window size? A: sequence number space >= 2 * window size § True for Stop and Wait (2 >= 2*1) § need old and new version of every sequence # v v Still one problem, packets could conceivably delayed for arbitrarily long in the network so could get an old packet N even after the sequence number space has wrapped around Solution? Not really. In practice, assume a maximum time a packet could live in the network 3: Transport Layer 3 a-20

TCP? v TCP is most like GBN § But many TCP implementations will buffer

TCP? v TCP is most like GBN § But many TCP implementations will buffer correctly received but of order segments and senders use duplicate acknowledgments to infer which segment dropped. . This is sort of like Selective Repeat v v TCP uses cumulative acknowledgements but counts bytes not packets and receiver ACKS what it wants not last thing it received Window size is not fixed like N in GBN § TCP allows receiver to set a maximum (dynamically) § Effective window size also changed over time in response to signs of congestion in the network v We will discuss TCP specifics next… 3: Transport Layer 3 a-21

Roadmap v Discussed general principles of reliable message delivery over unreliable channel § Lots

Roadmap v Discussed general principles of reliable message delivery over unreliable channel § Lots of it is common sense (like with our flaky fax machine) § But there is a significant degree of subtlety in getting it right! v We are going to move on to talking specifically about TCP § Flow control? Congestion control? v We have most of the tools we need now: receiver feedback, checksums, sequence numbers, cumulative acknowledgments and retransmission timers 3: Transport Layer 3 a-22

Question v Which of the following is true § For a window size of

Question v Which of the following is true § For a window size of 1, you need at least 2 possible sequence numbers. § For a window size of 1, you need at least 2 bits to store the sequence number. § The number of possible sequence numbers must be >= 2* the window size. § The window size must be >= 2* number of possible sequence numbers. Transport Layer 3 -23