TCP Early TCP window size adjustment controlled only

  • Slides: 15
Download presentation
TCP • Early TCP: • window size adjustment controlled only by receiver’s advertised window

TCP • Early TCP: • window size adjustment controlled only by receiver’s advertised window • Retransmission timeout value based on a simple RTT • October 1986 Internet suffered a series of congestion collapses (a factor of 1000 drop in throughput). 1

TCP • Researcher’s wondered if TCP could be improved to avoid this. • Enhancements

TCP • Researcher’s wondered if TCP could be improved to avoid this. • Enhancements with the 1988 TCP/Tahoe BSD release: • Slow-start (additive increase) • Multiplicative decrease • Round trip time variance estimation • RTO algorithms (Karn’s algorithm) • Congestion avoidance • Two more enhancements added in TCP/Reno: • fast retransmit • fast recovery • Other enhancements (to be discussed later): • Selective Repeat: TCP/SACK • Enhanced loss recovery (TCP/New. Reno) • Explicit Congestion Notification (ECN) 2

TCP • The essence of these changes: TCP should obey the ‘conservation of packets’

TCP • The essence of these changes: TCP should obey the ‘conservation of packets’ principle: A new packet is not inserted into the network until an old packet leaves • If a TCP connection reaches ‘equilibrium’ (I. e. , running stably with a full window) then congestion collapse would be the exception rather than the rule • Three ways for packet conservation to fail: • The connection doesn’t get to equilibrium (maybe not enough application data). (SLOW START) • A sender injects a new packet before an old has exited. (ACCURATE RTO VALUE) • The equilibrium can’t be reached because of resource limits along the path. (CONGESTION AVOIDANCE) 3

First hop (fast) Sener starts with a burst Subsequent transmissions ‘metered’ by arriving acks

First hop (fast) Sener starts with a burst Subsequent transmissions ‘metered’ by arriving acks (which arrive at a frequency reflective of the transmission time over the bottleneck link). Second hop (slow) 1 2 3 4 1 Transmission time over a slow link 2 5 3 6 4 7 5 8 6 7 8 So what is ‘self clocking’? 4

TCP • Getting to Equilibrium: Slow-start (1) • A TCP sender uses acks as

TCP • Getting to Equilibrium: Slow-start (1) • A TCP sender uses acks as a clock (‘self clocking’). • Self clocking systems automatically adjust to bandwidth and delay variations • Slow-start is used to get to equilibrium quickly • Algorithm adds 1 new variable (cwnd), 3 lines of code at the sender • congestion window (cwnd) • When starting or restarting after a timeout, set cwnd = 1 • On each ack for new data, increase cwnd by 1 • The send window will therefore be the minimum of the receiver’s advertised window and the cwnd 5

TCP snd_wnd cwnd rx_wnd 1 2 3 4 5 6 7 8 16 16

TCP snd_wnd cwnd rx_wnd 1 2 3 4 5 6 7 8 16 16 number of datagrams in flight (flightsize) 1 2 4 8 Slow start increases the window exponentially because the window can double each RTT. Note: we show the window updates in segments rather than in segment byte counts. 6

