TCP Timeout and Retransmission
description
Transcript of TCP Timeout and Retransmission
TCP/IP Illustrated Vol 1TCP/IP Illustrated Vol 1
TCP Timeout andTCP Timeout andRetransmissionRetransmission
2005. 5. 2( 월 )이 병 희
IntroductionIntroduction TCP provides a reliable transport
Each end send acknowledgment to the other end when receive data
Data and acknowledgment can get lost TCP handles this by setting a timeout when it sends
data and retransmits data
TCP manages four different timers retransmission timer persist timer keepalive timer 2MSL timer
RTT MeasurementRTT Measurement Timeout should be based on Round-trip time
(RTT) RTT measured by observing difference between
time of transmission and arrival of acknowledgment
SRTT = αSRTT + (1 – α)RTTRTO = β SRTT
It can’t keep up with wide fluctuations in the RTT causing unnecessary retransmissions
RTO measurement in RFC1122 Err = RTT – SRTT SRTT = SRTT + gErr D = D + h( |Err| - D) RTO = SRTT + 4D
RTT Measurement ExampleRTT Measurement Example The timer increment a counter
every time the 500ms The starting Seq number is
remembered
Karn’s AlgorithmKarn’s Algorithm When timeout occurs and packet is
retransmitted 송신 호스트는 RTT 연산에 대해 혼선 Is the ACK for the first transmission or second ?
Do not update the RTT until an ACK is received for a segment that was not retransmitted
if TCP timestamp option is used, we don’t need to apply Karn’s Algorithm
Segment1,Seq =1010
ACK, Seq=1010
Segment1,Seq =1010Segment1
Retransmission
Congestion Avoidance AlgorithmCongestion Avoidance Algorithm assumption of the algorithm
packet loss caused by damage is very small the loss of a packet signals congestion
Congestion Avoidance and Slow Start algorithm Initialization of the connection sets cwnd to one and ssthresh to 65535bytes
When congestion occurs, one-half of the current window size is saved in ssthresh. If congestion is indicated by timeout, cwnd is set to one.
When new data is acknowledged by the other end, cwnd is increased
Congestion Avoidance AlgorithmCongestion Avoidance Algorithm If cwnd is less than or equal to ssthresh, doing slow
start. otherwise doing congestion avoidance.
slow start has cwnd start at one segment, and be incremented by one segment every time an ACK is received
congestion avoidance dictates that cwnd be incremented by 1/cwnd each time an ACK is received
Fast Retransmit and Fast RecoveryFast Retransmit and Fast Recovery Fast Retransmission
If Sender receive three or more duplicate ACK in a row, Sender retransmit the missing segment without waiting for a retransmission timer to expire
Fast Recovery After fast retransmission, sender do congestion
avoidance Set ssthresh to one-half of the minimum of current cwnd and
receiver’s advertised window Set cwnd to ssthresh + 3(segment size) Each time another duplicate ACK arrives, increment cwnd by
the segment size and transmit packet When the next ACK arrives that acknowledges new data set
cwnd to ssthresh
Congestion exampleCongestion example segment 45 got lost
Receiver send duplicated ACK Sender get three duplicated
ACKs in a row Sender starts fast retransmission
TCP/IP Illustrated Vol 1TCP/IP Illustrated Vol 1
TCP Persist TimerTCP Persist Timer
TCP Persist TimerTCP Persist Timer When window size goes to ‘0’, Sender stops
transmitting data until the window becomes nonzero
If an ACK is lost, both sender and receiver are waiting for the other
To prevent deadlock, sender use persist timer
7169:8193(1024) ack1 win 4096
ACK 9217 win 0
8193:9217(1024) ack1 win 4096
ACK 9217 win 4096
TCP Persist TimerTCP Persist Timer After segment13, sender set persist timer If sender doesn’t receive window update when timer
expire, it send window probes
persist timer start
send window probes
svr4bsdi
(11)
(12)
(13)
(14)
(15)
Silly Window SyndromeSilly Window Syndrome It can be caused by either side
Receiver advertise small size windows Sender transmit small amount of data
Ways to prevent silly window syndrome Receiver side
must not advertise small window use delay ACK
Sender side must not transmit data until full-size or at least one-half of
maximum window size sender can send everything when we are not excepting an
ACK
SWS exampleSWS example
sun.1069
PSH 1:1025(1024) ack 1, win 4096
PSH 1025:2049(1024) ack 1, win 4096
bsdi.7777
PSH 2049:3073(1024) ack 1, win 4096
PSH 3073:4097(1024) ack 1, win 4096
ack 4097, win 0
1 2
3
4
54097:4098(1) ack 1, win 40966
ack 4098, win 0 74098:4099(1) ack 1, win 40968
ack 4099, win 0 9
4099:4100(1) ack 1, win 409610
ack 4100, win 1533 11
0.0
0.002026(0.0020)
0.003737(0.0017)
0.005361(0.0016)
0.170306(0.1649)5.151768(4.9815)
5.170308(0.0185)10.151592(4.9813)
10.170299(0.0187)
15.151466(4.9812)
15.170296(0.0188)
SWS exampleSWS example
12
13
14
15
16
17
18
19
20
21
4100:5124(1024) ack 1, win 4096
ack 5124, win 509
5124:5633(509) ack 1, win 4096
ack 5633, win 0
5633:5634(1) ack 1, win 4096
ack 5634, win 1279
FIN, PSH 5634:6145(511) ack 1, win 4096
ack 6146, win 767
ack 6146, win 2816
FIN 1:1(0) ack 6146, win 4096
ack 2, win 409622
sun.1069 bsdi.7777
15.172006(0.0017)
15.370307(0.1983)20.151782(4.7815)
20.170297(0.0185)25.151162(4.9809)
25.170302(0.0191)25.171801(0.0015)
25.174401(0.0026)39.991658(14.8173)
51.991775(12.0001)
51.992665(0.0009)
SWS exampleSWS example
Action Receiver bufferTime Segment#
(Fig. 22.2) Send TCP Receive TCP Application data available
0.000 1 1:1025(1024) 1024 30720.002 2 1025:2049(1024) 2048 2048
0.003 3 2049:3073(1024) 3072 1024
0.005 4 3073:4097(1024) 4096 0
0.170 5 ACK 4097, win 0
3.99 read 256 3840 256
5.151 6 4097:4098(1) 3841 255
5.17 7 ACK 4098, win 0
5.99 read 256 3585 511
7.99 read 256 3329 767
9.99 read 256 3073 1023
10.151 8 4098:4099(1) 3074 1022
10.170 9 ACK 4099, win 0
11.99 read 256 2818 1278
13.99 read 256 2562 1534
15.151 10 4099:4100(1) 2563 1533
15.170 11 ACK 4100, win 1533
15.172 12 4100:5124(1024) 3587 509
15.370 13 ACK 5124, win 509
SWS exampleSWS example
Action Receiver bufferTime Segment#
(Fig. 22.2) Send TCP Receive TCP Application Data Available
15.370 13 ACK 5124, win 50915.99 read 256 3331 765
17.99 read 256 3075 1021
19.99 read 256 2819 1277
20.151 14 5124:5633(509) 3328 768
20.17 15 ACK 5633, win 0
21.99 read 256 3072 1024
23.99 read 256 2816 1280
25.151 16 5633:5634(1) 2817 1279
25.170 17 ACK 5634, win 1279
25.171 18 5634:6145(511) 3328 768
25.174 19 ACK 6146, win 767
25.99 read 256 3072 1024
39.99 read 256 1280 2816
39.99 20 ACK 6146, win 2816
51.99 read 256(EOF) 0 4096
51.991 21 ACK 6146, win 4096
51.992 22 ACK 2
TCP/IP Illustrated Vol 1TCP/IP Illustrated Vol 1
TCP Keepalive TimerTCP Keepalive Timer
TCP Keepalive TimerTCP Keepalive Timer Introduction
If there are no data exchange between TCP connection, the connection remains established
Even if intermediate routers are crashed or lines are down, the connection remains established
Keepalive option provides capability that server can know whether client is down
If intermediate router has crashed, keepalive will think that the client is down and terminate connection
DescriptionDescription States of client and server
If there is no activity for two hours, the server sends a probe segment to the client
State of Client’s host and Server Server’s Action
The client’s host is running and reachable from the server
Server’s TCP will reset keepalive timer for 2 hours.
If data across the TCP connection before expire, timer is reset for 2 hours again.
The client’s host has crashed and is either down or in the process of rebooting
Server will not receive response in 75 second. Server sends total 10 probes, 75 second apart. If no response, server will terminate the connection
The client’s host has just rebooted
Because client has just rebooted, server will receive response but it will be a reset. So, server terminates the connection
The client’s host is running, but unreachable from the server
Same as client’s down. Server terminates the connection after 10 probes, 75 second apart.
Keepalive ExampleKeepalive Example
bsdi % sock –K svr4 echo hello, world hello, world
- disconnect cable –(4 hours later) read error: Connection timed out
first keepalive probe(2 hours later)
second keepalive probe(4 hours later)
• Other End Crashes
Keepalive ExampleKeepalive Example• Other End Crashes and Reboot
bsdi % sock –K svr4 echo hi there hi there
read error: Connection reset by peer
first keepalive probe(2 hours later)
Keepalive ExampleKeepalive Example• Other End is Unreachable
slip % sock –K vangogh.cs.berkeley.edu echo testing testing
- link is down (3 hours later) - read error: No route to host
ClientServer
Terminate the connection
Router(alive)
Router(down)
first keepalive probe(2 hours later)
second keepalive probe(4 hours later)