Presentation is loading. Please wait.

Presentation is loading. Please wait.

TCP Tutorial - Part III -

Similar presentations


Presentation on theme: "TCP Tutorial - Part III -"— Presentation transcript:

1 TCP Tutorial - Part III -
Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution 2.5 License

2 TCP Flow Control Computer Network

3 Sliding Window Revisited
Sending application Receiving application TCP TCP LastByteWritten LastByteRead LastByteAcked LastByteSent NextByteExpected LastByteRcvd (a) (b) Sending side LastByteAcked ≤ LastByteSent LastByteSent ≤ LastByteWritten buffer bytes between LastByteAcked and LastByteWritten Receiving side LastByteRead < NextByteExpected NextByteExpected ≤ LastByteRcvd + 1 buffer bytes between LastByteRead and LastByteRcvd Computer Network

4 TCP Flow Control Send buffer size: SendBuffer
Receive buffer size: RcvBuffer Receiving side LastByteRcvd - LastByteRead ≤ RcvBuffer AdvertisedWindow = RcvBuffer - (LastByteRcvd - LastByteRead) Sending side LastByteSent - LastByteAcked ≤ AdvertisedWindow EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked) LastByteWritten - LastByteAcked ≤ SendBuffer block sender if tries to write y bytes but (LastByteWritten - LastByteAcked) + y > SenderBuffer Always send ACK in response to arriving data segment Computer Network

5 TCP Flow Control TCP sender has a ‘SendBuffer’
LastByteSent - LastByteAcked ≤ AdvertisedWindow block sender if tries to send the next segment but (LastByteSent - LastByteAcked) + thee next sgement size > AdvertisedWindow LastByteWritten – LastByteAcked ≤ SendBuffer block sender if tries to write y bytes but (LastByteWritten - LastByteAcked) + y > SenderBuffer EffectiveWindow LastByteWritten AdvertisedWindow (from receiver) Sent but not acked Not yet sent Sequence numbers SendBuffer LastByteAcked LastByteSent Computer Network

6 TCP Flow Control flow control TCP receiver has a “RcvBuffer”:
sender won’t overflow receiver’s buffer by transmitting too much, too fast flow control TCP receiver has a “RcvBuffer”: LastByteRead RcvBuffer (possible window) ACKed but not delivered to user recv’d but not ACKed Sequence numbers missing data AdvertisedWindow NextByteExpected LastByteRcvd Application process may be slow at reading from buffer speed-matching service: matching the send rate to the receiving app’s drain rate Receiver advertises spare room by including value of “window sizes” in segments Computer Network

7 Window Advertisement Issues
Persist when AdvertisedWindow = 0 send a segment with 1 byte of data every so often which triggers a response that contains the current advertised window (eventually nonzero) Flow Control can limit Throughput Let rtt be the round-trip time, i.e., the time from sending a segment until an acknowledgement (ACK) is received Let t = wnd/b be the time to transmit a full “window” of data, where b is link bandwidth Throughput is wnd/rtt Sender Receiver t rtt wnd bytes Computer Network

8 TCP Congestion Control
Computer Network

9 TCP Congestion Control
informally: “too many sources sending too much data too fast for network to handle” different from flow control! manifestations: long delays (queueing in router buffers) lost packets (buffer overflow at routers) Computer Network

10 TCP Congestion Control
Flow Control vs. Congestion Control Src Dest Limits amount of data that destination must buffer Src Dest Attempts to reduce buffer overflow inside the network Computer Network

11 Congestion Collapse 10 Mbps 1.5 Mbps
If both sources send full speed, the router is completely overwhelmed congestion collapse: senders lose data from congestion and they resend, causing more congestion (can be self-reinforcing) has been observed many times Computer Network

12 Basic Rule Basic Rule End-to-end congestion control
IP layer provides no explicit feedback regarding network congestion There is no (or little) congestion  TCP sender increases its send rate There is congestion along the path  TCP sender reduces its send rate Computer Network

