Last Time: UDP Socket Programming
Last Time: UDP Socket Programming
DatagramSocket, DatagramPacket
TCP
17-1
This time
TCP
Fast retransmit
Flow control
Connection management
Congestion control
17-2
Fast Retransmit
Time-out period often If sender receives 3
relatively long: ACKs for the same data,
long delay before it supposes that segment
resending lost packet after ACKed data was
Detect lost segments lost:
via duplicate ACKs. fast retransmit: resend
Sender often sends segment before timer
many segments back-to- expires
back
If segment is lost, there
will likely be many
duplicate ACKs.
17-3
Fast retransmit algorithm:
17-4
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.4 Principles of reliable 3.6 Principles of
data transfer congestion control
3.7 TCP congestion
control
17-5
TCP Flow control: how it works
Rcvr advertises spare
room by including value
of RcvWindow in
segments
Sender limits unACKed
(Suppose TCP receiver data to RcvWindow
discards out-of-order guarantees receive buffer
segments) doesnt overflow
spare room in buffer
= RcvWindow
See the applet in UW-ACE!
= RcvBuffer-[LastByteRcvd -
LastByteRead]
17-7
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.4 Principles of reliable 3.6 Principles of
data transfer congestion control
3.7 TCP congestion
control
17-8
TCP Connection Management
Recall: TCP sender, receiver Three way handshake:
establish connection before
exchanging data segments Step 1: client host sends TCP
initialize TCP variables: SYN segment to server
specifies initial seq #
seq. #s
no data
buffers, flow control info
(e.g. RcvWindow) Step 2: server host receives SYN,
client: connection initiator replies with SYNACK segment
Socket clientSocket = new server allocates buffers
Socket("hostname","port
specifies server initial seq. #
number");
Step 3: client receives SYNACK,
server: contacted by client replies with ACK segment,
Socket connectionSocket =
welcomeSocket.accept();
which may contain data
17-9
TCP Connection Management (cont.)
closed
17-11
TCP Connection Management (cont)
TCP server
lifecycle
TCP client
lifecycle
17-12
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.4 Principles of reliable 3.6 Principles of
data transfer congestion control
3.7 TCP congestion
control
17-13
Principles of Congestion Control
Congestion:
informally: too many sources sending too much data
too fast for network to handle
different from flow control!
manifestations:
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem!
17-14
Approaches towards congestion control
Two broad approaches towards congestion control:
17-20
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.4 Principles of reliable 3.6 Principles of
data transfer congestion control
3.7 TCP congestion
control
17-21
TCP congestion control: additive increase,
multiplicative decrease
Approach: increase transmission rate (window size),
probing for usable bandwidth, until loss occurs
additive increase: increase CongWin by 1 MSS every
RTT until loss detected
multiplicative decrease: cut CongWin in half after loss
congestion
window
congestion window size
24 Kbytes
Saw tooth
16 Kbytes
behavior: probing
for bandwidth
8 Kbytes
time
time
17-23
TCP Slow Start
When connection begins, When connection begins,
CongWin = 1 MSS increase rate
Example: MSS = 1 kBytes exponentially fast until
& RTT = 200 msec first loss event
initial rate = 40 kbps
available bandwidth may
be >> MSS/RTT
desirable to quickly ramp
up to respectable rate
17-24
Refinement
Q: When should the
exponential
increase switch to
linear?
A: When CongWin
gets to 1/2 of its
value before
timeout.
Implementation:
Variable Threshold
At loss event, Threshold is
set to 1/2 of CongWin just
before loss event
17-26
Refinement: inferring loss
After 3 dup ACKs:
CongWin is cut in half
Philosophy:
window then grows
linearly 3 dup ACKs indicates
But after timeout event: network capable of
CongWin instead set to
delivering some segments
Timeout indicates a
1 MSS;
more alarming
window then grows congestion scenario
exponentially
to a threshold, then
grows linearly
17-27
Summary: TCP Congestion Control
17-28
Recap
Fast retransmit
3 duplicate ACKs
Flow control
Receiver windows
Connection management
SYN/SYNACK/ACK, FIN/ACK, TCP states
Congestion control
General concepts
TCP congestion control
AIMD, slow start, congestion avoidance
17-30
Next time
TCP
Throughput
Fairness
Delay modeling
NAT
17-31