TCP • Optimal Retransmit Calculation • Problem: If the sender retransmits too frequently (and

TCP • Optimal Retransmit Calculation • Problem: If the sender retransmits too frequently (and therefore incorrectly) it prevents fails the conservation of packets principle • However delaying too long before retransmitting leads to poor performance • Retransmission decision must be based on an accurate RTT calculation • Original RTT algorithm: • R = (alpha) * R + (1 -alpha) M where R is avg RTT estimate and M is the latest RTT sample • RTO = beta * R where beta accounts for RTT variation (suggested value is 2) • Van Jacobson improves the RTO calculation by estimating and including the observed variance associated with the RTT samples • The result: TCP uses an adaptive retransmission algorithm that monitors delays on each connection and adjusts the timeout parameters accordingly 7

TCP • Further problem with obtaining an accurate RTT: TCP Acks are cumulative and

TCP • Further problem with obtaining an accurate RTT: TCP Acks are cumulative and therefore ambiguous • Solution: Karn’s algorithm: Only compute an RTT sample for segments that are NOT retransmitted 8

TCP • Yet another RTT calculation problem (3): • The RTO might not be

TCP • Yet another RTT calculation problem (3): • The RTO might not be correct if the calculation ignores retransmitted segments • Solution: Karn’s exponential backoff algorithm • When a timeout occurs, exponentially increase the RTO value as follows: • RTO = { alpha * old. RTO, Max_RTO } for alpha >1 • Typical: alpha = 2, max RTO = 64 seconds 9

TCP • If timers are in good shape, it is possible to state with

TCP • If timers are in good shape, it is possible to state with some confidence that a timeout indicates a lost packet. TCP reacts by moving to slow start • However, a TCP Timeout is quite large (min of 1. 5 seconds) • slow start represents exponential send rate growth • Can TCP behave differently to reduce the frequency of timeouts? • Congestion Avoidance!!! • Another indicator of packet loss: arrival of duplicate ACKs • Can TCP make use of this to avoid an expensive timeout ? • Fast retransmit, fast recovery!!! • Congestion avoidance algorithms attempt to avoid timeouts while still reacting to evidence of network congestion 10

TCP: SS and Congestion Avoidance • Combined slow start and congestion avoidance algorithm (Tahoe)

TCP: SS and Congestion Avoidance • Combined slow start and congestion avoidance algorithm (Tahoe) • Create a second state variable, ssthresh, to switch between the two algorithms • Assume the wnd = min(cwnd, adverstised window) • On a timeout ssthresh = wnd / 2 (min value of 2 segments) cwnd = 1 • When a new ACK arrives if (cwnd <= ssthresh) /*open the window exponentially */ cwnd += 1; else /*otherwise do Congestion Avoidance- increment linearly */ cwnd += 1/cwnd; Note: In class we will assume that the cwnd and ssthresh are integers and in units of MSS segments. In an actual implementation, these variables are maintained as byte counts. 11

TCP • Fast Retransmit: • If three or more duplicate ACKs arrive at a

TCP • Fast Retransmit: • If three or more duplicate ACKs arrive at a sender, this is a strong indicator that a packet was dropped • The sender retransmits without waiting for the retransmit timer • Fast Recovery: After a fast retransmit, the sender goes to congestion avoidance rather than slow-start • Enhanced algorithm: • When dup#1 and dup#2 arrives, DO NOT increment the cwnd • When the third duplicate ACK is received set ssthresh = cwnd/2 but must be at least 2 segs retransmit the segment set cwnd = ssthresh + 3 packets • For each additional duplicate ACK (after the third duplicate ACK), increment cwnd by 1 and transmit a new packet (if allowed by the new cwnd value) • When the next ACK arrives that acknowledges new data, set cwnd to ssthresh • On a timeout, ssthresh=cwnd/2 and cwnd=1 12

wnd cwnd ssthresh 1 1 2 2 3 3 4 4 64 64 1

wnd cwnd ssthresh 1 1 2 2 3 3 4 4 64 64 1 Assume the receiver ACKs every segment (I. e. , no delayed ACK) 2 3 64 64 4 -7 Assume the receiver’s advertised window is always 8 segments #9 dropped ? ? ? 13

wnd 1 cwnd 1 ssthresh 64 Rx Adv wnd Ack# 8 1 2 2

wnd 1 cwnd 1 ssthresh 64 Rx Adv wnd Ack# 8 1 2 2 64 8 2 3 4 64 64 8 8 3 4 5 6 7 8 64 64 8 8 5 6 7 8 8 9 64 8 Once the first Ack for seg 8 arrives, should the sender send a new segment? 9 2 3 4 5 6 7 8 ? ? #9 dropped 10. . 15 ? 16 Highest SNUM sent - last ack’ed seg = 15 8 = 7 and this is less than the wnd so the sender can send 1 segment !! How about when the first dup arrives ? 16 - 8 = 8 so can not send since wnd is 8 14

wnd cwnd ssthresh Rx Adv wnd Ack# 8 #9 dropped 10 11 12 Is

wnd cwnd ssthresh Rx Adv wnd Ack# 8 #9 dropped 10 11 12 Is highest SNUM - last seg ACKed < window ? (15 - 8 = 7 < 8) so transmit 1 segment. 13 14 15 8 Cwnd does not 8 increase when the first 2 dups arrive. 8 7 9 64 8 9 (4+3) 9/2 = 4 8 9 ? ? 16 Why add 3 segments? Because when the 3 rd duplicate ack arrives, 3 segments have left the network. 8 8 9 10 4 4 4 8 8 8 9 9 9 8 11 4 8 9 4 4 4 8 17 5 4 5 (5. 2) 4 5 (5. 4) 4 5 (5. 58) 4 8 8 18 19 20 21 5 5 9 ? 17 18 19 20 21 -22 23 -25 15