TCP Timers Chiatai Tsai taicis nctu edu tw

  • Slides: 24
Download presentation
TCP Timers Chia-tai Tsai tai@cis. nctu. edu. tw

TCP Timers Chia-tai Tsai tai@cis. nctu. edu. tw

Introduction n The 7 Timers for each Connection n Connection-Establishment Timer n n n

Introduction n The 7 Timers for each Connection n Connection-Establishment Timer n n n Establish a new connection. If a response isn’t received within 75 seconds, the connection establishment is aborted. Retransmission Timer n n n Based on Round-Trip Time (RTT). TCP sends data. When this timer expires, TCP retransmit the data.

Introduction cont. n Delay ACK Timer n n Need not be acknowledged immediately. TCP

Introduction cont. n Delay ACK Timer n n Need not be acknowledged immediately. TCP waits up to 200 ms. Piggybacking Persist Timer n n n Based on RTT Triggered when a null window is advertised If timer expires, sender issues a probe (between 5 and 60 s, never gives up)

Introduction cont. n Keepalive Timer n n socket option SO_KEEPALIVE. Tests if the other

Introduction cont. n Keepalive Timer n n socket option SO_KEEPALIVE. Tests if the other end is still up and running Expires after 2 hours FIN_WAIT_2 Timer n n FIN_WAIT_1 -> FIN_WAIT_2 Avoid a connection in the FIN_WAIT_2 state forever.

Introduction cont. n 2 MSL Timer (TIME_WAIT Timer) n n MSL (Maximum Segment Life)

Introduction cont. n 2 MSL Timer (TIME_WAIT Timer) n n MSL (Maximum Segment Life) 30 s to 4 min Triggered when connection (client) enters TIME_WAIT state During 2 MSL, the socket pair cannot be reused. (packets arriving during this state are discarded) Timer Function n Fast timer n n n Triggered every 200 ms Delay ACK Timer Slow timer n Triggered every 500 ms

Implements of the 7 TCP timers

Implements of the 7 TCP timers

tcp_canceltimers Function n tcp_timer. c Triggered when enters TIME_WAIT state. All 4 timers counters

tcp_canceltimers Function n tcp_timer. c Triggered when enters TIME_WAIT state. All 4 timers counters are set to 0.

tcp_fasttime Function n tcp_timer. c Delay ACK Timer If TF_DELACK flag is set, it

tcp_fasttime Function n tcp_timer. c Delay ACK Timer If TF_DELACK flag is set, it is cleared and TF_ACKNOW flag is set instead.

tcp_slowtime Function n n tcp_timer. c Handle the other 6 Timers n n n

tcp_slowtime Function n n tcp_timer. c Handle the other 6 Timers n n n Connection establishment、retransmission、 persist、keepalive、FIN_WAIT_2、2 MSL Check each timer counter in all TCPCB Check if TCPCB has been deleted

tcp_slowtime Function cont. n Count idle time n n Keepalive FIN_WAIT_2 Increment RTT counter

tcp_slowtime Function cont. n Count idle time n n Keepalive FIN_WAIT_2 Increment RTT counter Increment RFC 1323 timestamp value n tcp_now

tcp_timers Function n n tcp_timer. c Called by TCP’s PRU_SLOWTIMO request

tcp_timers Function n n tcp_timer. c Called by TCP’s PRU_SLOWTIMO request

tcp_timers Function cont. n Case TCPT_2 MSL (FIN_WAIT_2 and 2 MSL Timers) n 2

tcp_timers Function cont. n Case TCPT_2 MSL (FIN_WAIT_2 and 2 MSL Timers) n 2 MSL Timers

tcp_timers Function cont. n FIN_WAIT_2 timer

tcp_timers Function cont. n FIN_WAIT_2 timer

tcp_timers Function cont. n Case TCPT_PERSIST (Persist Timer) n n Force window probe segment

tcp_timers Function cont. n Case TCPT_PERSIST (Persist Timer) n n Force window probe segment Time line of persist time

tcp_timers Function cont. n Case TCPT_KEEP (Connection Establishment and Keepalive Timers) n Connection establishment

tcp_timers Function cont. n Case TCPT_KEEP (Connection Establishment and Keepalive Timers) n Connection establishment timer and retransmission timer after SYN is sent

tcp_timers Function cont. n Keepalive timer n n Expired after 2 hours of idle

tcp_timers Function cont. n Keepalive timer n n Expired after 2 hours of idle time Drop connection who no response Send a keepalive probe Reset keepalive timer

Retransmission Timer Calculations

Retransmission Timer Calculations

Retransmission Timer Calculations member Units Initial value #sec Description t_srtt ticks x 8 0

Retransmission Timer Calculations member Units Initial value #sec Description t_srtt ticks x 8 0 t_rttvar ticks x 4 24 3 Smoothed mean deviation estimator : rttvar x 4 t_rxtcur ticks 12 6 Current retransmission timeout: RTO t_rttmin ticks 2 1 Min. value for retransmissions timeout t_rxtshift null 0 Smoothed RTT estimator : srtt x 8 Index into tcp_backoff[] array (exponential backoff)

tcp_setpersist Function n tcp_output. c Check retransmission timer not enabled Calculate RTO

tcp_setpersist Function n tcp_output. c Check retransmission timer not enabled Calculate RTO

tcp_setpersist Function cont. n Exponential backoff array n {1, 2, 4, 8, 16, 32,

tcp_setpersist Function cont. n Exponential backoff array n {1, 2, 4, 8, 16, 32, 64, 64, 64, 64}

tcp_xmit_timer Function n n tcp_input. c rtt is the RTT measurement to be applied

tcp_xmit_timer Function n n tcp_input. c rtt is the RTT measurement to be applied n n Timestamp option (tcp_now) RTT counter (t_rtt)

tcp_xmit_timer Function cont. n Update smoothed estimators and RTO

tcp_xmit_timer Function cont. n Update smoothed estimators and RTO

Retransmission Timeout (tcp_timers Function cont. ) n tcp_timer. c

Retransmission Timeout (tcp_timers Function cont. ) n tcp_timer. c

Retransmission Timeout cont. n Source introduction n n Increment shift count (t_rxtshift) Calculate new

Retransmission Timeout cont. n Source introduction n n Increment shift count (t_rxtshift) Calculate new RTO Ask IP to find a new route Clear estimators Force retransmission of oldest unacknowledged data