Download presentation
Presentation is loading. Please wait.
Published byKaija Haavisto Modified over 5 years ago
1
Computer Networks: Transmission Control Protocol (TCP)
Ivan Marsic Rutgers University Chapter 2 - TCP
2
Transmission Control Protocol (TCP)
Chapter 2
3
UDP Header
4
Topic: TCP Protocol TCP Packet (“Segment”) Format
Setting Retransmission Timers Flow Control
5
TCP in the Protocol Stack
End-to-end protocol Most popular protocol in the Internet (together with IP, “TCP/IP protocol suite”
6
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
7
TCP Session Continuous stream of bytes becomes available for application to use when a connection is established and disappears when the connection is closed
8
Encapsulation of TCP Data in IP Datagrams
9
TCP Header
10
Recall the IPv4 Packet Header
10
11
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
12
Retransmission Timer Calculation
Search the Web for RTT distribution measurement
13
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 = and = 0.25
14
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 : 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)
15
TCP Connection Establishment
Visit to learn about network sockets
16
Example TCP Session
17
Flow vs. Congestion Control
18
Topic: TCP Congestion Control
TCP Tahoe TCP Reno TCP NewReno 18
19
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?
20
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
21
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” 21
22
TCP Buffer Parameters
23
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
24
TCP Congestion Control Param’s
Variable Definition MSS 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).] RcvWindow The size of the most recently advertised receiver window. CongWindow Sender’s current estimate of the available buffer space in the bottleneck router. LastByteAcked The highest sequence number currently acknowledged. LastByteSent The sequence number of the last byte the sender sent. FlightSize The amount of data that the sender has sent, but not yet had acknowledged. EffectiveWindow 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. SSThresh 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.
25
TCP Sender State Diagram
“Send data” 1. Set CongWin & SSThresh 2. Send EfctWin of data, if any 3. Re-start RTO timer “Retransmit” 1. Set CongWin & SSThresh 2. Re-send oldest outstanding segment 3. Double the RTO timer & re-start it
26
TCP Receiver State Diagram
27
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
28
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.
29
How TCP Sender Detects Segment Loss
Event TCP Version TCP Sender’s Action Timeout Tahoe Set CongWindow = 1MSS Reno 3dup ACKs Set CongWindow = max {½ FlightSize, 2MSS} + 3MSS
30
Slow Start Threshold Determines when the “slow start” phase ends and the “congestion avoidance” phase begins SSThresh = max {½ FlightSize, 2MSS}
31
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)
32
TCP-Tahoe Sender State Diagram
“Send data” 1. Set CongWin & SSThresh 2. Send EfctWin of data, if any 3. Re-start RTO timer “Retransmit” 1. Set CongWin & SSThresh 2. Re-send oldest outstanding segment 3. Double the RTO timer & re-start it
33
TCP-Reno Sender State Diagram
34
Example 2.1: TCP Bottleneck Link
35
Detail of Transmission Round #5
37
RTO Timer Timeout Pattern
Move 8 UP
38
TCP Tahoe (2) MSS = 1024 bytes, RcvWindow = 64 KB
39
TCP Tahoe (3)
40
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)
41
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 )
42
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)
43
TCP Reno (1)
44
TCP Reno (2)
45
Topic: TCP NewReno Protocol
Partial ACKs for Pkt Loss Detection Example 45
46
How TCP Sender Discovers Packet Loss
Retransmission timer (RTO) expired 3 dupACKs received Partial ACK received TCP Tahoe & TCP Reno TCP NewReno
47
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
48
TCP NewReno tloss At this time define:
Full acknowledgment = ACK for all 6 outstanding pkts
49
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
50
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
51
TCP NewReno: Example (1)
txmit (Link 1) << txmit (Link 2) tprop (Link 1) << tprop (Link 2) tprop (Link 2) = 6 txmit (Link 2)
52
TCP NewReno: Example (2)
52
53
Slow Start Fast Retransmit Fast Recovery
Neither in router nor acknowledged; black boxes symbolize packets that are sent out of order, for which the preceding packet was dropped at the router (due to the lack of router memory space)
54
Fast Recovery (cont’d)
Congestion Avoidance
55
Topic: TCP Over Wireless
Reducing Link-Layer Overheads
56
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
57
Wireless Link-layer Overhead
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.