📄 net_tcp.h
字号:
#define NET_TCP_CONN_STATE_TIME_WAIT 53
#define NET_TCP_CONN_STATE_CLOSE_WAIT 55
#define NET_TCP_CONN_STATE_LAST_ACK 56
#define NET_TCP_CONN_STATE_CLOSING_DATA_AVAIL 59 /* See Note #2a. */
/*
*********************************************************************************************************
* TCP CONNECTION QUEUE STATES
*********************************************************************************************************
*/
#define NET_TCP_RX_Q_STATE_NONE 0
#define NET_TCP_RX_Q_STATE_CLOSED 100
#define NET_TCP_RX_Q_STATE_CONN_CLOSED 110
#define NET_TCP_RX_Q_STATE_CONN_CLOSING 111
#define NET_TCP_RX_Q_STATE_CONN_SYNC 120
#define NET_TCP_RX_Q_STATE_CONN 121
#define NET_TCP_TX_Q_STATE_NONE 0
#define NET_TCP_TX_Q_STATE_CLOSED 200
#define NET_TCP_TX_Q_STATE_CONN_CLOSED 210
#define NET_TCP_TX_Q_STATE_CONN_CLOSING 211
#define NET_TCP_TX_Q_STATE_CONN_SYNC 220
#define NET_TCP_TX_Q_STATE_CONN 221
#define NET_TCP_TX_Q_STATE_CONN_SUSPEND 225
/*$PAGE*/
/*
*********************************************************************************************************
* TCP CONNECTION CODE DEFINES
*********************************************************************************************************
*/
#define NET_TCP_CONN_RX_SEQ_NONE 10 /* NO rx'd TCP conn seq. */
#define NET_TCP_CONN_RX_SEQ_SYNC_INVALID 11 /* Invalid rx'd TCP conn sync. */
#define NET_TCP_CONN_RX_SEQ_SYNC 12 /* Valid rx'd TCP conn sync. */
#define NET_TCP_CONN_RX_SEQ_INVALID 15 /* Invalid rx'd TCP conn seq. */
#define NET_TCP_CONN_RX_SEQ_VALID 16 /* Valid rx'd TCP conn seq. */
#define NET_TCP_CONN_RX_ACK_NONE 20 /* NO rx'd TCP conn ack. */
#define NET_TCP_CONN_RX_ACK_INVALID 21 /* Invalid rx'd TCP conn ack. */
#define NET_TCP_CONN_RX_ACK_VALID 22 /* Valid rx'd TCP conn ack. */
#define NET_TCP_CONN_RX_ACK_DUP 23 /* Duplicate rx'd TCP conn ack. */
#define NET_TCP_CONN_RX_ACK_PREV 24 /* Prev'ly rx'd TCP conn ack. */
#define NET_TCP_CONN_RX_RESET_NONE 30 /* NO rx'd TCP conn reset. */
#define NET_TCP_CONN_RX_RESET_INVALID 31 /* Invalid rx'd TCP conn reset. */
#define NET_TCP_CONN_RX_RESET_VALID 32 /* Valid rx'd TCP conn reset. */
#define NET_TCP_CONN_RX_WIN_RESET 50 /* Reset cur rx win size. */
#define NET_TCP_CONN_RX_WIN_SET 51 /* Set cur rx win size. */
#define NET_TCP_CONN_RX_WIN_INC 52 /* Inc cur rx win size. */
#define NET_TCP_CONN_RX_WIN_DEC 53 /* Dec cur rx win size. */
#define NET_TCP_CONN_TX_ACK_NONE 120 /* Do NOT tx TCP conn ack. */
#define NET_TCP_CONN_TX_ACK 121 /* Tx TCP conn ack. */
#define NET_TCP_CONN_TX_ACK_IMMED 122 /* Tx TCP conn ack immed'ly. */
#define NET_TCP_CONN_TX_ACK_FAULT 123 /* Tx TCP conn ack on fault. */
#define NET_TCP_CONN_TX_ACK_TIMEOUT 124 /* Tx TCP conn ack on timeout. */
#define NET_TCP_CONN_TX_RESET_NONE 130 /* Do NOT tx TCP conn reset. */
#define NET_TCP_CONN_TX_RESET 131 /* Tx TCP conn reset. */
#define NET_TCP_CONN_TX_RESET_FAULT 133 /* Tx TCP conn reset on fault. */
#define NET_TCP_CONN_TX_WIN_RESET 150 /* Reset cur tx win size. */
#define NET_TCP_CONN_TX_WIN_SET 151 /* Set cur tx win size. */
#define NET_TCP_CONN_TX_WIN_INC 152 /* Inc cur tx win size. */
#define NET_TCP_CONN_TX_WIN_DEC 153 /* Dec cur tx win size. */
#define NET_TCP_CONN_TX_WIN_SEG_RXD 155 /* Update cur tx win size based on rx'd seg. */
#define NET_TCP_CONN_TX_WIN_TIMEOUT 156 /* Timeout cur tx win size. */
#define NET_TCP_CONN_TX_WIN_REMOTE_UPDATE 157 /* Update cur tx remote win size. */
#define NET_TCP_CONN_TX_WIN_CONG_INC_SLOW_START 160 /* Inc tx cong win size based on slow start. */
#define NET_TCP_CONN_TX_WIN_CONG_INC_CONG_AVOID 161 /* Inc tx cong win size based on cong avoid. */
#define NET_TCP_CONN_TX_WIN_CONG_INC_REM 162 /* Inc rem tx cong win size. */
#define NET_TCP_CONN_TX_WIN_CONG_SET_SLOW_START 165 /* Set tx cong win size to slow start th. */
#define NET_TCP_CONN_TX_WIN_CONG_SET_FAST_RECOVERY 166 /* Set tx cong win size to fast recovery th. */
#define NET_TCP_CONN_TX_WIN_CONG_SET_TIMEOUT 167 /* Set tx cong win size to timeout th. */
#define NET_TCP_CONN_TX_RTT_INIT 170 /* Init tx RTT ctrls. */
#define NET_TCP_CONN_TX_RTT_RESET 171 /* Reset tx RTT ctrls. */
#define NET_TCP_CONN_TX_RTT_CALC 175 /* Calc tx RTT calcs. */
#define NET_TCP_CONN_TX_RTT_BACKOFF 176 /* Back-off tx RTT ctrls. */
/*$PAGE*/
/*
*********************************************************************************************************
* TCP CONGESTION CONTROL DEFINES
*
* Note(s) : (1) See the following RFC's for TCP Congestion Control summary :
*
* (a) (1) RFC #2001 TCP Congestion Control
* (2) RFC #2581 Slow Start See Note #2
* Congestion Avoidance See Note #3
* Fast Re-transmit See Note #4
* Fast Recovery See Note #4
*
* (b) (1) RFC # 813 Silly Window Syndrome (SWS) See Note #5
* (2) RFC #1122
* (A) Section 4.2.2.14
* (B) Section 4.2.3.3 Receive SWS (RSWS) See Note #5a
* (C) Section 4.2.3.4 Transmit SWS (TSWS) See Note #5b
*
* (c) (1) RFC # 896 Nagle's Algorithm
* (2) RFC #1122
* (A) Section 4.2.2.14
* (B) Section 4.2.3.4
*
* (d) (1) RFC # 813, Section 5 Delayed TCP Acknowledgments See Note #6
* (2) RFC #1122, Section 4.2.3.2
* (3) RFC #2581, Section 4.2
*
* (e) RFC #1122
* (1) Section 4.2.2.2 TCP Segment PUSH
* (2) Section 4.2.2.17 Probing Zero Windows /
* TCP Persist Timer
* (3) Section 4.2.3.5 TCP Connection Failures See Note #7
* (4) Section 4.2.3.9 ICMP Error Message / See 'net_tcp.h
* TCP Congestion Recovery Note #1e'
*
*
* (2) (a) RFC #2581, Section 3.1 states that "the initial value of ssthresh [slow start threshold]
* MAY be arbitrarily high (for example, some implementations use the size of the advertised
* window)".
*
* (1) This amends RFC #2001, Section 2.1 which previously stated that "initialization for
* a given connection sets ... ssthresh to 65535 bytes".
*
* (b) RFC #2581, Section 3.1, states that "when a TCP sender detects segment loss using the
* retransmission timer, the value of ssthresh MUST be set to no more than" :
*
* (3) ssthresh = max (FlightSize / 2, 2 * SMSS)
*
* where
* (A) FlightSize Amount of outstanding data in the network
* (B) SMSS Sender Maximum Segment Size -- the size of the
* largest segment that the sender can transmit
*
* (c) 'SLOW_START_TH' (i.e. 'Slow Start Threshold') abbreviated to 'SST' for some TCP control
* constants to enforce ANSI-compliance of 31-character symbol length uniqueness.
*
* See also 'net_tcp.c NetTCP_TxConnWinSizeHandlerCongCtrl() Notes #2c1A1b & #2c2A1b'.
*
* (3) RFC #2581, Section 3.1 states that ... :
*
* (a) "The initial value of cwnd [congestion window], MUST be less than or equal to 2*SMSS
* bytes and MUST NOT be more than 2 segments."
*
* (1) This amends RFC #2001, Section 2.1 which previously stated that "initialization
* for a given connection sets cwnd to one segment".
*
* (b) "During congestion avoidance, cwnd MUST NOT be increased by more than ... 1 full-sized
* segment per RTT [TCP segment round-trip time]."
*
* (c) "Upon a timeout cwnd MUST be set to no more than ... 1 full-sized segment."
*
* See also 'net_tcp.c NetTCP_TxConnWinSizeHandlerCongCtrl() Notes #2c1A1a, #2c1A4b2,
* #2c2A1a, & #2c2A4'.
*
* (4) RFC #2581, Section 3.2 states that ... :
*
* (a) "The fast retransmit algorithm uses the arrival of 3 duplicate ACKs ... as an indication
* ... [to perform] a retransmission".
*
* (b) "When the third duplicate ACK is received," ...
*
* (1) "Set ssthresh to no more than the value given in equation 3" (see Note #2b).
*
* (2) "Set cwnd to ssthresh plus 3*SMSS. This artificially 'inflates' the congestion
* window by the number of segments (three) that have left the network."
*
* (c) "For each additional duplicate ACK received, increment cwnd by SMSS."
*
* See also 'net_tcp.c NetTCP_TxConnWinSizeHandlerCongCtrl() Notes #2c1B & #2c2B'.
*$PAGE*
* (5) (a) RFC #1122, Section 4.2.3.3 states that "the suggested SWS avoidance algorithm for the
* receiver is ... to avoid advancing the right window edge RCV.NXT+RCV.WND ... until the
* reduction satisfies" :
*
* (1) RCV.BUFF - RCV.USER - RCV.WND >= min(Fr * RCV.BUFF, Eff.snd.MSS)
*
* where
* (A) RCV.BUFF Total receive buffer space
* (B) RCV.USER Data received but not yet consumed
* (C) RCV.WND Space advertised to sender
* (D) Fr Fraction whose recommended value is 1/2
* (E) Eff.snd.MSS Effective send MSS for the connection
*
*
* See also 'net_tcp.c NetTCP_RxConnWinSizeCfgUpdateTh() Note #1'.
* & 'net_tcp.c NetTCP_RxConnWinSizeHandler() Note #3'.
*
* (b) RFC #1122, Section 4.2.3.4 states that "the sender's SWS avoidance algorithm is ...
* [to] send data" :
*
* (3) "If at least a fraction Fs of the maximum window can be sent ... Fs is a fraction
* whose recommended value is 1/2."
*
* (4) "If data is PUSHed and the override timeout occurs ... The override timeout should
* be in the range 0.1 - 1.0 seconds."
*
* See also 'net_tcp.c NetTCP_TxConnTxQ() Note #7b2'.
*
* (6) The following sections state that "a TCP SHOULD implement a delayed ACK" :
*
* (A) RFC # 813, Section 5
* (B) RFC #1122, Section 4.2.3.2
* (C) RFC #2581, Section 4.2
*
* (a) (1) (A) RFC #1122, Section 4.2.3.2 states that "in a stream of full-sized segments
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -