15-441 Computer Networking Lecture 16 –TCP in detail Eric Anderson Fall 2013 www.cs.cmu.edu/~prs/15-441-F13.

Slides:



Advertisements
Similar presentations
TCP Variants.
Advertisements

TCP and Congestion Control
1 Transport Protocols & TCP CSE 3213 Fall April 2015.
Slide Set 13: TCP. In this set.... TCP Connection Termination TCP State Transition Diagram Flow Control How does TCP control its sliding window ?
CS 6401 Transport Control Protocol Outline TCP objectives revisited TCP basics New algorithms for RTO calculation.
1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July A note on the use.
1 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
6-May-154/598N: Computer Networks End-to-End Protocols Underlying best-effort network –drop messages –re-orders messages –delivers duplicate copies of.
Computer Networks 2 Lecture 2 TCP – I - Transport Protocols: TCP Segments, Flow control and Connection Setup.
TCP 4/15/2017.
Congestion Control Created by M Bateman, A Ruddle & C Allison As part of the TCP View project.
Computer Networking Lecture 17 – TCP & Congestion Control Dejian Ye, Liu Xin.
1 TCP - Part II. 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information.
Computer Networks: TCP Congestion Control 1 TCP Congestion Control Lecture material taken from “Computer Networks A Systems Approach”, Fourth Edition,Peterson.
Computer Networking Lecture 17 – More TCP & Congestion Control Copyright ©, Carnegie Mellon University.
Transport Layer 3-1 Fast Retransmit r time-out period often relatively long: m long delay before resending lost packet r detect lost segments via duplicate.
Computer Networks: TCP Congestion Control 1 TCP Congestion Control Lecture material taken from “Computer Networks A Systems Approach”, Third Ed.,Peterson.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
15-744: Computer Networking L-10 Congestion Control.
Lecture 18 – TCP Performance
1 Spring Semester 2007, Dept. of Computer Science, Technion Internet Networking recitation #7 TCP New Reno Vs. Reno.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Computer Networking Lecture 16 – TCP & Congestion Control Copyright ©, Carnegie Mellon University.
Computer Networks : TCP Congestion Control1 TCP Congestion Control.
Computer Networking Lecture 16 – More TCP
Advanced Computer Networks: TCP Congestion Control 1 TCP Congestion Control Lecture material taken from “Computer Networks A Systems Approach”, Fourth.
1 K. Salah Module 6.1: TCP Flow and Congestion Control Connection establishment & Termination Flow Control Congestion Control QoS.
Computer Networking Lecture 17 – TCP Performance Dejian Ye, Liu Xin.
COMT 4291 Communications Protocols and TCP/IP COMT 429.
TCOM 509 – Internet Protocols (TCP/IP) Lecture 04_b Transport Protocols - TCP Instructor: Dr. Li-Chuan Chen Date: 09/22/2003 Based in part upon slides.
1 Transport Protocols (continued) Relates to Lab 5. UDP and TCP.
Chapter 12 Transmission Control Protocol (TCP)
1 TCP - Part II Relates to Lab 5. This is an extended module that covers TCP data transport, and flow control, congestion control, and error control in.
Lecture 9 – More TCP & Congestion Control
What is TCP? Connection-oriented reliable transfer Stream paradigm
Lecture 18 – More TCP & Congestion Control
81 Sidevõrgud IRT 0020 loeng okt Avo Ots telekommunikatsiooni õppetool, TTÜ raadio- ja sidetehnika inst.
CS640: Introduction to Computer Networks Aditya Akella Lecture 15 TCP – III Reliability and Implementation Issues.
Computer Networking Lecture 18 – More TCP & Congestion Control.
TCP: Transmission Control Protocol Part II : Protocol Mechanisms Computer Network System Sirak Kaewjamnong Semester 1st, 2004.
1 CS 4396 Computer Networks Lab TCP – Part II. 2 Flow Control Congestion Control Retransmission Timeout TCP:
Network Protocols: Design and Analysis Polly Huang EE NTU
CS640: Introduction to Computer Networks Aditya Akella Lecture 15 TCP – III Reliability and Implementation Issues.
1 TCP - Part II. 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information.
ECE 4110 – Internetwork Programming
CS 6401 Congestion Control in TCP Outline Overview of RENO TCP Reacting to Congestion SS/AIMD example.
TCP Congestion Control 컴퓨터공학과 인공지능 연구실 서 영우. TCP congestion control2 Contents 1. Introduction 2. Slow-start 3. Congestion avoidance 4. Fast retransmit.
CS640: Introduction to Computer Networks Aditya Akella Lecture 15 TCP – II - Connection Set-up and Congestion Control.
CS640: Introduction to Computer Networks Aditya Akella Lecture 15 TCP Congestion Control.
Transmission Control Protocol (TCP) connection-oriented stream data transfer data sent as an unstructured stream of bytes reliability acknowledgements.
Transmission Control Protocol (TCP) TCP Flow Control and Congestion Control CS 60008: Internet Architecture and Protocols Department of CSE, IIT Kharagpur.
1 Transmission Control Protocol (TCP) RFC: Introduction The TCP is intended to provide a reliable process-to-process communication service in a.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
Computer Networking Lecture 8 – TCP & Congestion Control.
TCP - Part II.
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
Introduction to Networks
Introduction to Congestion Control
TCP - Part II Relates to Lab 5. This is an extended module that covers TCP flow control, congestion control, and error control in TCP.
Lecture 19 – TCP Performance
So far, On the networking side, we looked at mechanisms to links hosts using direct linked networks and then forming a network of these networks. We introduced.
TCP Overview Connection-oriented Byte-stream Full duplex
CS640: Introduction to Computer Networks
Lecture 18 – More TCP & Congestion Control
State Transition Diagram
Transport Protocols: TCP Segments, Flow control and Connection Setup
Transport Layer: Congestion Control
Computer Networking TCP.
Transport Protocols: TCP Segments, Flow control and Connection Setup
TCP: Transmission Control Protocol Part II : Protocol Mechanisms
Presentation transcript:

