TCP state meanings

More details can be found here

TCP Basic

categorynamedescription
TcpActiveOpenstcp_connect(), when sending SYN, add 1
TcpPassiveOpenstcp_create_openreq_child(), passive three-way handshake is completed, add 1
TcpAttemptFailstcp_done(): If you end a connection in the SYN_SENT/SYN_RECV state, add 1

tcp_check_req(): If there is an RST|SYN flag in the input packet in the last stage of the passive three-way handshake, add 1
TcpCurrEstabtcp_set_state(), according to ESTABLISHED is the new/old state, plus or minus one respectively.
TcpEstabResetstcp_set_state(), the new state is TCP_CLOSE, if the old state is ESTABLISHED/TCP_CLOSE_WAIT, add 1
TcpListenOverflowstcp_v4_syn_recv_sock(): After the last step of the three-way handshake is completed, add 1 when the Accept queue exceeds the upper limit
TcpListenDropstcp_v4_syn_recv_sock(): For any reason, including Accept queue exceeding limit, creating new connection, failure to inherit port, etc., add 1
TcpMaxConn0
TcpInSegstcp_v4_rcv(), receive a skb, add 1
TcpInErrstcp_rcv_established() -> tcp_validate_incoming(): If there is SYN and seq >= rcv_nxt, add 1

In the following function, if the checksum is wrong or the packet length is less than the TCP header, add 1: tcp_v4_do_rcv()tcp_rcv_established()tcp_v4_rcv()
TcpOutSegstcp_v4_send_reset(), tcp_v4_send_ack(), add 1tcp_transmit_skb(), tcp_make_synack(), add tcp_skb_pcount(skb) (see TCP_COOKIE_TRANSACTIONS)
TcpOutRststcp_v4_send_reset(), tcp_send_active_reset() plus 1

TCP Congestion Processing

categorynamedescription
TcpExtTWinet_twdr_do_twkill_work(): The number of sockets with TIME_WAIT timeout (timeout >= 4s). The reason why timewait sockets are treated as timeouts may be because the timeout time distribution of long timeout sockets is relatively scattered, and different search methods are required.
TcpExtTWKilledinet_twdr_twcal_tick(): TIME_WAIT timeout socket number. (timeout <4s), only when sysctl_tw_recycle is enabled, and TCP timestamp option is used, this will happen. At this time, 3.5x RTO is used as timewait timeout, and the default timeout is 60s
TcpExtTWRecycledtcp_v4_connect() -> __inet_check_established(): During establishment, if the port is reused from the TIME_WAIT socket, add 1
TcpExtTCPTimeWaitOverflowtcp_time_wait(): When the system cannot allocate new tcp_timewait_socket, or tw_count (scheduled timewait sockets) exceeds sysctl_max_tw_buckets, add 1
categorynamedescription
TcpExtTCPDSACKUndotcp_ack() -> tcp_fastretrans_alrt() -> tcp_try_undo_dsack()In the Disorder state, the number of undo completion (undo_retrans == 0).
TcpExtTCPFullUndotcp_ack() -> tcp_fastretrans_alrt() -> tcp_try_undo_recovery()In Recovery state, the number of times that all confirmations (snd_una >= high_seq) have been received and undo has been completed (undo_retrans == 0).
TcpExtTCPPartialUndotcp_ack() -> tcp_fastretrans_alrt() -> tcp_undo_partial()In Recovery state, the number of times that a partial confirmation (snd_una <high_seq) has been received but the undo has been completed (undo_retrans == 0).
TcpExtTCPLossUndotcp_ack() -> tcp_fastretrans_alrt() -> tcp_try_undo_loss()In Loss state, the number of times that all confirmations (snd_una >= high_seq) have been received and undo has been completed (undo_retrans == 0).
TcpExtTCPRenoReorderUpdate in tcp_update_reordering(). When metric > tp -> reordering and SACK is not enabled, this counter is incremented by 1.

In summary, when sacked_out is “unreliable”, tp -> reordering is updated to the “used seg” in the current window. “Number, including unconfirmed (and confirmed?) data, but not lost_out.

A. tcp_ack() -> tcp_fastretrans_alert() -> tcp_add_reno_sack() -> tcp_check_reno_reordering() -> tcp_update_reordering(): When receiving dupACK in the Open/Recovery/Disorder/CWR state , use the sacked_out + lost_metric> (= packets_out) call tcp_update_reordering()

B. tcp_ack() -> tcp_clean_rtx_queue() -> tcp_remove_reno_sacks() -> tcp_check_reno_reordering() -> tcp_update_reordering() : When clearing rtx queues, lost_outets_out will be subtracted from lost_packets_out The number of confirmed segs , if sacked_out + lost_out> packets_out, call tcp_update_reordering() with metric( = packets_out + acked_pcount)

Note:

sacked_out: the number of dupACK receivedlost_out: Limit the minimum value to 1 and the maximum value to packets_outtp -> reordering: When creating a socket, passively establishing a connection, and entering the Loss state, it is initialized to sysctl_tcp_reordering 
TcpExtTCPSACKReorderUpdate in tcp_update_reordering(). When metric > tp -> reordering and SACK is enabled but FACK is disabled, this counter is incremented by 1.

A. tcp_ack() -> tcp_sacktag_write_queue() -> tcp_update_reordering() will calculate faxes_out in tcp_sacktag_walk() By accumulating state.fack_count), this value is the number of segs from the beginning of snd_una to the highest sequence number of SACK (including those that are not covered by SACK). The conditions for judging the disorder are: (1) D-SACK for retransmission messages is found; (2) The currently received SACK sequence number is smaller than the largest SACK sequence number previously received. state.reord is the smallest fack_count when disorder occurs, that is, disorder occurs at “snd_una + fack_count”. metric = tp -> fackets_out-state.reord, that is, the maximum number of packets that may be out of order.

B. tcp_ack() -> tcp_clean_rtx_queue() -> tcp_update_reordering() is similar to A. tcp_clean_rtx_queue() calculates the hole in the data (non-retransmitted) that has been SACKed in the rtx queue, and the reord saves the position of the “smallest number” hole ( “Seats” in the retransmission queue). Prior_fackets-reord is the number of TCP segments that may be out of order. If there is no SACK, reorder = prior_fackets = 0 metric = prior_fackets - reord
TcpExtTCPFACKReorderSimilar to TCPSACKReorder, if SACK and FACK are enabled at the same time, this counter is increased.
TcpExtTCPTSReordertcp_ack() -> tcp_fastretrans_alrt() -> tcp_undo_partial() -> tcp_update_reordering() In the Recovery state, the number of times that a partial confirmation (snd_una <high_seq) has been received but the undo has been completed (undo_retrans == 0). The number is equal to TCPPartialUndo.r

TCP Loss & Retrans

categorynamedescription
TcpTCPTimeoutsIn the RTO timer, the number of times from the first timeout in the CWR/Open state, the remaining states are not counted in this counter. The number of SYN-ACK timeouts.
TcpRtoAlgorithm1, tcp_mib_init() initialization
TcpRtoMax120000, tcp_mib_init() initialization: TCP_RTO_MAX1000/HZ, TCP_RTO_MAX=120HZ
TcpRtoMin200, tcp_mib_init() initialization: TCP_RTO_MIN*1000/HZ, TCP_RTO_MIN=HZ/5
TcpRetransSegsThe number of retransmissions, including RTO timer and regular retransmissions, that is, tcp_transmit_skb() is called in tcp_retransmit_skb(), and the successful return is +1.
TcpTCPForwardRetrans(Non-RTO timer) The number of times to send new data, that is, in tcp_fastretrans_alrt()/tcp_simple_retransmit()->tcp_xmit_retransmit_queue(), If it is found that skb->seq> tp->retransmit_high (usually snd_una), if the current state is Recovery, SACK is enabled, and the sending conditions allow, then send new data in this function.
TcpTCPFastRetrans(Non-RTO timer) The number of fast retransmissions, ie tcp_fastretrans_alrt()/tcp_simple_retransmit()->tcp_xmit_retransmit_queue(), if it is not in the LOSS state, add 1
TcpTCPSlowStartRetrans(Non-RTO timer) retransmission times: ie tcp_fastretrans_alrt()/tcp_simple_retransmit()->tcp_xmit_retransmit_queue(), if it is in the state of LOSS, add 1
TcpTCPLostRetransmitResegment packet loss counter inferred from SACK data: in tcp_sacktag_write_queue()->tcp_mark_lost_retrans(), if tcp_highest_sack_seq(tp) is found to exceed the snd_nxt(TCB->ack_seq) of a certain skb during retransmission, it is considered that this retransmitted packet If it has been lost, add 1 (not the number of segments). tcp_highest_sack_seq(tp) is the seq of the skb with the highest SEQ number that has been SACKed.
TcpTCPSpuriousRTOsResegment packet loss counter inferred from SACK data: in tcp_sacktag_write_queue()->tcp_mark_lost_retrans(), if tcp_highest_sack_seq(tp) is found to exceed the snd_nxt(TCB->ack_seq) of a certain skb during retransmission, it is considered that this retransmitted packet If it has been lost, add 1 (not the number of segments). tcp_highest_sack_seq(tp) is the seq of the skb with the highest SEQ number that has been SACKed.

TCP Others

categorynamedescription
TcpExtTCPRenoRecoveryFail“tcp_retransmit_timer(): RTO occurs in the Reovery state, and SACK is not enabled, add 1”
TcpExtTCPRenoFailures“tcp_retransmit_timer(): In the Reorder state, or when sacked_out is not 0, RTO occurs and SACK is not enabled, add 1”
TcpExtTCPRenoRecoverytcp_fastretrans_alrt(): The number of times that TCP without SACK enters the Reovery state
TcpExtArpFilter“arp_rcv() -> NETFILTER(ARP_IN) -> arp_process()It has nothing to do with TCP. When an ARP packet is received, an output route search (sip, tip) is performed. If the device of the route item found is different from the input device, the counter is increased by 1”
TcpExtEmbryonicRststcp_v4_do_rcv() -> tcp_v4_hnd_req() -> tcp_check_req(): The number of RST or SYN received in the SYN_RECV state during the three-handed handshake.
TcpExtLockDroppedIcmps“tcp_v4_err(): ICMP error message is received, but the tcp socket is locked by the user”
TcpExOfoPruned“tcp_data_queue() -> tcp_try_rmem_schedule()In the slow path, if the data cannot be copied directly to the user space, it needs to be added to the sk_receive_queue, and the receiver side memory is checked whether it is allowed. If the rcv_buf is insufficient, it may be prune ofo queue. At this time the counter is incremented by 1”
TcpExtOutOfWindowIcmps“tcp_v4_err(): ICMP received, but the number of times the TCP header sequence number in ICMP is not within the receiving window. There are two possible situations: (1) In the LISTEN state, the sequence number does not wait for ISN; (2) In other states, the sequence number Not between SND_UNA .. SND_NXT”
TcpExtPAWSActive“tcp_rcv_synsent_state_process(): After sending SYN, ACK is received, but the number of PAWS check failures.”
TcpExtPAWSEstab“tcp_validate_incoming()tcp_timewait_state_process()tcp_check_req() enters the number of PAWS failures in the package.”
TcpExtPAWSPassivetcp_v4_conn_request(): The number of PAWS check failures for the last ACK of the three-way handshake.
TcpExtPruneCalled“tcp_data_queue() -> tcp_try_rmem_schedule()In the slow path, if the data cannot be copied directly to the user space, it needs to be added to the sk_receive_queue, and the receiver side memory is checked whether it is allowed. If the rcv_buf is insufficient, it may be prune ofo queue. At this time the counter is incremented by 1”
TcpExtRcvPruned“tcp_data_queue() -> tcp_try_rmem_schedule()In the slow path, if the data cannot be copied directly to the user space, it needs to be added before sk_receive_queue, and the receiver side memory is checked whether it is allowed. If the rcv_buf is insufficient, the prune receive queue may be prune. If prune fails, this counter is increased by 1.”
TcpExtSyncookiesFailedcookie_v4_check(): SYN cookie check failed times.
TcpExtSyncookiesRecvcookie_v4_check(): The number of times of receiving SYN cookie.
TcpExtSyncookiesSentcookie_v4_init_sequence(): The number of times the SYN cookie is generated.
TcpExtTCPAbortFailedtcp_send_active_reset(): alloc_skb() or tcp_transmit_skb() failed.
TcpExtTCPAbortOnClosetcp_close(): The number of times there is still data in sk_receive_queue.
TcpExtTCPAbortOnData“tcp_rcv_state_process(): Receive subsequent data in the FIN_WAIT_1/FIN_WAIT_2 state (serial number> RCV_NXT); or, if the TCP_LINGER2 setting value is <0, the counter is incremented by 1tcp_close(): There is no unread data, but SO_LINGER is set and linger timeout=0, the counter is incremented by 1, and the TCP is normally disconnected sk_prot->disconnect()”
TcpExtTCPAbortOnLingertcp_close(): The number of times that FIN_WAIT_2 immediately switches to CLOSE due to the TCP_LINGER2 setting value <0.
TcpExtTCPAbortOnMemory“When executing tcp_close()/probe timer/keepalive timer, whether the number of orphan sockets and tcp_memory_allocated exceed the maximum number of times.”
TcpExtTCPAbortOnSyntcp_validate_incoming(): The number of occurrences of SYN and the sequence number is greater than RCV_NXT.
TcpExtTCPAbortOnTimeoutRTO/probe/keepalive timer reaches the maximum number of retries or the maximum number of retries

TCP TIME_WAIT

categorynamedescription
TcpExtTWinet_twdr_do_twkill_work(): The number of sockets with TIME_WAIT timeout (timeout >= 4s). The reason why timewait sockets are treated as timeouts may be because the timeout time distribution of long timeout sockets is relatively scattered, and different search methods are required.
TcpExtTWKilledinet_twdr_twcal_tick(): TIME_WAIT timeout socket number. (timeout <4s), only when sysctl_tw_recycle is enabled, and TCP timestamp option is used, this will happen. At this time, 3.5x RTO is used as timewait timeout, and the default timeout is 60s
TcpExtTWRecycledtcp_v4_connect() -> __inet_check_established(): During establishment, if the port is reused from the TIME_WAIT socket, add 1
TcpExtTCPTimeWaitOverflowtcp_time_wai(): When the system cannot allocate new tcp_timewait_socket, or tw_count (scheduled timewait sockets) exceeds sysctl_max_tw_buckets, add 1