Computer Networks: Transmission Control Protocol (TCP)
description
Transcript of Computer Networks: Transmission Control Protocol (TCP)
Computer Networks:Transmission Control Protocol (TCP)
Ivan Marsic
Rutgers University
Chapter 2 - TCP
Transmission Control Protocol (TCP)
Chapter 2
UDP Header
UDP datagram data (if any)
16-bit source port number 16-bit destination port number
0 15 16 31
16-bit datagram length 16-bit datagram checksum
8bytes
UD
P p
ayl
oad
UD
P h
ead
er
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”
TCP (TransmissionControl Protocol)
Layer 2:
Network
Layer 1:
Link
Layer 3:
End-to-End
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 Datain IP Datagrams
Application
OSI Layer 4/5: TCP
OSI Layer 3: IP
From application: stream of bytes
Slice into TCP segments
Packetize into IP packets
TCP TCPhdr payload
TCP TCPhdr payload
TCP TCPhdr payload
TCP TCPhdr payload
IPhdr
TCP TCPhdr payload
IPhdrIP
hdrTCP TCPhdr payload
IPhdr
TCP TCPhdr payload
IPhdrIP
hdrTCP TCPhdr payload
NetworkNetwork
To application: stream of bytes
Unwrap TCP segments
Concatenate to a byte stream
TCP Header
16-bit source port number 16-bit destination port number
32-bit sequence number
flags
options (if any)
TCP segment data (if any)
0 15 16 31
16-bit TCP checksum 16-bit urgent data pointer
16-bit advertised receive window size4-bit
headerlength
unused(6 bits)
URG
ACK
PSH
RST
SYN
FIN
20bytes
32-bitacknowledgement number
TC
P p
ayl
oad
TC
P h
eade
r
Recall the IPv4 Packet Header
8-bit differentiatedservices (DS)
16-bit datagram length(in bytes)
16-bit datagram identification
options (if any)
data
0 15 16 31
8-bit time to live(TTL)
16-bit header checksum
13-bit fragment offset
4-bitversionnumber
20bytes
4-bitheaderlength
32-bit destination IP address
32-bit source IP address
8-bit user protocol
unused
DF
MF
7 8
flags
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
urgent data pointer
sequence number
Received byte stream, stored in Receive Buffer
seq. num + urg. ptr = Last Byte of Urgent Data
urgent data
Received TCP segment
non-urgent data
Retransmission Timer CalculationSearch the Web for RTT distribution measurement
0
Measured RTT value
Occ
urr
ence
fre
qu
ency
of
mea
sure
d R
TT
va
lue
s
0 1
1
2
2
RTT distribution measuredduring quiet periods
RTT distribution measuredduring peak usage periods
0
TimeoutInterval
Cases for which theRTO timer will expiretoo soon
(a)(b)
(c)
Measured RTT value
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
ClientClient ServerServer
#1
#2
#2
LISTEN(passive open)
SYN_SENT(active open)
SYN_RCVD
ESTABLISHED
ESTABLISHED
SYN 122750000:122750000(0)win 2048, <mss 1024>
ack 2363371521, win 2048
SYN 2363371521:2363371521(0)
ack 122750000, win 4096, <mss 512>
Time
Visit http://en.wikipedia.org/wiki/Network_socket to learn about network sockets
Example TCP SessionClientClient ServerServer
CongWin = 1 MSS = 512 bytesRcvWindow = 4096 bytes
CongWin = 1 + 1 = 2
CongWin = 2 +1+1 = 4
CongWin = 5 +1+1+1 = 8
#6
#7
#10
#10
#10
(TCP Sender) (TCP Receiver)
#3
#4
#4
Da
ta Tra
ns
po
rt(In
itial ph
ase
: “Slo
w S
tart”)
Gap in sequence!(buffer 512 bytes)
Gap in sequence!(buffer 1024 bytes)
#14
#10
#5
#6
#7
#8
#9
#11
#12
#13
#14
1024:1535(512), ack 0, win 2048
1536:2047(512), ack 0, win 2048
ack 1536, win 4096
2560:3071(512)
ack 2048, win 3584
ack 3584, win 4096
4096:4607(512)
4608:5119(512), ack 0, win 2048
512:1023(512), ack 0, win 2048
ack 512, win 4096
2048:2559(512), ack 0, win 2048
3072:3583(512), ack 0, win 2048
0:511(512), ack 0, win 2048
3584:4097(512), ack 0, win 2048
5120:5631(512), ack 0, win 2048
ack 5632, win 4096
ack 2048, win 4096 #7
CongWin = 4 +1 = 5
CongWin = 8 +1+1+1+1 = 12
#7
2560:3071(512)
2048:2559(512), ack 0, win 2048
3072:3583(512), ack 0, win 2048
#7
#8
#9
ack 2048, win 4096 #7
ack 2048, win 3584 (duplicate)
detail:
detail
Time
ack 3584, win 3072ack 3584, win 3584
#6
Flow vs. Congestion ControlFlow control Congestion control
Feedback:“Receiveroverflowing”
Feedback:“Not muchgetting through”
Sender
Receiver
Sender
Receiver
Sender
Receiver
Sender
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
We don’t know when sources will start/end their sessions; also their datarates are variable
Many sources and many receivers …
NetworkNetworkNetworkNetwork
(a)
RcvWin
CongWin
RcvWin
CongWin
Simplified Network Model
The entire network is abstracted as a single router – “black box”
(b)Network resourcesRepresented by “Congestion Window Size”
Receiver resourcesRepresented by “Receive Window Size”
TCP Buffer Parameters
[ Sending Application ] [ Receiving Application ]
LastByteAcked LastByteSent
FlightSize(Buffered in send buffer)
TCPsender’s
byte stream
Sent &acked
Allowed tosend
NextByteExpected LastByteRecvd
Buffered in RcvBuffer
TCPreceiver’sbyte stream
Delivered toapplication
Gap inrecv’d data
Increasingsequence num.
Increasingsequence num.
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 network3. Wait for a feedback about success rate
(acknowledgements from the receiver end)4. When the (positive/negative) feedback arrives:
a) + If the success rate is greater than zero, increase the sender window size and go to Step 2
b) – If loss is detected, decrease the sender window size and go to Step 2
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.
TCP Sender State Diagram
1. Set CongWin & SSThresh2. Send EfctWin of data, if any3. Re-start RTO timer
“Send data” 1. Set CongWin & SSThresh2. Re-send oldest outstanding segment3. Double the RTO timer & re-start it
“Retransmit”
duplicate ACK (less than 3) /new ACK /“Send data”
timeout /“Retransmit”
Start /new ACK
& (CongWin SSThresh) /“Send data”
TCP Sender
timeout /“Retransmit”
3 duplicate ACKs /“Retransmit”
(Fast retransmit)
3 duplicate ACKs /“Retransmit”
(Fast retransmit)
duplicate ACK (less than 3) /new ACK /“Send data”
Slow Start
CongWin SSThresh
for every new ACK, set:
CongWin CongWin + 1
Congestion Avoidance
MSSCongWin
CongWin SSThresh
for every new ACK, set:
CongWin CongWin + MSS
[Tahoe]
[Reno]after “fast recovery”
TCP Receiver State Diagram
In-order segment /
500 msec elapsed /Send ACK
In-order seg. /Send ACK
Out-of-order segment /Buffer it & Send dupACK
Out-of-order segment /Buffer it & Send dupACK
In-order segment, completely fills gaps /Send ACK
In-order segment,partially fills gaps /
Send ACK
Start /
Delayed acknowledging
Segments arriving in-order
TCP Receiver
(NextByteExpected = LastByteRecvd + 1)
(LastByteRecvd > NextByteExpected)
Out-of-order segments
Immediate acknowledging
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 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 DetectsSegment Loss
EventTCP
VersionTCP Sender’s Action
TimeoutTahoe
Set CongWindow = 1MSS Reno
3dup ACKs
Tahoe Set CongWindow = 1MSS
Reno
Set CongWindow =max {½ FlightSize, 2MSS} + 3MSS
Slow Start Threshold
• Determines when the “slow start” phase ends and the “congestion avoidance” phase begins
• SSThresh = max {½ FlightSize, 2MSS}
TCP Tahoe Sender
SSThresh(t) = max {½ CongWindow(t1), 2MSS} (2.4)
)1(CongWin
MSSMSS)1(CongWin)(CongWin
ttt [bytes] (2.5)
Congestion Window computation under Congestion Avoidance:Congestion Window computation under Congestion Avoidance:
(Effective Window computed as before …)
When packet loss detected via 3 dupACKs:
TCP-Tahoe Sender State Diagram
1. Set CongWin & SSThresh2. Send EfctWin of data, if any3. Re-start RTO timer
“Send data” 1. Set CongWin & SSThresh2. Re-send oldest outstanding segment3. Double the RTO timer & re-start it
“Retransmit”
timeout /“Retransmit”
Start / Slow Start
timeout /“Retransmit”
Congestion Avoidance
dupACK /
new ACK /“Send data”
new ACK /“Send data”
Fast retransmitdupACK & (count 3) /
“Retransmit”
dupACKscount = 0
new ACK & (CongWin SSThresh) /“Send data”Tahoe Sender
dupACK /
dupACK /new ACK /“Send data”
new ACK /“Send data”
Fast retransmitdupACK & (count 3) /
“Retransmit”
0 dupACKscount 3
dupACKscount = 0
dupACK /
0 dupACKscount 3
TCP-Reno Sender State Diagram
timeout /“Retransmit”
timeout /“Retransmit”
Congestion Avoidance
dupACK /
new ACK /“Send data”
new ACK /“Send data”
Fast retransmitdupACK & (count 3) /
“Retransmit”
Reno Sender
dupACK /
dupACK /
new ACK /“Send data”
new ACK /“Send data”
0 dupACKscount 3
dupACKscount = 0
dupACK /
Slow Start
timeout /“Retransmit”
new ACK & (CongWin SSThresh) /“Send data”
recovery ACK /CongWin SSThresh& “Send data”
Fas
t re
tran
smit
dupA
CK
& (
coun
t
3)/
“Ret
rans
mit”
Fast Recovery
On entry, set:
SSThresh ½ CongWinCongWin SSThresh + 3MSS
& “Send data”
0 dupACKscount 3
dupACKscount = 0
Start /
dupACK /CongWin CongWin + 1 & “Send data”
Example 2.1: TCP Bottleneck Link
10 Mbps
1 Mbps
6+1 packets
Sender Receiver
Router
Router Architecture
CPU
Memory
6 slots for packets
I/O Transmit/Receive
1 packet in transmission
Detail of Transmission Round #5
181920212227 181920212227
Sender
6 packets buffered:
171819202122 171819202122
Router Receiver
#16#17#18#19#20#21#22#23#24#25#26#27#28#29
#16#16
#17#17
#18#18
Transmission time on link_2equals 10 (Tx time on link_1)
Segment #16received
Segment #17received
Segmentstransmitted:
Time = 4 RTT
Time
Droppedpackets
LastByteA
ckedLastB
yteSent
#14#15
#29#30
FlightS
ize
LastByteR
ecvdN
extByteE
xpected
#14#15
packet #27 occupies the slot emptied by packet #17
SenderSender ReceiverReceiver
#1
#2,3
#4,5,6,7
#8,9, …,14,15
#16,17, …,22,23,…,27,28,29
#15
CongWin = 1 MSS
CongWin = 1 + 1
CongWin = 2 +1+1
CongWin = 4 +1+1+1+1
CongWin = 8 +1+…+1
7
CongWin = 1
CongWin = 1 + 1
#2
#4
#15
#23
EfctWin = 14
EfctWin = 8
8 segments sent
14 segments sent
EfctWin = 0
#8
#15,15,…,15
#15
1 RTT
2 RTT
3 RTT
4 RTT
5 RTT
6 RTT
7 RTT
8 RTT
9 RTT
1024 bytesto application
2 KBto appl
4 KBto appl
7 KBto appl
[ 1 segment lost ]
(buffer 8 KB) [ 5 segments missing ]
8 KBto appl
[ 4 segments missing ][ segment #27 buffered ]
Gap in sequence!(buffer 7 KB)
[ segment #15 missing ]
7+1 dupACKs
seg 27
seg 15 (retransmission)
ack 15
ack 23
seg 1
ack 2
dup ack 15
seg 15
7 dup ack 15
(loss)
EfctWin = 4
EfctWin = 2
EfctWin = 1
#23
#24
CongWin = 1
EfctWin = 1
CongWin = 1 + 1
EfctWin = 0
CongWin = 1 + 1
EfctWin = 0
RTO timeoutseg 23 (retransmission)
ack 24
1024 bytesto appl
[ 3 segments missing ][ segment #27 buffered ]Time [RTT]
RTO Timer Timeout Patternack 236 RTT
7 RTT
16 RTT
17 RTT
18 RTT
19 RTT
20 RTT
21 RTT
22 RTT
23 RTT
seg 25 (retransmission)
ack 26
24 RTT
seg 23 (retransmission)
ack 249 RTT
10 RTT
12 RTT
13 RTT
14 RTT
15 RTT
seg 24 (retransmission)
ack 25
RTO t-out
8 RTT
11 RTT
RTO t-out
RTO t-out
icon indicates whenRTO timer is started
TCP Tahoe (2)MSS = 1024 bytes, RcvWindow = 64 KB
12
4
8
14
10242048
4096
8192
[MSS][bytes]
EffctWin#1
#2,3
#4,5
,6,7
#8,9
, …,1
4,15
#16,
17, …
,22,
23,…
,29
#15
#23
#40,
41,4
2,43
,44
#31,
32
#45,
46,4
7,48
,49,
50
#66,
67,6
8, …
,72
#65
#73,
74
#75,
76,7
7,78
#79,
80,8
1,82
,83
1 2 3 4 5 7 8 109 11 140139 141
144143 145
148149
150
Seg
men
ts s
ent
Time
[RTT]
65535
137#2
9138
14336
1MSS
15MSS
2MSS
#33,
34,3
5
#36,
37,3
8,39
142
#51,
52,5
3, …
,57
#58,
59,6
0, …
,64,
65
6 147146
CongWin
EffctWinFlightSize
SSThresh9
6 3 dupACKs
RTO timeout
TCP Tahoe (3)
12
4
8
15
Co
ng
Win
[MS
S]
0 1 2 3 4 5 6 7 8 9 10 2423 2625 2827 3029 31 32 33 34 35 36 37 3811 2221
Multiplicative decreaseTCP Tahoe: CongWin 1 MSSTCP Reno: CongWin 1/2 FlightSize Additive increase
(Congestion avoidance)When CongWin SSThresh, for each ACK:CongWin(t) CongWin(t–1) + MSS2 / CongWin(t–1)
Slow startFor each ACK:CongWin CongWin + 1
Slow startFor each ACK:CongWin CongWin + 1
SSThresh
Time [RTT]
39
Fast retransmitRetransmit oldest un-acknowledged segment
after 3 dupACKs without waiting for RTO timeout
Retransmit based on RTO timeout(“slow retransmit”)
TCP Sender States / Phases
Defined by: Congestion Window (CW) SSThreshCongestion Window calculation:
CW(t) = CW(t – 1) + #ACKMSS
Slow Start:
Fast Retransmit:Defined as:When 3 dupACKs received,retransmit the oldest outstanding packet without waiting for RTO timeout
Defined by: Congestion Window (CW) > SSThreshCongestion Window calculation:
CW(t) = CW(t – 1) + MSS
Congestion Avoidance:
#ACKMSS
CW(t – 1)
Reno-Specific State / Phase
Fast Recovery:Defined as:When 3 dupACKs received,Congestion Window calculation:
CW(t) = max {½ FlightSize(t), 2MSS} + 3MSS
Same as for Tahoe:Slow Start, Fast Retransmit, Congestion Avoidance
( Unlike TCP Tahoe sender, which sets CW(t) = 1MSS when 3 dupACKs received )
TCP Reno Sender
SSThresh(t) = max {½ FlightSize(t1), 2MSS} (2.6)
CongWindow(t) = SSThresh(t) + 3MSS (2.7)
CongWindow = SSThresh (2.8)
(Effective Window computed as before …)
Enter Fast Recovery: count each “old ACK” as +MSS to CongWin.
When packet loss detected via 3 dupACKs:
When “new ACK” received, exit Fast Recovery and enter Congestion Avoidance.
TCP Reno (1)
2424
12
4
8
15
10242048
4096
8192
16384
[MSS][bytes]
EffctWin#1
#2,3
#4,5
,6,7
#8,9
, …,1
4,15
#16,
17, …
,22,
23,…
,29
#15,
30,…
,35,
36,3
7
#23
#38
(1 b
yte)
#24
#50
(1 b
yte)
#28
#74,
82,8
3
SSThresh
#29
#53,
54,5
5,56
#36,
57
#58
#59
(1 b
yte)
#37
#60,
61,
…,6
6
#67,
68, …
,73,
74#7
5,76
, …
,81
0 1 2 3 4 5 6 7 8 9 10 2120 2322 2524 2726 28 29 30 31 32 33 34 35
Seg
men
ts s
ent
Time
[RTT]
65535
#84,
85,…
,90,
91,…
,94,
95
36
1122
11 19
#26
18
36363737
59596666
7373
44
2323
29292828
7+1 dupACKs
881515
6 dupACKs
#39
(1 b
yte)
#40
(1 b
yte)
CongWin
EffctWin#4
1 (1
byt
e)
3 dupACKs
#47
(1 b
yte)
#48
(1 b
yte)
#49
(1 b
yte)
#51
(1 b
yte)
#52
(1 b
yte)
FlightSize
4 dupACKs
7 dupACKs
TCP Reno (2)
CongWin =
CongWin =
CongWin =
CongWin =EfctWin = 2
7168 bytesto application7168 bytes
to application
1024 bytesto appl
1024 bytesto appl
7.6 MSSEfctWin = 0
EfctWin = 1
EfctWin = 43.6
13.6
CongWin =EfctWin = 1
3.7
CongWin =EfctWin = 0
3.7
CongWin =EfctWin = 1
CongWin =EfctWin = 7
6.7
3.61327.6
6.6323.7
SenderSender ReceiverReceiver
#52 (1 byte)
#2926 RTT
#29
#3627 RTT
#36,36,36,3628 RTT
(buffer 1 byte)
Gap in sequence!(buffer 4 KB)
4 dupACKs
Time [RTT]
3 dupACKs
#53,54,55,56
#36,57
#3729 RTT
#58
#3730 RTT
#59 (1 byte)
#3731 RTT
#37
#6032 RTT
1024 + 16 + 6144bytes to application
(buffer 1024 bytes)
(buffer 1 KB)
(buffer 1 byte)3 dupACKs
#37
#60,61, …,66
seg 52 (1 byte)
ack 29
seg 29
ack 36
ack 37
seg 58
ack 37
seg 59 (1 byte)
ack 37
seg 37
ack 60
seg 36
ack 37
ack 36
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
LastByteAcked =LastByteSent
#1#1
EffectiveWindow
#2#2 #3#3 #4#4 #5#5 #6#6
NextByteExpected =LastByteRecvd + 1
LastByteRecvd
TCP Sender TCP Receiver
(loss)
(loss)
(loss)
LastByteAcked LastByteSent
FlightSize
#2#2 #4#4 #6#6
NextByteExpected
Ack#1 (duplicate)
Ack#1 (duplicate)
Ack#1 (duplicate)
Seg#1 (retransmission)
#2#2 #4#4 #6#6
NextByteExpectedLastByteRecvd
#1#1
LastByteRecvd
LOSS DETECTED(3dupACKs)
Ack#3 (partial)LOSS DETECTED(partial ACK)
Seg#3 (retransmission)
Time
Receive bufferLastByteAcked =LastByteSent
#1#1
EffectiveWindow
#2#2 #3#3 #4#4 #5#5 #6#6
NextByteExpected =LastByteRecvd + 1
LastByteRecvd
TCP Sender TCP Receiver
(loss)
(loss)
(loss)
LastByteAcked LastByteSent
FlightSize
#2#2 #4#4 #6#6
NextByteExpected
Ack#1 (duplicate)
Ack#1 (duplicate)
Ack#1 (duplicate)
Seg#1 (retransmission)
#2#2 #4#4 #6#6
NextByteExpectedLastByteRecvd
#1#1
LastByteRecvd
LOSS DETECTED(3dupACKs)
Ack#3 (partial)LOSS DETECTED(partial ACK)
Seg#3 (retransmission)
Time
Receive bufferReceive buffer
tloss
At this time define:Full acknowledgment = ACK for all 6 outstanding pkts
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 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
TCP NewReno: Example (1)
Example 2.2
txmit (Link 1) << txmit (Link 2)
tprop (Link 2) = 6 txmit (Link 2)
tprop (Link 1) << tprop (Link 2)
Sender Receiver
Link 1 4+1 packets Link 2
Router
TCP NewReno: Example (2)Example 2.2
txmit(Link 1)
txmit(Link 2)
tprop(Link 1)
Receiver
Sender/Router
1 2 3
100
pkt ack
transmission on Link 1
propagation on Link 1
transmission on Link 2
propagation on Link 2
Sender
Router
1 2 3
Receiver
Sender/Router
100
pkt ack
txmit(Link 1)
tprop(Link 1)
txmit(Link 2)
11 22 33 44 55 66 77 88 99 101011111212131314141515
Receiver
Sender/Router
10 200 30 40 50 60
16161717181920212224262830323436 42
pkt ack
3840 442323
Congestion window [segments]
Packets in flight on 2nd link
3dupACK
Packets in Router buffer
0
10
20
0
5
6
0
2525
Time [in packet transmission slots]
SSThresh = 65535 bytes
SSThresh = 11 MSS
Lost packets:23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45 (12 total)
4646
CongWin
98
11109
13121110
15141312111
32 3
54
765
76 7
15141312
151413
1514
171615
19181716
2120191817
2221201918
2422212019
2624222120
2826242221
3028262422
3230282624
3432302826
3634323028
3836343230
4038363432
4240383634
4442403836
44424038
444240
234442
234423
462546
1 232
54
6543 4
7654
765
876
987
1098
111098
12111098
14131211109
1312111098
151413121110
161514131211
171615141312
181716151413
191817161514
201918171615
212019181716
222120191817
242221201918
262422212019
282624222120
302826242221
323028262422
343230282624
363432302826
383634323028
403836343230
424038363432
444240383634
4442403836
2344424038
23444240
234442
234423 25
4625
Slow Start Fast RecoveryFast Retransmit
2727 29294949 3131 53535454 333356565757585859596060
Receiver
Sender/Router
70 8060 90 100 110 120
3535616162626363646465656666 676768686969707071717272 7474
pktack
73733939 75757676
Congestion window [segments]
Packets in flight on 2nd link
Packets in Router buffer
20
30
40
0
5
6
0
8282
Time [in packet transmission slots]
83838484
CongWin
5633
585751
4929
5231
5352
5958
605960
6135
6261
6362
6463
6564
666566
6737
6867
6968
7069
7170
7271
7372
743973
757439
767574
777675
787776
85848382
86858483
87868584
274727
57563355
58575633
605958575633
5958575633
6059585756
3560595857
6135605958
6261356059
6362613560
6463626135
656463626135
666564636261
376665646362
673766656463
686737666564
696867376665
706968676637
717069686766
727170696867
737271706968
397372717069
743973727170
757439737271
767574397372
777675743973
787776757439
797877767574
807978777675
818079787776
824181807978
838241818079
484727
2948
47474848
484748
4727
5049
5150
4929
504929
51504929
315150
50505151
5453
555455
515049
523151
535231
54535231
5554535231
5756
462546
5252
4847
5555 3737
55545352
33555453
56335554
777778787979808081814141 858586868787
797877
807978
818079
82418180
83824181
84838241
88878685
89888786
90898887
418180797877
848382418180
858483824181
868584838241
SSThresh = 11 MSS
CW = 51
Fast Recovery (cont’d)
Congestion Avoidance
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 OverheadTCP 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)