• TCP/IP研究(1)-Timer(2)


    Function Partition of TCP Timer in ASIC and Firmware

                               

    Date

    Author

    Description

    2006-08-24

    Kevin

    Initialization

    TCP maintains the connection state internally and requires timers to keep track of events. TCP maintains seven timers for each connection:

    SYNACK timer

    Retransmit timer

    Delayed ACK timer

    Keepalive timer

    Zero Window Probe timer

    FinWait2 timer

    TWKill timer

     

    The operations of timer include:

    initialize timer

    clean(delete) timer

    start(restart, reset) timer

    timeout process

     

    In the document, all the former operations will be partitioned to implement by ASIC and firmware.

     

    Restart(reset) timer can be implemented by both ASIC and firmware. But timeout process can be implemented only by one instance , either ASIC or firmware.

     

    First, the document presents the conclusion Table 1, and then the analysis is following.

     

     

    TCP Timer

    Initialize

    Delete

    restart(reset) Timer

    Timeout Process

    SYNACK timer

    Firmware

    Firmware

    Firmware

    Firmware

    FIN_WAIT2 timer

    Firmware

    Firmware

    Firmware

    Firmware

    Keepalive timer

    Firmware

    Firmware

    Firmware

    Firmware

    Retransmit timer

    Firmware

    Firmware

    Firmware && ASIC

    Firmware

    Zero Window Probe timer

    Firmware

    Firmware

    Firmware && ASIC

    Firmware

    Delayed ACK time

    Firmware

    Firmware

    Firmware && ASIC

    ASIC

    TIME_WAIT Kill timer

    Firmware

    Firmware

    Firmware

    Firmware

     

     

     

     

     

                                                            Table1

    1. SYNACK timer

    timeout value is 3 seconds

     

    This timer is used when a TCP instance changes its state from LISTEN to SYN_RECV. The TCP instance of the server initially waits three seconds for an ACK. If no ACK arrives within this time, then the connection request is considered outdated.

     

    Restart( reset ) timer: implement by firmware. Because LISTEN state is handled in the Slow-Path. All of the slow-path is implement by firmware.

    Timeout process: implement by firmware. Because LISTEN state is handled in the Slow-Path. All of the slow-path is implement by firmware. And the timeout only takes place once pre connection. So, burden of SYNACK Timeout process is very very small.

    2. FinWait2 timer

    timeout value is (FIN time – 60) second.

    The expiry of this timer switches the connection from the FIN_WAIT2 state into the CLOSED state, if no FIN packet from the partner arrives.

    Restart( reset ) timer: implement by firmware. Because FIN_WAIT2 state is handled in the Slow-Path. All of the slow-path is implement by firmware.

    Timeout process: implement by firmware. Because FIN_WAIT2 state is handled in the Slow-Path. All of the slow-path is implement by firmware. And the timeout only takes place once pre connection. So, burden of FinWait2 Timeout process is very very small.

    3. Keepalive timer

    timeout value is 75 seconds or 2 hours.

     

    This timer is used to test whether a connection is still up. It is invoked for the first time after two( or nine) hours. Subsequently, nine probes are sent every 75 seconds. If all probes fail, the connection is reset.

    Keepalive is enabled via the socket option SO_KEEPALIVE, and the timeout value associated with the timer is maintained in the keepopen field of the sock structure.

     

    Only in the SYN_RCV, SYN_SENT, FIN_WAIT1, FIN_WAIT2 state, the timer should be start. ( Note: When I read the Linux code, I don’t find it is started in the ESTABLISHED state. But, I am wondered!)

    Restart( reset ) timer: implement by firmware. Because SYN_RCV, SYN_SENT, FIN_WAIT1, FIN_WAIT2 state is handled in the Slow-Path. All of the slow-path is implement by firmware.

    Timeout process: implement by firmware. Because SYN_RCV, SYN_SENT, FIN_WAIT1, FIN_WAIT2 state is handled in the Slow-Path. All of the slow-path is implement by firmware. And the timeout only takes place 9 timer pre connection in the extreme situation. So, burden of FinWait2 Timeout process is very very small.

    4. Retransmit timer

    200ms <= timeout value <= 2min

    Because the TCP protocol uses only positive acknowledgements, the sending TCP instance has to see for itself whether a segment was lost. It does this by use of the retransmit timer, the expiry of which indicates that a segment could have been lost, causing its retransmission.

    This timer is also used during the establishment of a connection. The Linux TCP sender is governed by a state machine(Open, Disorder ,CWR, Recovery,Loss) that determines the sender actions when acknowledgements arrive. In the Open substate, ASIC processes Packets; in the other state, firmware processes packets.

    Restart( reset ) timer: implement by both ASIC and firmware. Whenever send a packet, the retransmit timer should be reset.  If the sub-state is Open, ASIC should reset the retransmit timer; if the sub-state is the others, firmware should reset the retransmit timer.

     

    Timeout process: implement by and firmware. Because if RTO takes place, the substate will change to Loss. And the Loss state is handled by firmware. The timeout value

    is between 200ms and 2min, and the backoff mechanism is used five times. So, burden of RTO Timeout process is very small.

    5. Zero Window Probe timer

    timeout value is RTT*2 E backoff or a maximum of  120 seconds.

    .

    This timer is used to test for a defined time interval, to see whether the zero window still applies. The zero window timer is set when this side of the connection sends out a zero window probe in response to a zero window advertisement from the peer.

     

    Only in the ESTABLISHED state, the timer should be started.

     

    Restart( reset ) timer: implement by both ASIC and firmware. Because ESTABLISHED state is handled in both Fast-Path the Slow-Path.

    Timeout process: implement by firmware. Because timeout value is RTT*2 E backoff or a maximum of  120 seconds. If there are 16K connections in the extreme situation, the timeout will take place about 135 (16k/120) times per second.. So, burden of Zero Window Probe Timeout process is very small.

    6. Delayed ACK timer:

    40ms <= timeout value <= 200ms

    The purpose of delayed acknowledgment is to minimize the number of separate ACKs that are sent. The receiver does not send an ACK as soon as it can. Instead, it holds on to the ACK in the hopes of piggybacking the ACK on an outgoing data packet.

     

    “Characteristics of Wide-Area TCP/IP Conversations ”(1991 Cáceres et al) said: ,如果按照分组数量计算,约有一 半的T C P报文段包含成块数据(如F T P、电子邮件和U s e n e t新闻),另一半则包含交互数据 (如Te l n e t和R l o g i n)。如果按字节计算,则成块数据与交互数据的比例约为9 0 %和1 0 %。

     

    90% of TCP data is enabled by the socket option TCP_NODELAY. So, Delayed ACK timer is enabled. It is necessary to implement Delayed ACK Timer by ASIC.

     

    Restart( reset ) timer: implement by ASIC and firmware, because whenever the sender receives a data packet in Fast-Path or Slow-Path, Delayed ACK Timer should be reset. It is high frequency.

     

    Timeout process: implement by ASIC, because the timeout value  is between 40ms and 200ms, if the timeout value is 40ms , and the sender’s outgoing data packet is fewer, the timeout will take place 25 times per second. It is a bit of frequency. If there are 16k connections in the extreme situation, the timeout will take place 400k (25 * 16k) times per second. So, the timeout process should be implemented by ASIC.

    7. TWKill timer

    timeout value is 60 second.

    This timer manages the interval in the TIME_WAIT state.

     

    Restart( reset ) timer: implement by firmware. Because TIME_WAIT state is handled in the Slow-Path. All of the slow-path is implemented by firmware.

    Timeout process: implement by firmware. Because TIME_WAIT state is handled in the Slow-Path. All of the slow-path is implemented by firmware. And the timeout only takes place one pre connection. So, burden of TWKill Timeout process is very very small.

  • 相关阅读:
    c/c++字节序转换(转)
    O_DIRECT与O_SYNC区别(转)
    TCMalloc小记(转)
    内存优化总结:ptmalloc、tcmalloc和jemalloc(转)
    不依赖三方库从图像数据中获取宽高-gif、bmp、png、jepg
    Linux查看物理CPU个数、核数、逻辑CPU个数
    unix环境高级编程-3.10-文件共享(转)
    TF_Server gRPC failed, call return code:8:Received message larger than max (45129801 vs. 4194304)
    google doc上的云转换
    telnet 退出命令
  • 原文地址:https://www.cnblogs.com/e-shannon/p/10381374.html
Copyright © 2020-2023  润新知