Transport Layer: Part II Efficient Reliable Data Transfer Protocols Go-Back-N and Selective Repeat Round Trip Time Estimation Flow Control Congestion Control Readings: Sessions 3.4-3.7, Lecture Notes CSci4211: Transport Layer: Part II 1
Recall: Simple Reliable Data Transfer Protocol • “ Stop-and-Wait ” Protocol – also called Alternating Bit Protocol • Sender: – i) send data segment (n bytes) w/ seq =x • buffer data segment, set timer, retransmit if time out – ii) wait for ACK w/ack = x+n; if received, set x:=x+n, go to i) • retransmit if ACK w/ “ incorrect ” ack no. received • Receiver: – i) expect data segment w/ seq =x; if received, send ACK w/ ack=x+n, set x:=x+n, go to i) • if data segment w/ “ incorrect ” seq no received, discard data segment, and retransmit ACK. CSci4211: Transport Layer: Part II 2
Problem with Stop & Wait Protocol Sender Receiver first packet bit transmitted, t = 0 first packet bit RTT arrives ACK arrives, send next packet, t = RTT + L / R • Can ’ t keep the pipe full – Utilization is low when bandwidth-delay product (R x RTT)is large! CSci4211: Transport Layer: Part II 3
Stop & Wait: Performance Analysis Example: 1 Gbps connection, 15 ms end-end prop. delay, data segment size: 1 KB = 8Kb L (packet length in bits) 8 kb T transmit 9 (transmiss ion rate, bps) 10 b/s R 6 8 10 s 0 . 008 ms / . 008 L R L U 0 . 00027 sender RTT L / R RTT * R L 30 . 008 – U sender : utilization, i.e., fraction of time sender busy sending – 1KB data segment every 30 msec (round trip time) --> 0.027% x 1 Gbps = 33kB/sec throughput over 1 Gbps link Moral of story: network protocol limits use of physical resources! CSci4211: Transport Layer: Part II 4
Pipelined Protocols Pipelining: sender allows multiple, “ in-flight ” , yet- to-be-acknowledged data segments – range of sequence numbers must be increased – buffering at sender and/or receiver • Two generic forms of pipelined protocols: Go-Back-N and Selective Repeat CSci4211: Transport Layer: Part II 5
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 2 nd packet arrives, send ACK last bit of 3 rd packet arrives, send ACK ACK arrives, send next packet, t = RTT + L / R Increase utilization by a factor of 3! 3 * L / R . 024 U = 0.0008 = = sender 30.008 RTT + L / R microsecon CSci4211: Transport Layer: Part II 6
Go-Back-N: Basic Ideas Sender: • Packets transmitted continually (when available) without waiting for ACK, up to N outstanding, unACK ’ ed packets • A logically different timer associated with each “ in- flight ” (i.e., unACK ’ ed) packet • timeout(n): retransmit pkt n and all higher seq # pkts in window Receiver: • ACK packet if corrected received and in-order, pass to higher layer, NACK or ignore corrupted or out-of-order packets • “ cumulative ” ACK: if multiple packets received corrected and in-order, send only one ACK with ack= next expected seq no. CSci4211: Transport Layer: Part II 7
Go-Back-N: Sliding Windows Sender: “ window ” of up to N, consecutive unack ’ ed pkts allowed • • send_base: first sent but unACKed pkt, move forward when ACK ’ ed expected, not received yet may be received (and can be buffered, but not ACK ’ ed) Receiver: rcv_base • rcv_base: keep track of next expected seq no, move forward when next in-order (i.e., w/ expected seq no) pkt received CSci4211: Transport Layer: Part II 8
GBN in Action CSci4211: Transport Layer: Part II 9
Selective Repeat • As in Go-Back-N – Packet sent when available up to window limit • Unlike Go-Back-N – Out-of-order (but otherwise correct) is ACKed – Receiver: buffer out-of-order pkts, no “ cumulative ” ACKs – Sender: on timeout of packet k, retransmit just pkt k • Comments – Can require more receiver buffering than Go-Back-N – More complicated buffer management by both sides – Save bandwidth • no need to retransmit correctly received packets CSci4211: Transport Layer: Part II 10
Selective Repeat: Sliding Windows CSci4211: Transport Layer: Part II 11
Selective Repeat: Algorithms receiver sender pkt n in [rcvbase, rcvbase+N-1] data from above : • send ACK(n) • out-of-order: buffer • if next available seq # in window, send pkt • in-order: deliver (also deliver buffered, in-order timeout(n): pkts), advance window to • resend pkt n, restart timer next not-yet-received pkt ACK(n) in [sendbase,sendbase+N]: pkt n in [rcvbase-N,rcvbase-1] • mark pkt n as received • ACK(n) • if n smallest unACKed pkt, otherwise: advance window base to • ignore next unACKed seq # CSci4211: Transport Layer: Part II 12
Selective Repeat in Action CSci4211: Transport Layer: Part II 13
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? CSci4211: Transport Layer: Part II 14
Seqno Space and Window Size • How big the sliding window can be? – MAXSEQNO: number of available sequence numbers – Under Go-Back-N? • MAXSEQNO will not work, why? – What about Selective-Repeat? CSci4211: Transport Layer: Part II 15
TCP Reliable Data Transfer • TCP creates reliable • Retransmissions are data transfer service triggered by: on top of IP ’ s – timeout events unreliable service – duplicate acks • Pipelined segments • Initially consider • Cumulative ACKs simplified TCP sender: – ignore duplicate acks • TCP uses single retransmission timer – ignore flow control, congestion control CSci4211: Transport Layer: Part II 16
TCP Sender Events: data rcvd from app: timeout: • Create segment with • retransmit segment seq # that caused timeout • seq # is byte-stream • restart timer number of first data ACK received: byte in segment • If acknowledges • start timer if not already running (think previously unACKed of timer as for oldest segments, then unacked segment) – update what is known to • expiration interval: be ACKed – start timer if there are TimeOutInterval outstanding segments CSci4211: Transport Layer: Part II 17
TCP ACK generation [RFC 1122, RFC 2581] Event at Receiver TCP Receiver Action Arrival of in-order segment with Delayed ACK. Wait up to 500ms expected seq #. All data up to for next segment. If no next segment, expected seq # already ACKed send ACK Arrival of in-order segment with Immediately send single cumulative expected seq #. One other ACK, ACKing both in-order segments segment has ACK pending Arrival of out-of-order segment Immediately send duplicate ACK, higher-than-expect seq. # . indicating seq. # of next expected byte Gap detected Arrival of segment that Immediate send ACK, provided that partially or completely fills gap segment starts at lower end of gap CSci4211: Transport Layer: Part II 18
TCP Round Trip Time and Timeout Q: how to estimate RTT? Q: how to set TCP timeout value? • SampleRTT : measured time from segment transmission • longer than RTT until ACK receipt – but RTT varies – ignore retransmissions, • too short: why? premature timeout • SampleRTT will vary, want – unnecessary estimated RTT “ smoother ” retransmissions – average several recent • too long: slow measurements, not just reaction to segment current SampleRTT loss CSci4211: Transport Layer: Part II 19
TCP Round Trip Time Estimation a EstimatedRTT = (1- )*EstimatedRTT + a *SampleRTT • Exponential weighted moving average • influence of past sample decreases exponentially fast • typical value: = 0.125 a Setting the timeout interval • EstimtedRTT plus “ safety margin ” – large variation in EstimatedRTT -> larger safety margin “ safety margin ” : accommodate variations in estimatedRTT • b b DevRTT = (1- )*DevRTT + *|SampleRTT-EstimatedRTT| b (typically, = 0.25) TimeoutInterval = EstimatedRTT + 4*DevRTT CSci4211: Transport Layer: Part II 20
Example RTT Estimation: RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 350 300 250 RTT (milliseconds) 200 150 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) SampleRTT Estimated RTT CSci4211: Transport Layer: Part II 21
TCP Flow Control flow control • receive side of TCP sender won ’ t overflow connection has a receiver ’ s buffer by receive buffer: transmitting too much, too fast • speed-matching service: matching the send rate to the receiving app ’ s drain rate • app process may be slow at reading from buffer CSci4211: Transport Layer: Part II 22
TCP Flow Control: How It Works • Rcvr advertises spare room by including value of RcvWindow in segments • Sender limits unACKed data to RcvWindow (Suppose TCP receiver discards out-of-order – guarantees receive buffer doesn ’ t overflow segments) • spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] CSci4211: Transport Layer: Part II 23
Recommend
More recommend