Computer Networking Lecture 16 –TCP in detail Eric Anderson Fall

2 Good Ideas So Far… Flow control Stop & wait Sliding window Loss recovery Timeouts Acknowledgement-driven recovery Selective repeat Cumulative acknowledgement Congestion control AIMD  fairness and efficiency How does TCP actually implement these?

3 Outline TCP connection setup/data transfer TCP Packet Loss and Retransmission TCP congestion avoidance TCP slow start

4 Sequence Number Space Each byte in byte stream is numbered. 32 bit value Wraps around Initial values selected at start up time TCP breaks up the byte stream into packets. Packet size is limited to the Maximum Segment Size Each packet has a sequence number. Indicates where it fits in the byte stream packet 8packet 9packet

5 Establishing Connection: Three-Way handshake Each side notifies other of starting sequence number it will use for sending Why not simply chose 0? Must avoid overlap with earlier incarnation Security issues Each side acknowledges other’s sequence number SYN-ACK: Acknowledge sequence number + 1 Can combine second SYN with first ACK SYN: SeqC ACK: SeqC+1 SYN: SeqS ACK: SeqS+1 ClientServer

6 TCP Connection Setup Example Client SYN SeqC: Seq. # , window 65535, max. seg Server SYN-ACK+SYN Receive: # (= SeqC+1) SeqS: Seq. # , window 5840, max. seg Client SYN-ACK Receive: # (= SeqS+1) 09:23: IP > : S : (0) win (DF) 09:23: IP > : S : (0) ack win 5840 (DF) 09:23: IP > :. ack win (DF)

7 TCP State Diagram: Connection Setup CLOSED SYN SENT SYN RCVD ESTAB LISTEN active OPEN create TCB Snd SYN create TCB passive OPEN delete TCB CLOSE delete TCB CLOSE snd SYN SEND snd SYN ACK rcv SYN Send FIN CLOSE rcv ACK of SYN Snd ACK Rcv SYN, ACK rcv SYN snd ACK Client Server

