CS640: Introduction To Computer Networks: Aditya Akella TCP - Iii Reliability and Implementation Issues
CS640: Introduction To Computer Networks: Aditya Akella TCP - Iii Reliability and Implementation Issues
Computer Networks
Aditya Akella
Lecture 15
TCP – III
Reliability and Implementation Issues
Reliability
• TCP provides a “reliable byte stream”
– “Loss recovery” key to ensuring this abstraction
– Sender must retransmit lost packets
• Challenges:
– When is a packet lost?
• Congestion related losses
• Reordering of packets
– How to tell the difference between a delayed packet and
lost one?
– Variable packet delays
• What should the timeout be?
– How to recover from losses?
2
Loss Recovery in a Sliding Window
setup
• Sliding window with cumulative acks
– Receiver can only return a single “ack” sequence number to
the sender.
– Acknowledges all bytes with a lower sequence number
– Starting point for retransmission
– Duplicate acks sent when out-of-order packet received
3
Round-trip Time Estimation
• Reception success known only after one RTT
– Wait at least one RTT before retransmitting
4
Jacobson’s Retransmission
Timeout (RTO)
• Original setting:
– Round trip times exponentially averaged:
• New RTT = (old RTT) + (1 - ) (new sample)
• Recommended value for : 0.8 - 0.9
– Retransmit timer set to (2 * RTT)
– But this can lead to spurious retransmissions
• Key observation:
– At high loads round trip variance is high
• Solution:
– Base RTO on RTT and deviation
• RTO = RTT + 4 * rttvar
– new_rttvar = * dev + (1- ) old_rttvar
• Dev = linear deviation
• Inappropriately named – actually smoothed linear deviation
5
AIMD Implementation
• If loss occurs when cwnd = W
– Network can handle < W segments
– Set cwnd to 0.5W (multiplicative decrease)
– Known as “congestion control”
Cut Grabbing
Time
Packet loss
+ Timeout Congestion back
Window Bandwidth
and Rate
7
Improving Loss Recovery:
Fast Retransmit
• Waiting for timeout to retransmit is inefficient
8
Fast Retransmit
Retransmission
X
Sequence No Duplicate Acks
10
Packet Pacing
• In steady state, a packet is sent when an ack is
received
– Data transmission remains smooth, once it is smooth (steady
state)
– “Self-clocking” behavior
– When self clocking is lost send packets in a burst could
momentarily overflow network capacity
11
Preserving Clocking:
Fast Recovery
• Each duplicate ack notifies sender that single
packet has cleared network
• Behavior
– Sender is idle for some time – waiting for ½ cwnd worth
of dupacks
– Transmits at original rate after wait
• Ack clocking rate is same as before loss
12
Fast Recovery (Reno)
Sent for each dupack after
W/2 dupacks arrive
Sequence No
Packets
Acks
Time 13
Dupacks may not be enough:
Timeouts can still happen!
X
X
X
X
Now what? - timeout
X
Sequence No
Packets
Acks
Time
14
Reaching Steady State
• Doing AIMD is fine in steady state…
– But how to get to steady state?
• How does TCP know what is a good initial rate to start with?
Pb
Pr
Sender Receiver
As Ar
Ab 15
Slow Start
• Slow start
– Initialize cwnd = 1
– Upon receipt of every
ack, cwnd = cwnd + 1
• Implications
– Window actually
increases to W in RTT
* log2(W)
– Can overshoot window
and cause packet loss
16
Slow Start Example
One RTT
0R
1
One pkt time
1R 1
2
3
2R 2 3
4 6
5 7
4 5 6 7
3R
8 10 12 14
9 11 13 15
17
Return to Slow Start
• If too many packets are lost self
clocking is lost as well
– Need to implement slow-start and
congestion avoidance together
19
TCP Performance and Role of
Buffering
• Can TCP saturate a link? Depends on buffering in network
• Congestion control
– Increase utilization until… link becomes congested
– React by decreasing window by 50%
– Window is proportional to rate * RTT
• Unbuffered link
– The router can’t fully utilize the link
• If the window is too small, link is not full
• If the link is full, next window increase causes drop
• With no buffer TCP achieves 75% utilization
W Minimum window
for full
utilization
20
t
TCP Performance
• In the real world, router queues play important role
– Role of Buffers If window is larger, packets sit in queue on
bottleneck link
21
Buffered Link
W