Computer Networks: Transmission Control Protocol (TCP) Ivan Marsic Rutgers University Chapter 2 - TCP Transmission Control Protocol (TCP) Chapter 2 UDP Header U D P p a ylo a d U D P header 0 15 16 1 6 -b it so u rce p o rt n u m b e r 31 1 6 -b it d e stin a tio n p o rt n u m b e r 8 b yte s 1 6 -b it d a ta g ra m le n g th 1 6 -b it d a ta g ra m ch e cksu m U D P d a ta g ra m d a ta (if a n y) Topic: TCP Protocol TCP Packet (“Segment”) Format Setting Retransmission Timers Flow Control TCP in the Protocol Stack • End-to-end protocol • Most popular protocol in the Internet (together with IP, “TCP/IP protocol suite” L a ye r 3 : Endto -E n d L a ye r 2 : N e tw ork L a ye r 1 : L in k T C P (T ra nsm ission C o n tro l P roto co l) Transmission Control Protocol (TCP) • Notion of a “session” or “connection”, so TCP is said to be a connection-oriented protocol • TCP “Quality of Service”: Assured delivery • Congestion avoidance helps improve throughput TCP Session • Continuous stream of bytes becomes available for application to use when a connection is established and disappears when the connection is closed Encapsulation of TCP Data in IP Datagrams From application: stream of bytes To application: stream of bytes Application Slice into TCP segments OSI Layer 4/5: TCP Concatenate to a byte stream TCP TCP hdr payload TCP TCP hdr payload Packetize into IP packets OSI Layer 3: IP Unwrap TCP segments IP hdr TCP hdr IP hdr TCP p a ylo a d Network Network TCP hdr TCP p a ylo a d TCP Header 0 15 16 1 6 -b it so u rce p o rt n u m b e r 31 1 6 -b it d e stin a tio n p o rt n u m b e r TC P header 3 2 -b it se q u e n ce n u m b e r 4 -b it header le n g th u n u se d (6 b its) fla g s 3 2 -b it a ckn o w le d ge m e n t n u m b e r U A P R S F R C S S Y I G K H T N N 1 6 -b it a d ve rtise d re ce ive w in d o w size 1 6 -b it T C P ch e cksu m 1 6 -b it u rg e n t d a ta p o in te r T C P p a ylo a d o p tio n s (if a n y) T C P se g m e n t d a ta (if a n y) 20 b yte s Recall the IPv4 Packet Header 0 7 8 4 -b it ve rsio n num ber 4 -b it header le n g th 15 16 8 -b it d iffe re n tia te d se rvice s (D S ) 1 6 -b it d a ta g ra m le n g th (in b yte s) u n u D M s F F e d 1 6 -b it d a ta g ra m id e n tifica tio n 8 -b it tim e to live (T T L ) fla g s 31 8 -b it u se r p ro to co l 1 3 -b it fra gm e n t o ffse t 1 6 -b it h e a d e r ch e cksu m 3 2 -b it so u rce IP a d d re ss 3 2 -b it d e stin a tio n IP a d d re ss o p tio n s (if a n y) d a ta 20 b yte s Urgent Data Pointer • Last byte of urgent data (LBUD) = sequenceNumber + urgentPointer • First byte of urgent data never explicitly defined • Any data in Receive buffer up to LBUD may be considered urgent R e c e ive d b yte s tre a m , sto re d in R e c e ive B u ffe r R e c e ive d T C P s e gm e n t u rg e n t d a ta n o n -u rg e n t d ata se q ue nc e n um b e r s e q . n um + u rg . p tr = L a s t B yte o f U rg e n t D a ta u rg en t d a ta po inter Retransmission Timer Calculation O c c u rre n c e fre q u e n c y o f m e a s u re d R T T va lu e s Search the Web for RTT distribution measurement R T T d istrib u tio n m e a su re d d u rin g q u ie t p e rio d s (a) (b) 1 R T T d istrib u tio n m e a su re d d u rin g p e a k u sa g e p e rio d s 2 0 0 2 1 M e a s u re d R T T va lu e TimeoutInterval C a se s fo r w h ich th e R T O tim e r w ill e xp ire to o so o n (c) 0 M e a su re d R T T va lu e Retransmission Timer Calculation Exponential Weighted Moving Average (EWMA) • Timeout Interval, set as +4 : TimeoutInterval(t) = EstimatedRTT(t) + 4 DevRTT(t) • Estimated mean value of RTT: EstimatedRTT(t) = (1) EstimatedRTT(t 1) + SampleRTT(t) • Estimated current standard deviation of RTT: DevRTT(t) = (1) DevRTT(t 1) + SampleRTT(t) EstimatedRTT(t 1) • The initial value is set as: DevRTT(0) = 1/2 SampleRTT(0) for the first RTT measurement • Recommended values of the control parameters are = 0.125 and = 0.25 Retransmission Timer Management (from Listing 2-1) • • • • • • • In method TCPSender.send(), Listing 2-1 // called by the application layer from above in Line 24: if (RTO timer not already running) { set the RTO timer to the current value as calculated in methods handle() and RTOtimeout(); start the timer; } • • • • • • In method TCPSender.handle(), Listing 2-1 // called by IP layer when ACK arrives in Lines 36 - 38: if ((lastByteAcked < lastByteSent) { calculate the new value of the RTO timer using Eq. (2.2); re-start the RTO timer; } • • • • In method TCPSender.RTOtimeout(), Listing 2-1 // called when RTO timeout in Line 43: double the TimeoutInterval; // exponential backoff , Eq. (2.1) start the timer; TCP Connection Establishment Client Client Time SYN_SENT (active open) ESTABLISHED #1 #2 Server Server LISTEN (passive open) SYN 12275 0000:12275 0000(0) win 2048, < mss 1024> (0) 363371521 :2 1 2 5 1 7 3 3 12> SYN 236 96, <mss 5 0 4 in w , 0 0 0 ack 122750 ack 2363371521 , win 2048 #2 SYN_RCVD ESTABLISHED Visit http://en.wikipedia.org/wiki/Network_socket to learn about network sockets Example TCP Session CongWin = 1 MSS = 512 bytes RcvWindow = 4096 bytes (TCP Sender) (TCP Receiver) Client Client Server Server 0:511(512), ac #3 CongWin = 1 + 1 = 2 k 0, win 2048 ack 512, win 4096 #4 4096 #6 2048:255 9(512), ac k 0, win 20 48 2560:3071(512) ack 2048, win 4096 #7 ack 2048, win 3072:3583(512), ack 0, win 2048 3584 #7 ack 3584, win 4096 #10 #4 512:1023(512 ), #5 1024:1535(512), ack 0, win 2048 ack 0, win 20 48 ack 1536, win #6 #7 CongWin = 2 +1+1 = 4 1536:2047(512), ack 0, win 2048 #8 #9 CongWin = 4 +1 = 5 #10 CongWin = 5 +1+1+1 = 8 3584:4 097 #11 (512), ack 0, win 20 4096:4607(512) 48 #12 4608:5119(512), ack 0, win 2048 #10 Gap in sequence! #10 (buffer 1024 bytes) 3584 ack 3584, win 5120:5631(512), ack 0, 3072 win 3584, ack win 2048 #13 #14 Gap in sequence! (buffer 512 bytes) Data Transport (Initial phase: “Slow Start”) Time #14 ack 5632, win 4096 CongWin = 8 +1+1+1+1 = 12 detail: #7 2048:255 9(51 #8 2560:3071(512) #9 3072:3583(512), ack 0, win 2048 2), ack 0, #6 win 2048 ack 2048, win 4096 #7 detail ack 2048, win e) 3584 (duplicat #7 Flow vs. Congestion Control Flow control Congestion control Sender Sender Feedback: “Not much getting through” Feedback: “Receiver overflowing” Receiver Receiver Topic: TCP Congestion Control TCP Tahoe TCP Reno TCP NewReno The Problem • TCP is a window-based protocol – Window size represents the amount of resources available for a communication session – It limits the number of outstanding (unacknowledged) packets • However, unlike a simple ARQ (Chapter 1), “resources” include both receiver resources and network resources • How to know the available network resources? Network Conceptual Model Many sources and many receivers … Network Network (a) We don’t know when sources will start/end their sessions; also their datarates are variable Simplified Network Model The entire network is abstracted as a single router – “black box” RcvWin CongWin Receiver resources Represented by “Receive Window Size” (b) Network resources Represented by “Congestion Window Size” TCP Buffer Parameters [ Sending Application ] Sent & acked Increasing Allowed to sequence num. send [ Receiving Application ] Delivered to application Gap in recv’d data Increasing sequence num. TCP receiver’s byte stream TCP sender’s byte stream LastByteAcked LastByteSent FlightSize (Buffered in send buffer) NextByteExpected LastByteRecvd Buffered in RcvBuffer TCP Congestion Control Summary 1. Sender starts with a small window size 2. Send a “burst” of packets (size of the current sender window) into the network 3. Wait for a feedback about success rate (acknowledgements from the receiver end) 4. When the (positive/negative) feedback arrives: a) b) + If the success rate is greater than zero, increase the sender window size and go to Step 2 – If loss is detected, decrease the sender window size and go to Step 2 TCP Congestion Control Param’s Variable MSS RcvWindow CongWindow LastByteAcked LastByteSent FlightSize EffectiveWindow SSThresh Definition The maximum segment size that the sender can transmit. MSS does not include the TCP/IP headers and options—only the data payload. This value can be based on the maximum transmission unit (MTU) of the first link, the path MTU discovery algorithm, or other factors. By setting MSS to the path MTU, the sender may avoid packet fragmentation (Section 1.4.1), although this is difficult to achieve because routers change routes dynamically. [Note that RFC-2581 distinguishes the sender maximum segment size (SMSS) and the receiver maximum segment size (RMSS).] The size of the most recently advertised receiver window. Sender’s current estimate of the available buffer space in the bottleneck router. The highest sequence number currently acknowledged. The sequence number of the last byte the sender sent. The amount of data that the sender has sent, but not yet had acknowledged. The maximum amount of data that the sender is currently allowed to send. At any given time, the sender must not send data with a sequence number higher than the sum of the highest acknowledged sequence number and the minimum of CongWindow and RcvWindow. The slow start threshold used by the sender to decide whether to employ the slow-start or congestion-avoidance algorithm to control data transmission. The slow start algorithm is used when CongWindow < SSThresh, while the congestion avoidance algorithm is used when CongWindow > SSThresh. When CongWindow and SSThresh are equal the sender may use either slow start or congestion avoidance. TCP Sender State Diagram TCP Sender new ACK / “Send data” new ACK / “Send data” duplicate ACK (less than 3) / duplicate ACK (less than 3) / new ACK & (CongWin SSThresh) / “Send data” Start / Slow Start Congestion Avoidance CongWin SSThresh CongWin SSThresh for every new ACK, set: for every new ACK, set: CongWin CongWin + 1 CongWin CongWin + MSS MSS CongWin timeout / “Retransmit” [Reno] after “fast recovery” 3 duplicate ACKs / “Retransmit” (Fast retransmit) timeout / “Retransmit” [Tahoe] “Send data” 1. Set CongWin & SSThresh 2. Send EfctWin of data, if any 3. Re-start RTO timer 3 duplicate ACKs / “Retransmit” (Fast retransmit) “Retransmit” 1. Set CongWin & SSThresh 2. Re-send oldest outstanding segment 3. Double the RTO timer & re-start it TCP Receiver State Diagram Out-of-order segment / Buffer it & Send dupACK TCP Receiver Out-of-order segment / Buffer it & Send dupACK Segments arriving in-order (NextByteExpected = LastByteRecvd + 1) In-order segment / Start / Out-of-order segments Immediate acknowledging In-order seg. / Send ACK Delayed acknowledging (LastByteRecvd > NextByteExpected) 500 msec elapsed / Send ACK In-order segment, completely fills gaps / Send ACK In-order segment, partially fills gaps / Send ACK How Much Sender Can Send • The sender must always ensure that: LastByteSent LastByteAcked min{CongWindow, RcvWindow} • the amount of unacknowledged data should never exceed: FlightSize = LastByteSent LastByteAcked min{CongWindow, RcvWindow} • TCP session invariant (“allowed to send”): EffectiveWindow = min{CongWindow, RcvWindow} FlightSize How TCP Sender Detects Segment Loss • Retransmission timer (RTO) expiration • Reception of three duplicate ACKs (four identical ACKs without the arrival of any other intervening packets) Why three dupACKs: – If there is just a reordering of the segments, there will be only one or two dupACKs before the reordered segment is processed, which will then generate a regular ACK. – If three or more dupACKs are received in a row, it is a strong indication that a segment has been lost. How TCP Sender Detects Segment Loss TCP Event TCP Sender’s Action Version Tahoe Set CongWindow = 1MSS Timeout Reno Tahoe Set CongWindow = 1MSS Reno Set CongWindow = max {½ FlightSize, 2MSS} + 3MSS 3dup ACKs Slow Start Threshold • Determines when the “slow start” phase ends and the “congestion avoidance” phase begins • SSThresh = max {½ FlightSize, 2MSS} TCP Tahoe Sender (Effective Window computed as before …) When packet loss detected via 3 dupACKs: SSThresh(t) = max {½ CongWindow(t1), 2MSS} (2.4) Congestion Window computation under Congestion Avoidance: CongWin ( t ) CongWin ( t 1) MSS MSS CongWin ( t 1) [bytes] (2.5) TCP-Tahoe Sender State Diagram new ACK & (CongWin SSThresh) / “Send data” Tahoe Sender Start / new ACK / “Send data” dupACKs count = 0 Slow Start Congestion Avoidance dupACK / dupACK / new ACK / “Send data” 0 dupACKs count 3 dupACK / new ACK / “Send data” dupACK / dupACKs count = 0 new ACK / “Send data” 0 dupACKs count 3 Fast retransmit dupACK & (count 3) / “Retransmit” timeout / “Retransmit” “Send data” 1. Set CongWin & SSThresh 2. Send EfctWin of data, if any 3. Re-start RTO timer timeout / “Retransmit” Fast retransmit dupACK & (count 3) / “Retransmit” “Retransmit” 1. Set CongWin & SSThresh 2. Re-send oldest outstanding segment 3. Double the RTO timer & re-start it TCP-Reno Sender State Diagram dupACK / CongWin CongWin + 1 & “Send data” Fast Recovery Reno Sender Fast retransmit dupACK & (count 3) / “Retransmit” On entry, set: SSThresh ½ CongWin CongWin SSThresh + 3MSS & “Send data” timeout / “Retransmit” new ACK / “Send data” dupACK / recovery ACK / CongWin SSThresh & “Send data” dupACK / Congestion Avoidance 0 dupACKs count 3 dupACKs count = 0 new ACK / “Send data” timeout / “Retransmit” dupACK / timeout / “Retransmit” new ACK & (CongWin SSThresh) / “Send data” dupACKs count = 0 new ACK / “Send data” new ACK / “Send data” Fast retransmit dupACK & (count 3) / “Retransmit” Slow Start Start / 0 dupACKs count 3 dupACK / Example 2.1: TCP Bottleneck Link 10 Mbps Router 1 Mbps Sender Receiver 6+1 packets Router Architecture CPU Memory I/O Transmit/Receive 6 slots for packets 1 packet in transmission Detail of Transmission Round #5 Sender Time = 4 RTT Receiver 6 packets buffered: #16 FlightSize Dropped packets #14 #15 Transmission time on link_2 equals 10 (Tx time on link_1) LastByteRecvd NextByteExpected 22 21 20 19 18 17 #14 #15 LastByteAcked Segments #16 transmitted: #17 #18 #19 #20 #21 #22 #23 #24 #25 #26 #27 #28 #29 Router #29 #30 LastByteSent #17 Segment #16 received 27 22 21 20 19 18 Time packet #27 occupies the slot emptied by packet #17 #18 Segment #17 received Sender Sender CongWin = 1 MSS EfctWin = 1 Receiver Receiver #1 1 RTT seg 1 ack 2 CongWin = 1 + 1 #2 1024 bytes to application #4 2 KB to appl #2,3 EfctWin = 2 2 RTT CongWin = 2 +1+1 #4,5,6,7 EfctWin = 4 4 KB to appl #8 3 RTT CongWin = 4 +1+1+1+1 EfctWin = 8 #8,9, …,14,15 4 RTT 8 segments sent seg 15 (loss) ack 15 #15 7 KB to appl [ 1 segment lost ] CongWin = 8 +1+…+1 EfctWin = 14 #16,17, …,22, 23,…,27,28,29 7 Gap in sequence! (buffer 7 KB) [ segment #15 missing ] 14 segments sent k 15 7 d u p ac #15,15,…,15 seg 27 5 RTT 7+1 dupACKs CongWin = 1 #15 6 RTT CongWin = 1 + 1 EfctWin = 0 CongWin = 1 EfctWin = 1 CongWin = 1 + 1 EfctWin = 0 #15 dup ack 15 (buffer 8 KB) [ 5 segments missing ] seg 15 (retransmission) #23 ack 23 8 KB to appl [ 4 segments missing ] [ segment #27 buffered ] 7 RTT 8 RTT RTO timeout 9 RTT Time [RTT] #23 seg 23 (retransmission) ack 24 #24 1024 bytes to appl [ 3 segments missing ] [ segment #27 buffered ] RTO Timer Timeout Pattern 6 RTT ack 23 icon indicates when RTO timer is started 7 RTT 8 RTT RTO t-out 9 RTT seg 23 (retransmission ) 16 RTT ack 24 17 RTT 10 RTT 18 RTT 11 RTT 19 RTT 12 RTT 20 RTT 13 RTT RTO t-out 14 RTT 15 RTT seg 24 (retransmission ) 21 RTT ack 25 22 RTT RTO t-out 23 RTT 24 RTT seg 25 (retransmission ack 26 ) TCP Tahoe (2) MSS = 1024 bytes, RcvWindow = 64 KB EffctWin [bytes] 65535 CongWin FlightSize EffctWin SSThresh [MSS] 15MSS 14336 14 8192 8 4096 4 6 3 dupACKs 9 RTO timeout 2MSS 2 1 Time #79,80,81,82,83 #75,76,77,78 #73,74 #65 #66,67,68, …,72 #58,59,60, …,64,65 #51,52,53, …,57 #40,41,42,43,44 #45,46,47,48,49, 50 140 142 144 146 148 150 [RTT] 139 141 143 145 147 149 #36,37,38,39 138 #33,34,35 137 #31,32 8 9 10 11 #29 7 #23 #15 #16,17, …,22,23,…,29 4 5 6 #8,9, …,14,15 2 3 #4,5,6,7 1 #2,3 1MSS #1 Segments sent 2048 1024 TCP Tahoe (3) Multiplicative decrease TCP Tahoe: CongWin 1 MSS TCP Reno: CongWin 1/2 FlightSize 15 Slow start When CongWin SSThresh, for each ACK: CongWin(t) CongWin(t–1) + MSS2 / CongWin(t–1) For each ACK: CongWin CongWin + 1 CongWin [MSS] Additive increase (Congestion avoidance) 8 Retransmit based on RTO timeout (“slow retransmit”) 4 SSThresh 2 1 0 1 2 3 4 5 6 7 8 9 10 11 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 Fast retransmit Retransmit oldest un-acknowledged segment after 3 dupACKs without waiting for RTO timeout Time [RTT] TCP Sender States / Phases Slow Start: Defined by: Congestion Window (CW) SSThresh Congestion Window calculation: CW(t) = CW(t – 1) + #ACKMSS Fast Retransmit: Defined as: When 3 dupACKs received, retransmit the oldest outstanding packet without waiting for RTO timeout Congestion Avoidance: Defined by: Congestion Window (CW) > SSThresh Congestion Window calculation: #ACKMSS CW(t) = CW(t – 1) + MSS CW(t – 1) Reno-Specific State / Phase Same as for Tahoe: Slow Start, Fast Retransmit, Congestion Avoidance Fast Recovery: Defined as: When 3 dupACKs received, Congestion Window calculation: CW(t) = max {½ FlightSize(t), 2MSS} + 3MSS ( Unlike TCP Tahoe sender, which sets CW(t) = 1MSS when 3 dupACKs received ) TCP Reno Sender (Effective Window computed as before …) When packet loss detected via 3 dupACKs: SSThresh(t) = max {½ FlightSize(t1), 2MSS} (2.6) CongWindow(t) = SSThresh(t) + 3MSS (2.7) Enter Fast Recovery: count each “old ACK” as +MSS to CongWin. When “new ACK” received, exit Fast Recovery and enter Congestion Avoidance. CongWindow = SSThresh (2.8) 65535 [bytes] [MSS] 16384 15 8 15 2 1 4096 4 2048 1024 2 1 24 0 1 2 3 4 5 6 7 8 9 10 11 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [RTT] 6 dupACKs 7+1 dupACKs 3 dupACKs #29 #53,54,55,56 #36,57 #58 #59 (1 byte) #37 #60,61, …,66 #67,68, …,73,74 #75,76, …,81 #74,82,83 #84,85,…,90,91,…,94,95 EffctWin #28 #50 (1 byte) #51 (1 byte) #52 (1 byte) 8 #26 #47 (1 byte) #48 (1 byte) #49 (1 byte) 8192 #1 #2,3 #4,5,6,7 #8,9, …,14,15 #16,17, …,22,23,…,29 #15,30,…,35,36,37 #23 #38 (1 byte) #39 (1 byte) #40 (1 byte) #24 #41 (1 byte) Segments sent TCP Reno (1) SSThresh CongWin 73 28 29 59 66 4 36 37 23 EffctWin FlightSize Time 4 dupACKs 7 dupACKs TCP Reno (2) SSeennddeerr C o n gW in = 6 . 7 M S S E fc tW in = 0 C o n gW in = # 5 2 (1 b yte ) 26 R TT 3 dupACKs 3 1 6 . 3 6 . 7 2 E fc tW in = 1 R Reecceeive iverr #29 seg 29 #36 ack 36 # 5 3 ,5 4 ,5 5 ,5 6 E fc tW in = 4 28 R TT C o n gW in = 6 . 3 1 4 dupACKs 29 R TT seg 36 #58 30 R TT C o n gW in = 7 . 3 7 . 3 2 1 0 2 4 b yte s to a p p l (b u ffe r 1 0 2 4 b yte s ) seg 58 #37 (b u ffe r 1 K B ) #37 (b u ffe r 1 b yte ) ack 37 # 5 9 (1 b yte ) s e g 5 9 (1 b yte ) E fc tW in = 0 31 R TT #37 #37 ack 37 E fc tW in = 1 3 dupACKs 3 6 . 6 ack 37 #37 seg 37 E fc tW in = 1 32 R TT ack 60 C o n gW in = 7 . 6 E fc tW in = 7 # 3 6 ,3 6 ,3 6 ,3 6 ack 36 ack 37 C o n gW in = 7 . 3 7 1 6 8 b yte s to a p p lic a tio n G a p in s e q u e n c e! (b u ffe r 4 K B ) # 3 6 ,5 7 E fc tW in = 2 C o n gW in = # 2 9 (b u ffe r 1 b yte ) ack 29 27 R TT C o n gW in = 6 . 3 s e g 5 2 (1 b yte ) # 6 0 ,6 1 , … ,6 6 T im e [R T T ] #60 1024 + 16 + 6144 b yte s to a p p lic a tio n Topic: TCP NewReno Protocol Partial ACKs for Pkt Loss Detection Example How TCP Sender Discovers Packet Loss • Retransmission timer (RTO) expired • 3 dupACKs received • Partial ACK received TCP Tahoe & TCP Reno TCP NewReno TCP NewReno – Partial ACKs • Defined at the time tloss when the sender discovers a packet loss (by 3 dupACKs): • Full acknowledgment: If the sender will receive an ACK for all packets that were outstanding at the time tloss • Partial acknowledgment: If the sender will receive an ACK for some of the packets that were outstanding at the time tloss TCP NewReno TCP Sender TCP Receiver EffectiveWindow #1 #2 #3 #4 #5 NextByteExpected = LastByteRecvd + 1 #6 LastByteRecvd LastByteAcked = LastByteSent Receive buffer (loss) (loss) (loss) Time #2 tloss #6 NextByteExpected FlightSize LastByteAcked #4 LastByteRecvd te) te) te) lica p lica u lica p d p ( u u (d (d k#1 k#1 Ac k #1 Ac Ac LastByteSent LOSS DETECTED (3 dupACKs) At this time define: Full acknowledgment = ACK for all 6 outstanding pkts LOSS DETECTED (partial ACK) Seg#1 (retransmission ) #1 #2 #4 LastByteRecvd Ack#3 (partial) NextByteExpected Seg#3 (retransmission ) #6 TCP NewReno Fast Recovery • NewReno sender enters Fast Recovery when a loss is detected (by 3 dupACKs) • NewReno sender exits Fast Recovery when it receives the full acknowledgement (defined at time tloss) • After Fast Recovery, NewReno sender enters Congestion Avoidance Congestion Window Calculation during Fast Recovery • NewlyAcked = LastByteAcked(t) LastByteAcked(t 1) • If (NewlyAcked < MSS), then CongWindow(t) = CongWindow(t 1) NewlyAcked • Else if (NewlyAcked MSS), then CongWindow(t) = CongWindow(t 1) NewlyAcked + MSS TCP NewReno: Example (1) Example 2.2 Link 1 Sender 4+1 packets Router txmit (Link 1) << txmit (Link 2) tprop (Link 1) << tprop (Link 2) tprop (Link 2) = 6 txmit (Link 2) Link 2 Receiver TCP NewReno: Example (2) Example 2.2 Sender txmit(Link 1) transmission on Link 1 propagation on Link 1 tprop(Link 1) Sender/Router 0 1 transmission on Link 2 2 3 pkt Router propagation on Link 2 10 ack txmit(Link 2) Receiver Sender/Router 0 txmit(Link 1) 1 tprop(Link 1) pkt Receiver txmit(Link 2) 10 2 3 ack Sender/Router 0 1 10 20 2 3 pkt 4 5 6 7 Time [in packet transmission slots] 30 3 dupACK 40 50 60 8 9 10 11 12 13 14 15 16 171819202122242628 30323436 3840 42 44 23 17 25 46 ack Receiver Congestion window [segments] SSThresh = 65535 bytes 20 SSThresh = 11 MSS 10 CongWin Lost packets: 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45 (12 total) 0 Packets in Router buffer Slow Start 5 0 3 2 3 1 Fast Retransmit Fast Recovery 7 5 6 7 4 5 6 7 15 21 22 24 26 28 30 32 34 36 38 40 42 44 13 14 15 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 11 12 13 14 15 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 23 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 23 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 4423 7 6 6 5 5 5 3 4 4 4 4 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 12 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 23 11 11 11 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 23 7 8 9 10 10 10 10 11 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 23 6 7 8 9 9 9 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 44 23 5 6 7 8 8 8 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 26 28 30 32 34 36 38 40 42 4423 46 2546 Packets in flight on 2nd link 6 0 1 3 2 2 46 25 25 Sender/Router 60 27 47 48 ack 70 29 49 50 51 80 31 52 53 54 55 Time [in packet transmission slots] 90 33 56 57 58 59 60 100 110 120 35 61 62 63 64 65 66 37 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 84 85 86 87 pkt Receiver CW = 51 Congestion window [segments] 40 Fast Recovery (cont’d) 30 CongWin SSThresh = 11 MSS 20 Congestion Avoidance Packets in Router buffer 5 0 47 48 27 4748 49 50 51 29 49 50 51 82 83 84 85 86 87 88 89 90 74 75 76 77 78 79 80 81 41 82 83 84 85 86 87 88 89 61 62 63 64 65 66 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 84 85 86 87 88 35 61 62 63 64 6566 37 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 84 85 86 87 52 53 54 55 31 52 53 5455 5657 58 59 60 3356 57 58 5960 55 54 54 51 31 52 53 53 53 50 51 31 52 52 52 49 50 51 31 31 31 60 65 66 37 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 84 85 86 59 59 60 35 61 62 63 64 64 65 66 37 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 84 85 55 33 56 57 58 58 58 59 60 35 61 62 63 63 64 65 66 37 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 84 54 55 33 56 57 57 57 58 59 60 35 61 62 62 63 64 65 66 37 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 83 53 54 55 33 56 56 56 57 58 59 60 35 61 61 62 63 64 65 66 66 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 82 52 53 54 55 33 33 33 56 57 58 59 60 35 35 61 62 63 64 65 37 66 67 68 69 70 71 72 73 39 74 75 76 77 78 79 80 81 41 Packets in flight on 2nd link 6 48 46 47 47 0 2546 27 27 27 51 50 50 48 29 49 49 49 47 48 29 29 29 Topic: TCP Over Wireless Reducing Link-Layer Overheads TCP Over Wireless • Slow start until reaches the SSThresh size; set timer for every burst • If no ACK congestion; halve the window size; slow start again Wireless Link-layer Overhead TCP layer: TCP data segment [1024 KB + 40 bytes headers] TCP ACK segment [0 KB + 40 bytes headers] Link layer: Link layer overhead: backoff delay, interframe spaces, link-layer control frames (RTS, CTS, ACK)