8 CLOSED LISTEN SYN_RCVDSYN_SENT ESTABLISHED CLOSE_WAIT LAST_ACKCLOSING TIME_WAIT FIN_WAIT_2 FIN_WAIT_1 Passive openClose Send/SYN SYN/SYN + ACK SYN + ACK/ACK SYN/SYN + ACK ACK Close/FIN FIN/ACKClose/FIN FIN/ACK ACK + FIN/ACK Timeout after two segment lifetimes FIN/ACK ACK Close/FIN Close CLOSED Active open/SYN TCP State Diagram: Connection Setup s c

9 Tearing Down Connection Either side can initiate tear down Send FIN signal “I’m not going to send any more data” Other side can continue sending data Half open connection Must continue to acknowledge Acknowledging FIN Acknowledge last sequence number + 1 AB FIN, SeqA ACK, SeqA+1 ACK Data ACK, SeqB+1 FIN, SeqB

10 TCP Connection Teardown Example Session Echo client on , server on Client FIN SeqC: Server ACK + FIN Ack: (= SeqC+1) SeqS: Client ACK Ack: (= SeqS+1) 09:54: IP > : F : (0) ack win (DF) 09:54: IP > : F : (0) ack win 5840 (DF) 09:54: IP > :. ack win (DF)

11 State Diagram: Connection Tear-down CLOSING CLOSE WAIT FIN WAIT-1 ESTAB TIME WAIT snd FIN CLOSE send FIN CLOSE rcv ACK of FIN LAST-ACK CLOSED FIN WAIT-2 snd ACK rcv FIN delete TCB Timeout=2msl send FIN CLOSE send ACK rcv FIN snd ACK rcv FIN rcv ACK of FIN snd ACK rcv FIN+ACK ACK Active Close Passive Close

12 CLOSED LISTEN SYN_RCVDSYN_SENT ESTABLISHED CLOSE_WAIT LAST_ACKCLOSING TIME_WAIT FIN_WAIT_2 FIN_WAIT_1 Passive openClose Send/SYN SYN/SYN + ACK SYN + ACK/ACK SYN/SYN + ACK ACK Close/FIN FIN/ACKClose/FIN FIN/ACK ACK + FIN/ACK Timeout after two segment lifetimes FIN/ACK ACK ACK/ /ACK Close/FIN Close CLOSED Active open/SYN TCP State Diagram: Connection Teardown A B “half-closed” B→A still open

13 Outline TCP connection setup/data transfer Packet Loss and Retransmission Recognizing packet loss Identifying missing packets Retransmission behavior TCP congestion avoidance TCP slow start

14 Reliability Challenges Congestion related losses Variable packet delays What should the timeout be? Reordering of packets How to tell the difference between a delayed packet and a lost one?

15 TCP = Go-Back-N Variant Sliding window with cumulative acks Receiver can only return a single “ack” sequence number to the sender. Acknowledges all bytes with a lower sequence number Starting point for retransmission Duplicate acks sent when out-of-order packet received But: sender only retransmits a single packet. Reason??? Only one that it knows is lost Network is congested  shouldn’t overload it Error control is based on byte sequences, not packets. Retransmitted packet can be different from the original lost packet – Why?

16 Outline TCP connection setup/data transfer Packet Loss and Retransmission Recognizing packet loss Identifying missing packets Retransmission behavior TCP congestion avoidance TCP slow start

Retransmit Timeout How long is too long? Well, how long does it usually take? Early TCP: RTO = 2 x RTT Last 20 years: RTO = RTT + 4x deviation What’s the RTT? What’s the deviation? 17

18 Round-trip Time Estimation Wait at least one RTT before retransmitting Importance of accurate RTT estimators: Low RTT estimate unneeded retransmissions High RTT estimate poor throughput RTT estimator must adapt to change in RTT But not too fast, or too slow! Spurious timeouts “Conservation of packets” principle – never more than a window worth of packets in flight

19 Original TCP Round-trip Estimator Round trip times exponentially averaged: New RTT =  (old RTT) + (1 -  ) (new sample) Recommended value for  : for most TCP’s Retransmit timer set to (b * RTT), where b = 2 Every time timer expires, RTO exponentially backed-off Not good at preventing spurious timeouts Why?

