590 likes | 827 Views
Computer Networks: Transmission Control Protocol (TCP). Ivan Marsic Rutgers University. Chapter 2 - TCP. Transmission Control Protocol (TCP). Chapter 2. UDP Header. Topic : TCP Protocol. TCP Packet (“Segment”) Format Setting Retransmission Timers Flow Control.
E N D
Computer Networks:Transmission Control Protocol (TCP) Ivan Marsic Rutgers University Chapter 2 - TCP
Transmission Control Protocol (TCP) Chapter 2
Topic:TCP Protocol TCP Packet (“Segment”) Format Setting Retransmission Timers Flow Control
TCP in the Protocol Stack • End-to-end protocol • Most popular protocolin the Internet(together with IP,“TCP/IP protocol suite”
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 bytesbecomes available for application to use when a connection is establishedand disappears when the connection is closed
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
Search the Web for RTT distribution measurement Retransmission Timer Calculation
Retransmission Timer CalculationExponential 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;
Visit http://en.wikipedia.org/wiki/Network_socket to learn about network sockets TCP Connection Establishment
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 … (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” Receiver resources Represented by “Receive Window Size” (b) Network resources Represented by “Congestion Window Size”
TCP Congestion Control Summary • Sender starts with a small window size • Send a “burst” of packets (size of the current sender window) into the network • Wait for a feedback about success rate (acknowledgements from the receiver end) • When the (positive/negative) feedback arrives: • + 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 Sender State Diagram “Send data” “Retransmit” 1. Set CongWin & SSThresh 2. Send EfctWin of data, if any 3. Re-start RTO timer 1. Set CongWin & SSThresh 2. Re-send oldest outstanding segment 3. Double the RTO timer & re-start it
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 DetectsSegment Loss • Retransmission timer (RTO) expiration • Reception of three duplicate ACKs(four identical ACKs without the arrival of any other intervening packets)Why threedupACKs: • 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.
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: Congestion Window computation under Congestion Avoidance: [bytes] (2.5)
TCP-Tahoe Sender State Diagram “Send data” “Retransmit” 1. Set CongWin & SSThresh 2. Send EfctWin of data, if any 3. Re-start RTO timer 1. Set CongWin & SSThresh 2. Re-send oldest outstanding segment 3. Double the RTO timer & re-start it
TCP Tahoe (2) MSS = 1024 bytes, RcvWindow = 64 KB
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: CW(t) = CW(t – 1) + MSS #ACKMSS 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)
Topic:TCP NewReno Protocol Partial ACKs for Pkt Loss Detection Example
How TCP Sender Discovers Packet Loss TCP Tahoe & TCP Reno TCP NewReno • Retransmission timer (RTO) expired • 3 dupACKs received • Partial ACK received
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 tloss At this time define: Full acknowledgment = ACK for all 6 outstanding pkts
TCP NewReno Fast Recovery NewReno sender entersFast Recovery when a loss is detected (by 3 dupACKs) NewReno sender exitsFast Recovery when it receives the full acknowledgement(defined at time tloss) After Fast Recovery, NewReno sender enters Congestion Avoidance
Congestion Window Calculationduring Fast Recovery NewlyAcked =LastByteAcked(t) LastByteAcked(t 1) If (NewlyAcked <MSS), thenCongWindow(t) =CongWindow(t 1) NewlyAcked Else if (NewlyAcked MSS), thenCongWindow(t) =CongWindow(t 1) NewlyAcked + MSS