Lecture_09_CN214 TCP_Flow & Congestion Control
Lecture_09_CN214 TCP_Flow & Congestion Control
Control
Lecture 09
M.M. Hafizur Rahman
SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data Seq=92, 8 bytes of data
timeout
timeout
SendBase=120
cumulative ACK
lost ACK scenario premature timeout covers for earlier
lost ACK
CCSIT/KFU Transport Layer 3
TCP Fast Retransmit
Host A Host B
TCP fast retransmit
if sender receives 3 additional Se q= 9
ACKs for same data (“triple 2, 8 by
Seq= data tes of
duplicate ACKs”), resend unACKed 100, 2
data
0 b yt e
s of
segment with smallest seq # X
likely that unACKed segment
lost, so don’t wait for timeout ACK
=100
timeout
=100
ACK
CK =100
A
= 10 0
Receipt of three duplicate ACKs ACK
connection has a
receive buffer:
delivers data faster data from TCP socket
than application buffers
TCP socket
layer removes App process may receiver buffers
data from socket be slow at reading
buffers? from buffer
TCP
flow control Network layer code
delivering IP datagram
receiver controls sen- payload into TCP
der, so sender won’t socket buffers IP
code
overflow receiver’s Net layer may be
buffer by transmitting fast to reading to
too much, too fast
receive buffer from sender
speed-matching service: Receiver Protocol Stack
matching the send rate to
the receiving app’s drain rate Transport Layer
CCSIT/KFU 6
TCP Segment Structure
32 bits
data data
ACKs
ACKs
data data
ACKs
ACKs
SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data Seq=92, 8 bytes of data
timeout
timeout
SendBase=120
cumulative ACK
lost ACK scenario premature timeout covers for earlier
lost ACK
CCSIT/KFU Transport Layer 22
TCP Fast Retransmit
Host A Host B
TCP fast retransmit
if sender receives 3 additional Se q= 9
ACKs for same data (“triple 2, 8 by
Seq= data tes of
duplicate ACKs”), resend unACKed 100, 2
data
0 b yt e
s of
segment with smallest seq # X
likely that unACKed segment
lost, so don’t wait for timeout ACK
=100
timeout
=100
ACK
CK =100
A
= 10 0
Receipt of three duplicate ACKs ACK
at cwnd=20
at cwnd=12
at cwnd=12
ssthresh=20/2 = 10 ssthresh=12/2 = 6
cwnd=1 cwnd=ssthresh=6
choose x choose x
req_conn(x) req_conn(x)
ESTAB ESTAB
acc_conn(x) retransmit acc_conn(x)
req_conn(
x)
ESTAB ESTAB
data(x+1) accept
data(x+1 req_conn(x)
ACK(x+1)
)
connection connection
x completes client x completes server
terminat forgets x
es
No problem! ESTAB
acc_conn(x)
Problem: half open
connection! (no client)
CCSIT/KFU Transport Layer 29
2 Way Handshake Scenarios
choose x
req_conn(x)
ESTAB
retransmit acc_conn(x)
req_conn(
x)
ESTAB
data(x+1) accept
data(x+1
retransmit )
data(x+1)
connection
x completes server
client
terminat forgets x
es req_conn(x)
ESTAB
data(x+1) accept
data(x+1
)
Problem: dup data
accepted!
CCSIT/KFU Transport Layer 30
TCP: 3 Way Handshaking
Server state
Client state
clientSocket = socket(AF_INET, SOCK_STREAM)
LISTEN
clientSocket.connect((serverName,serverPort)) LISTEN
choose init seq num, x
send TCP SYN msg
SYNSENT SYNbit=1, Seq=x
choose init seq num, y
send TCP SYNACK
msg, acking SYN SYN RCVD
SYNbit=1, Seq=y
ACKbit=1; ACKnum=x+1
received SYNACK(x)
ESTAB indicates server is live;
send ACK for SYNACK;
this segment may contain ACKbit=1, ACKnum=y+1
client-to-server data
received ACK(y)
indicates client is live
ESTAB
1. On belay?
2. Belay on.
3. Climbing.
LAST_ACK
FINbit=1, seq=y
TIMED_WAIT can no longer
send data
ACKbit=1; ACKnum=y+1
timed wait
for 2*max CLOSED
segment lifetime
CLOSED
350
300
RTT (milliseconds)
RTT (milliseconds)
250
200
sampleRTT
150
EstimatedRTT
100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
time (seconds)
SampleRTT Estimated RTT
Ans:
EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT
EstimatedRTT =