20 Jacobson’s Retransmission Timeout Key observation: At high loads, round trip variance is high Solution: Base RTO on RTT and standard deviation RTO = RTT + 4 * rttvar new_rttvar =  * dev + (1-  ) old_rttvar Dev = linear deviation Inappropriately named – actually smoothed linear deviation

21 RTT Sample Ambiguity Karn’s RTT Estimator If a segment has been retransmitted: Don’t count RTT sample on ACKs for this segment Keep backed off time-out for next packet Reuse RTT estimate only after one successful transmission AB ACK Sample RTT Original transmission retransmission RTO AB Original transmission retransmission Sample RTT ACK RTO X

22 Timestamp Extension Used to improve timeout mechanism by more accurate measurement of RTT When sending a packet, insert current time into option 4 bytes for time, 4 bytes for echo a received timestamp Receiver echoes timestamp in ACK Actually will echo whatever is in timestamp Removes retransmission ambiguity Can get RTT sample on any packet

23 Timer Granularity Many TCP implementations set RTO in multiples of 200,500,1000ms Why? Avoid spurious timeouts – RTTs can vary quickly due to cross traffic Make timers interrupts efficient What happens for the first couple of packets? Pick a very conservative value (seconds)

ACKs & NACKs TCP has no NACK 24 … ACK 12 ACK 13 ACK 14 … Send 12 Send 13 Send 14 Send 15 Send 16 Send 17 Send 18 Send 19 …

25 Duplicate ACKs (Fast Retransmit) What are duplicate acks (dupacks)? Repeated acks for the same sequence When can duplicate acks occur? Loss Packet re-ordering Window update – advertisement of new flow control window Assume re-ordering is infrequent and not of large magnitude Receipt of 3 or more duplicate acks is indication of loss Don’t wait for timeout to retransmit packet When does this fail?

26 Duplicate ACKs (Fast Retransmit) Time Sequence No Duplicate Acks Retransmission X Packets Acks

27 Outline TCP connection setup/data transfer Packet Loss and Retransmission Recognizing packet loss Identifying missing packets Retransmission behavior TCP congestion avoidance TCP slow start

28 TCP (Reno variant) Time Sequence No X X X X Now what? - timeout Packets Acks

29 SACK Basic problem is that cumulative acks provide little information Selective acknowledgement (SACK) essentially adds a bitmask of packets received Implemented as a TCP option Encoded as a set of received byte ranges (max of 4 ranges/often max of 3) When to retransmit? Still need to deal with reordering  wait for out of order by 3pkts

30 Selective ACK (SACK ) Time Sequence No X X X X Packets Acks “Hole”

31 “Partial Progress ACK” Time Sequence No X X X X Packets Acks “Hole”

32 Outline TCP connection setup/data transfer Packet Loss and Retransmission Recognizing packet loss Identifying missing packets Retransmission behavior TCP congestion avoidance TCP slow start

33 Fast Recovery Each duplicate ack notifies sender that single packet has cleared network When < new cwnd packets are outstanding Allow new packets out with each new duplicate acknowledgement Behavior Sender is idle for some time – waiting for ½ cwnd worth of dupacks Transmits at original rate after wait Ack clocking rate is same as before loss

34 Fast Recovery Time Sequence No Sent for each dupack after W/2 dupacks arrive X Packets Acks

35 Performance Issues Timeout >> fast rexmit Need 3 dupacks/sacks Not great for small transfers Don’t have 3 packets outstanding What are real loss patterns like?

36 Outline TCP connection setup/data transfer Packet Loss and Retransmission TCP congestion avoidance TCP slow start

37 Additive Increase/Decrease T0T0 T1T1 Efficiency Line Fairness Line User 1’s Allocation x 1 User 2’s Allocation x 2 Both X 1 and X 2 increase/ decrease by the same amount over time Additive increase improves fairness and additive decrease reduces fairness

38 Muliplicative Increase/Decrease Both X 1 and X 2 increase by the same factor over time Extension from origin – constant fairness T0T0 T1T1 Efficiency Line Fairness Line User 1’s Allocation x 1 User 2’s Allocation x 2

39 What is the Right Choice? Constraints limit us to AIMD Improves or keeps fairness constant at each step AIMD moves towards optimal point x0x0 x1x1 x2x2 Efficiency Line Fairness Line User 1’s Allocation x 1 User 2’s Allocation x 2

40 TCP Congestion Control Changes to TCP motivated by ARPANET congestion collapse Basic principles AIMD Packet conservation Reaching steady state quickly ACK clocking

41 AIMD Distributed, fair and efficient Packet loss is seen as sign of congestion and results in a multiplicative rate decrease Factor of 2 TCP periodically probes for available bandwidth by increasing its rate Time Rate

42 Implementation Issue Operating system timers are very coarse – how to pace packets out smoothly? Implemented using a congestion window that limits how much data can be in the network. TCP also keeps track of how much data is in transit Data can only be sent when the amount of outstanding data is less than the congestion window. The amount of outstanding data is increased on a “send” and decreased on “ack” (last sent – last acked) < congestion window Window limited by both congestion and buffering Sender’s maximum window = Min (advertised window, cwnd)

43 Packet Conservation At equilibrium, inject packet into network only when one is removed Sliding window and not rate controlled But still need to avoid sending burst of packets  would overflow links Need to carefully pace out packets Helps provide stability Need to eliminate spurious retransmissions Accurate RTO estimation Better loss recovery techniques (e.g. fast retransmit)

44 Congestion window helps to “pace” the transmission of data packets In steady state, a packet is sent when an ack is received Data transmission remains smooth, once it is smooth Self-clocking behavior PrPr PbPb ArAr AbAb Receiver Sender AsAs TCP Packet Pacing

45 Window, Rate, Packet Pacing Time Sequence No Packets cwnd rtt

46 Congestion Avoidance If loss occurs when cwnd = W Network can handle 0.5W ~ W segments Set cwnd to 0.5W (multiplicative decrease) Upon receiving ACK Increase cwnd by (1 packet)/cwnd What is 1 packet?  1 MSS worth of bytes After cwnd packets have passed by  approximately increase of 1 MSS Implements AIMD

47 Congestion Avoidance Sequence Plot Time Sequence No Packets Acks

48 Congestion Avoidance Behavior Time Congestion Window Packet loss + retransmit Grabbing back Bandwidth Cut Congestion Window and Rate

49 How to Change Window When a loss occurs have W packets outstanding New cwnd = 0.5 * cwnd How to get to new state without losing ack clocking?

50 Outline TCP connection setup/data transfer Packet Loss and Retransmission TCP congestion avoidance TCP slow start

51 Reaching Steady State Doing AIMD is fine in steady state but slow… How does TCP know what is a good initial rate to start with? Should work both for a CDPD (10s of Kbps or less) and for supercomputer links (10 Gbps and growing) Quick initial phase to help get up to speed Called “slow start” – Why?

52 Slow Start Packet Pacing How do we get this clocking behavior to start? Initialize cwnd = 1 Upon receipt of every ack, cwnd = cwnd + 1 Implications Window actually increases to W in RTT * log 2 (W) Can overshoot window and cause packet loss

53 Slow Start Example 1 One RTT One pkt time 0R 2 1R 3 4 2R R

54 Slow Start Sequence Plot Time Sequence No Packets Acks

55 Return to Slow Start If packet is lost we lose our self clocking as well Need to implement slow-start and congestion avoidance together When retransmission occurs set ssthresh to 0.5w If cwnd < ssthresh, use slow start Else use congestion avoidance

56 TCP Saw Tooth Behavior Time Congestion Window Initial Slowstart Fast Retransmit and Recovery Slowstart to pace packets Timeouts may still occur ssthresh

57 Important Lessons TCP state diagram  setup/teardown TCP timeout calculation  how is RTT estimated Modern TCP loss recovery Why are timeouts bad? How to avoid them?  e.g. fast retransmit