13 Basic Rule Window Size Determination What does flow control do?
avoids overrunning the receiver What does congestion control do? avoid overrunning router buffers; avoid saturating the network Congestion Window (=cwin) It imposes a constraint on the rate at which a TCP sender can send traffic into the network cwnd It is what the network can handle flow control window (wnd) It is what the receiver can handle Computer Network

14 Basic Rule Window Size Determination What mechanism do we use?
both use windows [flow control] wnd (=AdvertisedWindow) [congestion control] cwnd actual window used is the MIN of wnd and cwnd Dynamic Window Size (version 1.0) : Windows Size = min{cwin, wnd} Computer Network

15 TCP Congestion Principals
underlying principle: packet conservation at equilibrium, inject packet into network only when one is removed basis for stability of physical systems TCP components: how to get there: slow start how to stay there: congestion avoidance Computer Network

16 TCP Congestion Principals
Additive-Increase, Multiplicative-Decrease (AIMD) Approach: increase transmission rate until loss occurs additive increase ( congestion avoidance phase) increase cwin by 1 MSS every RTT until loss detected continuously probing for usable bandwidth multiplicative decrease cut cwin in half after loss (4020105) It is not allowed to drop below one MSS Saw tooth behavior: probing for bandwidth Computer Network

17 Slow Start Initialize cwnd = 1
Upon receipt of every ACK, cwnd = cwnd + 1 TCP sender maintains three new variables: cwnd – congestion window It is determined by inferred information about the level of congestion in the network. ssthresh – slow-start threshold It can be thought of as an estimate of the level below which congestion is not expected Flight Size No. of unacknowledged segments Implications Will overshoot window and cause packet loss but remember, packet loss is part of the plan Computer Network

18 Slow Start Slow Start When connection begins, cwin = 1 MSS
Example: MSS = 500 bytes & RTT = 200 msec initial rate = 20 kbps available bandwidth may be >> MSS/RTT desirable to quickly ramp up to respectable rate Host A Host B one segment RTT two segments Slow Start algorithm Delayed & Cumulative Ack initialize: cwin = 1 for (each segment ACKed) cwin++ until (loss event OR cwin >ssthresh) four segments time Summary: initial rate is slow but ramps up exponentially fast Exponential increase (per RTT) in window size Computer Network

19 Slow Start Example (redrawn from [Jacobson88a] Fig 2) one RTT 0R 1 1R
one pkt time 1R 1 2 3 2R 2 3 4 6 5 7 3R 4 5 6 7 8 10 12 14 9 11 13 15 Computer Network

20 When “Slow Start” ends? Implementation:
Q: When should the exponential increase switch to linear? (Want to end when the pipe is full) A: do end when cwnd > ssthresh and move to “Congestion Avoidance phase” SSTHRESH Implementation: Variable ssthresh At loss event, ssthresh is set to 1/2 of Flight Size just before loss event ssthresh = max {Flight Size/2, 2*MSS} cwin=1 ssthresh is typically set to very large value on connection setup ssthresh represents the rough estimation of the network capacity Computer Network

21 Slow Start and Congestion Avoidance
State Transition cwin instead set to 1 MSS; window then grows exponentially to ssthresh, then grows linearly Congestion Avoidance upon receiving ACK Increase cwnd by 1/cwnd This is additive increase (over 1 RTT it adds up to increasing by 1 segment) why not multiplicative increase? growing too fast in equilibrium => oscillations Slow Start Congestion Avoidance SSTHRESH SSTHRESH Computer Network

22 Slow Start and Congestion Avoidance
Slow Start: aggressively grow congestion window until congestion is detected Congestion Avoidance Initially: cwnd = 1*MSS (Maximum Segment Size) ssthresh is very large. If no loss: cwnd = 2*cwnd (after each new ACK) (This gives exponential growth of cwnd) If loss (timeout): ssthresh = max{flight size/2, 2*MSS} (multiplicative decrease) cwnd = 1*MSS If no loss: increase cwnd at most 1*MSS per RTT (additive increase) If loss: ssthresh = max{flight size/2, 2*MSS} (multiplicative decrease) cwnd = 1*MSS. Computer Network

23 Slow Start and Congestion Avoidance
Initally: - cwnd = 1*MSS - ssthresh = very high (64kbytes) If a new ACK comes: - if cwnd < ssthresh  update cwnd according to slow start if cwnd  ssthresh  update cwnd according to congestion avoidance If timeout (i.e. loss) : - ssthresh = max{flight size/2, 2*MSS} ; cwnd (initial) ssthresh Loss, e.g. timeout ssthresh time slow start – in green congestion avoidance – in blue Computer Network

24 Slow Start and Congestion Avoidance
Computer Network

25 Jacobson88a Figure 3: No CC of Slow-Start
Computer Network

26 Jacobson88a Figure 4: with CC of Slow-Start
Computer Network

27 Problems So Far have way to fill pipe (slow start)
have way to run at equilibrium (congestion avoidance) but tough transition no good initial ssthresh large ssthresh causes packet loss, every time need approaches to quickly recover from packet loss Computer Network

28 Fallback Mechanism: Timeout
retransmission timer (RTO) if no ACK after RTO fires, reset cwnd=1 and resend lowest unACK’ed segment but they’re very crude force slow-start again coarse-grain TCP timeouts lead to idle periods are often slow—a long time with no traffic …but is there more information? Computer Network

29 Could We Do Better? Receipt of dupACKs tells the sender that the receiver is still getting new segments, i.e. there is still data flowing between sender and receiver Why does sender go back to slow start always? Computer Network

30 Fast Retransmit & Fast Recovery
allows and uses duplicate ACKs to trigger retransmission Reaction to 3 dup ACKs for Segment N i.e. 4 identical ACKs without the arrival of any other intervening packets, Retransmits the segment N without waiting for timeout And move to Fast Recovery phase Fast Retransmit Philosophy: 3 dup ACKs indicates network capable of delivering some segments timeout indicates a “more alarming” congestion scenario Computer Network

31 Fast Retransmit & Fast Recovery
a duplicate ACK implies the receiver got a packet out of order an earlier packet might have been lost (or delayed) TCP sender waits until it sees three duplicate ACKs before retransmitting a packet Computer Network

32 Fast Retransmit & Fast Recovery
SSTHRESH is cut in half of cwnd ssthresh = max {flight size/2, 2*MSS} Set cwnd as follows: cwnd = ssthresh + 3 window then grows linearly cwnd++ Additive increase for every subsequent dup ACK Transmit a segment if permitted by cwnd When a new ACK received Exit Fast Recovery phase Reset cwnd to ssthresh (resume congestion avoidance) When Timeout occurs  perform Slow-Start Fast Recovery This artificially "inflates" the congestion window by the number of segments (three) that have been sent and which the receiver has buffered. It will acknowledge receiving all segments sent till moving to Fast Recovery phase (assuming that no more segments were lost). in order to reflect the additional segment that has been sent and which the receiver has buffered Computer Network

33 Fast Retransmit & Fast Recovery
cwnd (initial) ssthresh fast-retransmit fast-retransmit timeout new ACK new ACK Time Slow Start Congestion Avoidance “inflating” cwnd with dupACKs roughly a 20% improvement in the throughput “deflating” cwnd with a new ACK Computer Network

34 TCP Congestion Control - Summary
When cwin is below SSTHRESH, sender in slow-start phase, window grows exponentially. When cwin is above SSTHRESH, sender is in congestion-avoidance phase, window grows linearly. When a triple duplicate ACK occurs, Immediately retransmit the packet  named Fast Retransmit ssthresh set to max {0.5 * flight size, 2*MSS} and cwin set to ssthresh+3.  named Fast Recovery When timeout occurs, ssthresh set to cwin/2 and cwin is set to 1 MSS. “Fast” – because it doesn’t wait for time out when not getting an ACK for a segment Computer Network


Download ppt "TCP Tutorial - Part III -"

Similar presentations


Ads by Google