📄 tcp.h
字号:
int sv_abort; /* # of retransmissions to go before aborting */ u32 sv_srtt; /* smooth round-trip time in milliseconds */ u32 sv_retrtim; /* Value currently being used for retransmission timeout. Nornally is a constant factor times the smooth round trip time, but when retransmissions are occuring, gets increased until a valid round trip time can be measured again (KARN's algorithm) */ u32 sv_trtt; /* 't_time' when 'sv_brtt' was first sent */ u32 sv_resync; /* timer sequence number at 'sv_trtt' sample */ m32 sv_brtt; /* sequence number of byte we are timing */ u32 sv_initretrim; /* Initial value of the retransmission timeout, from compiler constant INITIAL_REX_DELAY unless overridden by socket option. */ u32 sv_minretrim; /* Minimum value of retransmission timeout, from compiler constant MIN_REX_DELAY unless overridden by socket option. If computed value of retransmission timeout (based on measured round trip time) is less than this value, this value will be used. */ u32 sv_maxretrim; /* Maximum value of retransmission timeout, from compiler constant MAX_REX_DELAY unless overridden by socket option. If computed value of retransmission timeout (based on measured round trip time) exceeds this value, this value will be used.*/#ifdef TCP_RETRANSMIT_ENHANCEMENTS u32 sv_numdupacksrcvd; /* Counts the number of consecutive duplicate ACKS received. Zeroed when an ACK is received which ACKs new data or when the retransmission timer times out. Incremented when an ACK which ACKS no new data (a duplicate ACK) is received. When the 3rd consecutive duplicate ACK is received, retransmission is triggered. Incrementing beyond the 3rd will invoke processing related to "fast recovery" */#define TCP_DUP_ACKS_RETR_TRIGGER 3 m32 sv_rexmt_seqno; /* When TCP goes into retransmit mode (either because of duplicate ACKs or due to a retransmit timeout), it retransmits frames, one at a time, until the "gap" in the peer's receive buffer is filled. This activity may be going on in parallel with new data also being transmitted (if the send window permits it). The "next sequence number to send" for the sending of new data is kept track ov with the "sv_spsh" field. This new field, "sv_rexmt_seqno" serves a similar function for the retransmission activity. The details of how this field is used/updated depends on which algorithm(s) are enabled (e.g.,slow/start/ congestion avoidance/selective acks. */ int sv_retr_window; /* Counts how many segmnts we have "permission" to retransmit, based on how many ACKs we have received vs. how many packets we have retransmitted */ u32 sv_rexmt_gaplen; /* The length of the known "gap" in the peer's receive buffer, starting from "sv_rexmt_seqno". Limits the length of the segment that tcp_sqxmit will retransmit, if this figure is less than the MSS. Prevents uneccesarily retransmitting data beyond the end of the gap */ m32 sv_rexmt_spsh; /* Remembers how much data had been sent at the time we went into retransmission mode. Helps keep us from being tricked into unecessarily retransmitting new data that gets sent while we are in retransmission mode. */#endif /* TCP_RETRANSMIT_ENHANCEMENTS */#ifdef TCP_SELACK_ENHANCEMENTS /* Variables pertaining to incoming selective acknowledgements. Maintained in sorted order, so that this will give us a picture of the peer's receive buffer in terms of what segments the peer has received or not received. */ int sv_num_in_sack_blocks; tcp_sack_block_ sv_in_sack_blocks[MAX_NUM_IN_SACK_BLOCKS];#endif /* receive and acknowledgment smarts */ struct tcb * sv_acktcb; /* acknowledgement timer */ struct tcb * sv_perftcb;/* performance timer */ u32 sv_ackdelay; /* delay for ACK's in milliseconds */ int sv_ackEveryN; /* Indicates how many segments (of full MSS size) received will cancel the delayed ACK timer and trigger an ACK. This is a generalization of the "ack every other segment" mechanism where the number of segments to trigger an ACK is configureable via socket option */ u32 sv_rwindow; /* current (active) receive window */#ifdef TCP_WND_SCALE u16 sv_rwndscale; /* Recieve window scale */#endif#ifdef TCP_TIMESTAMPS u32 sv_recent_rx_tmstmp; /* TS.Recent as defined in RFC 1323 section 3.4 */#ifdef TCP_PAWS u32 sv_rx_tmstmp_update_time; /* The time (t_clicks) at which sv_recent_rx_tmstmp was last updated. Used to measure how long connection has been idle during PAWS processing -- see RFC 1323 section 4.2.3 */#endif m32 sv_last_ack_sent; /* Last.ACK.Sent as defined in RFC 1323 section 3.4 */#endif u32 sv_rsclicks; /* beginning of sampling time */ int sv_rcvsncwupd; /* bytes read from socket since last window update sent */ int sv_sqcntdwn; /* countdown for Source Quench recovery */#ifdef TCP_KEEP_ALIVE u16 sv_ka_type; /* NONE/TRY_NOGD/TRY_GD/GARBAGE_DATA/NO_GARBAGE */ u16 sv_ka_retrycnt; /* retry count */ tcb * sv_ka_tcb; /* tcp_timer */#endif /* variables pertaining to the re-use of message buffers containing mss-sized data segments to avoid freeing/allocation of them, to improve performance */#define MAX_HOLD_MSS_SIZED_MSGS 2 m *sv_tcp_mss_sized_msgs[MAX_HOLD_MSS_SIZED_MSGS]; /* array to hold pointers to messages that we can re-use on this connection */ int sv_num_mss_sized_msgs; /* variables pertaining to the re-use of message buffers containing acks to avoid freeing/allocation of them, to improve performance */#define MAX_HOLD_ACK_SIZED_MSGS 2 m *sv_tcp_ack_sized_msgs[MAX_HOLD_ACK_SIZED_MSGS]; /* array to hold pointers to messages that we can re-use on this connection */ int sv_num_ack_sized_msgs; /* variables pertaining to "urgent" data processing */ u8 sv_urg_mode; /* inline or out-of-band, out-of-band default */#define SV_URGMODE_OOB 0#define SV_URGMODE_INLINE 1 u8 sv_urg_state; /* what state are we in with respect to urgent data */#define SV_URGSTATE_NONE 0 /* no urgent pointer, no data */#define SV_URGSTATE_NODATA 1 /* urgent pointer, data not here yet */#define SV_URGSTATE_DATA 2 /* urgent pointer, urgent data has arrived */ u8 sv_urg_buf; /* contains the urgent byte, when and only when sv_urg_state is SV_URGSTATE_DATA */#ifdef TCP_SELACK_ENHANCEMENTS /* Variables pertaining to outgoing selective acknowledgements. Maintained in parallel to updates to the hold queue, contains the information from which the "selective acknowledgement" TCP option is constructed in outgoing segments. */ /* The sequence numbers in the sack blocks will be stored in network order. */ int sv_num_out_sack_blocks; tcp_sack_block_ sv_out_sack_blocks[MAX_NUM_OUT_SACK_BLOCKS];#endif#ifdef SV_SKEPTIC u32 * sv_ref[MAXREF]; /* references */ u32 sv_overflow; /* count of references that didn't fit in sv_ref */#endif#ifdef TCP_TRANSACTION_TCP u16 sv_t_tcp_flags; /* flags pertaining to transaction TCP operation */ /* Variables pertaining to a connection which is operating according to the transaction TCP protocol extensions. These variables are used only if the SV_TRANSACTION is set in sv_flags2 */ u32 sv_ccsend; /* The CC option value to send in segments on this connection. Initialized from the global connection counter. */ u32 sv_ccrecv; /* the CC option value received in the first segment from the other end of this connection, and expected to be received in subsequent segments. */ u32 sv_start_time; /* The time (in terms of t_time) when this connection was opened. Used when connection goes into TIME_WAIT to determine whether or not the connection duration is less than an MSL. This in turn is used to determine whether a subsequent duplicate connection while this one is in the TIME_WAIT state can abort this one's TIME_WAIT state and be accepted. */#endif /* TCP_TRANSACTION_TCP */} tcpsv_t;#ifdef SOCKET_USE_OLD_SOCKOPT_FUNCTIONS#define SET_SVSOCKET_OPTION_ON(s,n) s->sv_soptions |= n#define SET_SVSOCKET_OPTION_OFF(s,n) s->sv_soptions &= ~(n)#define GET_SVSOCKET_OPTION_STATUS(s,n) ((s->sv_soptions & n) ? n : 0 )#else#define SET_SVSOCKET_OPTION_ON(s,n) s->sv_soptions |= (1 << n)#define SET_SVSOCKET_OPTION_OFF(s,n) s->sv_soptions &= ~(1 << n)#define GET_SVSOCKET_OPTION_STATUS(s,n) ((s->sv_soptions & (1 << n) ) ? n : 0 )#endif#define rwnd(sop) gq_left(&(sop)->so_rq) /* Receive window */#define rwndmax(sop) (sop->so_rq.gq_max) /* Maximum possible receive window */#define sv_valid_sop(svp, sop) ((svp&&((sop = svp->sv_sop) != (so_t *)0)&&(sop == sop_tbl[svp->sv_soindx])) ? sop : (so_t *)0)#define FBITS(f) ((u16)((f)|((SIZEOF_TCPH_T) << 10)))#ifdef DEBUG#define set_state(msg, svp, x) sv_nstate(msg, svp, (u16)(x))#define tcp_er(err, msg) err#else/* next line was changed to allow mixing of TCP modules w/ DEBUG and those * without */#define set_state(msg, svp, x) sv_nstate((char *)0, svp, (u16)(x))#endif/*********************//* codes in sv_flags */#define SV_RFINFLG ((u16)0x1) /* FIN seen */#define SV_SFINFLG ((u16)0x2) /* FIN sent */#define SV_PASSIVE ((u16)0x4) /* open mode is passive or ~active */#define SV_UPSEND_PENDING ((u16)0x8) /* transmit has been scheduled after processing an ACK */#define SV_RECOVZWIN ((u16)0x10) /* recovering from a receive window that reached zero -- silly window avoidance measures are in effect */#define SV_EOF ((u16)0x20) /* timer needs to generate EOF */#define SV_EMPTYACK ((u16)0x40) /* ACK when window opens fully */#define SV_TSYNFLG ((u16)0x80) /* send a SYN */#define SV_TFINFLG ((u16)0x100) /* send a FIN */#define SV_RIP ((u16)0x200) /* retransmission in progress */#define SV_NOPROBE ((u16)0x400) /* no probing allowed! */#define SV_SEQNO ((u16)0x800) /* state vector contains sequence numbers */#define SV_XTIME ((u16)0x1000) /* round trip timing is in progress */#define SV_SENDING ((u16)0x2000) /* send currently in progress *//* 0x4000 is available */#define SV_DATACK ((u16)0x8000) /* unACKed data has been received *//* Description of the tcp state flags in sv_flags * * SV_RFINFLG : * Indicates that a FIN was received. * * SV_SFINFLG : * Indicates that a FIN was transmitted. * * SV_PASSIVE : * Indicates the type of open request. Set indicates that the open * was passive (listen, accept). Clear indicates that the open was * active (connect). * * SV_UPSEND_PENDING: * Indicates that we are in the time between scheduling a trnsmission * cycle after consuming an ACK/window update and that cycle actually * being invoked. Some other task may invoke a transmission cycle * between the scheduling and the invocation. In that case, the * scheduled invocation is redundant, and would unecessarily consume * CPU cycles. So this flag is used to prevent that. * * SV_EOF : * Used to indicate to the timer, that an End-Of-File packet should * be generated and placed on the receive queue. This is used when * a FIN is received, but there are no resources available to generate * the EOF. The timer will periodically check this flag and try to * gen the EOF until it is successful, at which time it will turn it * off. * * SV_EMPTYACK : * Need to send immediate ACK's when window opens fully, presumably * because the sender does better when this is done. * * SV_TSYNFLG : * Indicates to the transmission routines to send a SYN. Set by * tcp_gsyn, and cleared when the SYN is ACKnowledged. * * SV_TFINFLG : * Indicates to the transmission routines to send a FIN. Set by a * close or a shutdown, and cleared when the FIN is ACKnowledged. * * SV_NOPROBE : * Indicates that a probe was just recently sent, and further * probes are disallowed. * * SV_RIP : * Set by the timer when a retransmission cycle occurs. Used by the * transmission routines to determine whether or not to retransmit or * send new data. * * SV_SENDING : * Set by the data sending routine ('tcp_sqxmit') when it is in the * act, preventing unnecessary send calculation time and minimizing * out-of-order generation of packets. * * SV_MSSACK : * Indicates to 'tcp_recv' that an ACKnowledgement has been deferred * until the receive window opens to more than 1 MSS. * * SV_DATACK : * Indicates that data has been received (queued to ULP) which has * yet to be ACKnowledged. Absence of this bit coalesces window * openings until the window becomes fully open (or some more * data arrives of course). */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -