-typedef struct _tcp_connection
-{
- transport_connection_t connection; /**< Common transport data. First! */
-
- u8 state; /**< TCP state as per tcp_state_t */
- u16 flags; /**< Connection flags (see tcp_conn_flags_e) */
- u32 timers[TCP_N_TIMERS]; /**< Timer handles into timer wheel */
-
- /* TODO RFC4898 */
-
- /** Send sequence variables RFC793 */
- u32 snd_una; /**< oldest unacknowledged sequence number */
- u32 snd_una_max; /**< newest unacknowledged sequence number + 1*/
- u32 snd_wnd; /**< send window */
- u32 snd_wl1; /**< seq number used for last snd.wnd update */
- u32 snd_wl2; /**< ack number used for last snd.wnd update */
- u32 snd_nxt; /**< next seq number to be sent */
- u16 snd_mss; /**< Effective send max seg (data) size */
-
- /** Receive sequence variables RFC793 */
- u32 rcv_nxt; /**< next sequence number expected */
- u32 rcv_wnd; /**< receive window we expect */
-
- u32 rcv_las; /**< rcv_nxt at last ack sent/rcv_wnd update */
- u32 iss; /**< initial sent sequence */
- u32 irs; /**< initial remote sequence */
-
- /* Options */
- u8 snd_opts_len; /**< Tx options len */
- u8 rcv_wscale; /**< Window scale to advertise to peer */
- u8 snd_wscale; /**< Window scale to use when sending */
- u32 tsval_recent; /**< Last timestamp received */
- u32 tsval_recent_age; /**< When last updated tstamp_recent*/
- tcp_options_t snd_opts; /**< Tx options for connection */
- tcp_options_t rcv_opts; /**< Rx options for connection */
-
- sack_block_t *snd_sacks; /**< Vector of SACKs to send. XXX Fixed size? */
- sack_scoreboard_t sack_sb; /**< SACK "scoreboard" that tracks holes */
-
- u16 rcv_dupacks; /**< Number of DUPACKs received */
- u8 snt_dupacks; /**< Number of DUPACKs sent in a burst */
-
- /* Congestion control */
- u32 cwnd; /**< Congestion window */
- u32 cwnd_acc_bytes; /**< Bytes accumulated for cwnd increment */
- u32 ssthresh; /**< Slow-start threshold */
- u32 prev_ssthresh; /**< ssthresh before congestion */
- u32 prev_cwnd; /**< ssthresh before congestion */
- u32 bytes_acked; /**< Bytes acknowledged by current segment */
- u32 burst_acked; /**< Bytes acknowledged in current burst */
- u32 snd_rxt_bytes; /**< Retransmitted bytes */
- u32 snd_rxt_ts; /**< Timestamp when first packet is retransmitted */
- u32 tsecr_last_ack; /**< Timestamp echoed to us in last healthy ACK */
- u32 snd_congestion; /**< snd_una_max when congestion is detected */
- tcp_cc_algorithm_t *cc_algo; /**< Congestion control algorithm */
-
- /* RTT and RTO */
- u32 rto; /**< Retransmission timeout */
- u32 rto_boff; /**< Index for RTO backoff */
- u32 srtt; /**< Smoothed RTT */
- u32 rttvar; /**< Smoothed mean RTT difference. Approximates variance */
- u32 rtt_seq; /**< Sequence number for tracked ACK */
- f64 rtt_ts; /**< Timestamp for tracked ACK */
- f64 mrtt_us; /**< High precision mrtt from tracked acks */
-
- u16 mss; /**< Our max seg size that includes options */
- u32 limited_transmit; /**< snd_nxt when limited transmit starts */
- u32 last_fib_check; /**< Last time we checked fib route for peer */
- u32 sw_if_index; /**< Interface for the connection */
-} tcp_connection_t;
-
-struct _tcp_cc_algorithm
-{
- void (*rcv_ack) (tcp_connection_t * tc);
- void (*rcv_cong_ack) (tcp_connection_t * tc, tcp_cc_ack_t ack);
- void (*congestion) (tcp_connection_t * tc);
- void (*recovered) (tcp_connection_t * tc);
- void (*init) (tcp_connection_t * tc);
-};
-
-#define tcp_fastrecovery_on(tc) (tc)->flags |= TCP_CONN_FAST_RECOVERY
-#define tcp_fastrecovery_off(tc) (tc)->flags &= ~TCP_CONN_FAST_RECOVERY
-#define tcp_recovery_on(tc) (tc)->flags |= TCP_CONN_RECOVERY
-#define tcp_recovery_off(tc) (tc)->flags &= ~TCP_CONN_RECOVERY
-#define tcp_in_fastrecovery(tc) ((tc)->flags & TCP_CONN_FAST_RECOVERY)
-#define tcp_in_recovery(tc) ((tc)->flags & (TCP_CONN_RECOVERY))
-#define tcp_in_slowstart(tc) (tc->cwnd < tc->ssthresh)
-#define tcp_fastrecovery_sent_1_smss(tc) ((tc)->flags & TCP_CONN_FR_1_SMSS)
-#define tcp_fastrecovery_1_smss_on(tc) ((tc)->flags |= TCP_CONN_FR_1_SMSS)
-#define tcp_fastrecovery_1_smss_off(tc) ((tc)->flags &= ~TCP_CONN_FR_1_SMSS)
-#define tcp_fastrecovery_first(tc) ((tc)->flags & TCP_CONN_FRXT_FIRST)
-#define tcp_fastrecovery_first_on(tc) ((tc)->flags |= TCP_CONN_FRXT_FIRST)
-#define tcp_fastrecovery_first_off(tc) ((tc)->flags &= ~TCP_CONN_FRXT_FIRST)
-
-#define tcp_in_cong_recovery(tc) ((tc)->flags & \
- (TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY))
-
-always_inline void
-tcp_cong_recovery_off (tcp_connection_t * tc)
-{
- tc->flags &= ~(TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY);
- tcp_fastrecovery_1_smss_off (tc);
- tcp_fastrecovery_first_off (tc);
-}