TCP Timers

Embed Size (px)

Citation preview

  • 8/2/2019 TCP Timers

    1/24

    TCP Timers

    Chia-tai Tsai

    [email protected]

  • 8/2/2019 TCP Timers

    2/24

    Introduction The 7 Timers for each Connection

    Connection-Establishment Timer

    Establish a new connection. If a response isnt received within 75 seconds, the

    connection establishment is aborted.

    Retransmission Timer

    Based on Round-Trip Time (RTT).

    TCP sends data.

    When this timer expires, TCP retransmit the data.

  • 8/2/2019 TCP Timers

    3/24

    Introduction cont. Delay ACK Timer

    Need not be acknowledged immediately.

    TCP waits up to 200 ms.

    Piggybacking

    Persist Timer

    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)

  • 8/2/2019 TCP Timers

    4/24

    Introduction cont. Keepalive Timer

    socket option SO_KEEPALIVE.

    Tests if the other end is still up and running

    Expires after 2 hours

    FIN_WAIT_2 Timer

    FIN_WAIT_1 -> FIN_WAIT_2

    Avoid a connection in the FIN_WAIT_2 state forever.

  • 8/2/2019 TCP Timers

    5/24

    Introduction cont. 2MSL Timer (TIME_WAIT Timer)

    MSL (Maximum Segment Life) 30s to 4 min

    Triggered when connection (client) enters TIME_WAIT

    state During 2MSL, the socket pair cannot be reused. (packets

    arriving during this state are discarded)

    Timer Function Fast timer

    Triggered every 200 ms

    Delay ACK Timer

    Slow timer Triggered every 500 ms

  • 8/2/2019 TCP Timers

    6/24

    Implements of the 7 TCP timers

  • 8/2/2019 TCP Timers

    7/24

    tcp_canceltimers Function tcp_timer.c

    Triggered when enters TIME_WAITstate.

    All 4 timers counters are set to 0.

  • 8/2/2019 TCP Timers

    8/24

    tcp_fasttime Function tcp_timer.c

    Delay ACK Timer

    If TF_DELACK flag is set, it is clearedand TF_ACKNOW flag is set instead.

  • 8/2/2019 TCP Timers

    9/24

    tcp_slowtime Function tcp_timer.c

    Handle the other 6 Timers Connection establishmentretransmission

    persistkeepaliveFIN_WAIT_22MSL

    Check each timer counter in all TCPCB

    Check if TCPCB has been deleted

  • 8/2/2019 TCP Timers

    10/24

    tcp_slowtime Function cont. Count idle time

    Keepalive

    FIN_WAIT_2

    Increment RTT counter

    Increment RFC 1323 timestamp value

    tcp_now

  • 8/2/2019 TCP Timers

    11/24

    tcp_timers Function tcp_timer.c

    Called by TCPs PRU_SLOWTIMOrequest

  • 8/2/2019 TCP Timers

    12/24

    tcp_timers Function cont. Case TCPT_2MSL

    (FIN_WAIT_2 and 2MSL Timers)

    2MSL Timers

  • 8/2/2019 TCP Timers

    13/24

    tcp_timers Function cont. FIN_WAIT_2 timer

  • 8/2/2019 TCP Timers

    14/24

    tcp_timers Function cont. Case TCPT_PERSIST (Persist Timer)

    Force window probe segment

    Time line of persist time

  • 8/2/2019 TCP Timers

    15/24

    tcp_timers Function cont. Case TCPT_KEEP (Connection

    Establishment and Keepalive Timers)

    Connection establishment timer andretransmission timer after SYN is sent

  • 8/2/2019 TCP Timers

    16/24

    tcp_timers Function cont.

    Keepalive timer

    Expired after 2 hours of idle time

    Drop connection who no response Send a keepalive probe

    Reset keepalive timer

  • 8/2/2019 TCP Timers

    17/24

    Retransmission Timer Calculations

    var4

    varvarvar

    rttsrttRTO

    rttdeltarttrtt

    deltagsrttsrtt

    srttntickdelta

  • 8/2/2019 TCP Timers

    18/24

    Retransmission Timer Calculations

    member Units Initial value #sec Description

    t_srtt ticks x 8 0 Smoothed RTT estimator :srtt x 8

    t_rttvar ticks x 4 24 3 Smoothed mean deviationestimator : rttvar x 4

    t_rxtcur ticks 12 6 Current retransmissiontimeout: RTO

    t_rttmin ticks 2 1Min. value for

    retransmissions timeout

    t_rxtshift null 0 Index into tcp_backoff[]array (exponential backoff)

  • 8/2/2019 TCP Timers

    19/24

    tcp_setpersist Function

    tcp_output.c

    Check retransmission timer not enabled

    Calculate RTO

    2

    var_4

    _

    4

    var_

    28

    _

    var2

    rtttsrttt

    rtttsrttt

    rttsrttRTO

  • 8/2/2019 TCP Timers

    20/24

    tcp_setpersist Function cont.

    Exponential backoff array {1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64}

  • 8/2/2019 TCP Timers

    21/24

    tcp_xmit_timer Function

    tcp_input.c

    rtt is the RTT measurement to be applied

    Timestamp option (tcp_now)

    RTT counter (t_rtt)

  • 8/2/2019 TCP Timers

    22/24

    tcp_xmit_timer Function cont.

    Update smoothed estimators and RTO

    var_8

    _

    var4

    4

    var_var_var_

    varvarvar

    __

    88

    rttt

    srttt

    RTO

    rttsrttRTO

    rtttdeltartttrttt

    rttdeltahrttrtt

    deltasrtttsrttt

    deltasrttsrtt

    deltagsrttsrtt

  • 8/2/2019 TCP Timers

    23/24

    Retransmission Timeout(tcp_timers Function cont.)

    tcp_timer.c

  • 8/2/2019 TCP Timers

    24/24

    Retransmission Timeout cont.

    Source introduction

    Increment shift count (t_rxtshift)

    Calculate new RTO

    Ask IP to find a new route

    Clear estimators

    Force retransmission of oldestunacknowledged data