/* * Initialize the congestion window at the beginning of a connection or * after idle time */ static void tcp_cubic_cwnd_init_or_reset(struct tcpcb *tp) { VERIFY(tp->t_ccstate != NULL); tcp_cubic_clear_state(tp); tcp_cc_cwnd_init_or_reset(tp); tp->t_pipeack = 0; tcp_clear_pipeack_state(tp); /* Start counting bytes for RFC 3465 again */ tp->t_bytes_acked = 0; /* * slow start threshold could get initialized to a lower value * when there is a cached value in the route metrics. In this case, * the connection can enter congestion avoidance without any packet * loss and Cubic will enter steady-state too early. It is better * to always probe to find the initial slow-start threshold. */ if (tp->t_inpcb->inp_stat->txbytes <= TCP_CC_CWND_INIT_BYTES && tp->snd_ssthresh < (TCP_MAXWIN << TCP_MAX_WINSHIFT)) tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; /* Initialize cubic last max to be same as ssthresh */ tp->t_ccstate->cub_last_max = tp->snd_ssthresh; }
static int tcp_cubic_init(struct tcpcb *tp) { OSIncrementAtomic((volatile SInt32 *)&tcp_cc_cubic.num_sockets); VERIFY(tp->t_ccstate != NULL); tcp_cubic_clear_state(tp); return (0); }
static void tcp_cubic_after_timeout(struct tcpcb *tp) { VERIFY(tp->t_ccstate != NULL); if (!IN_FASTRECOVERY(tp)) { tcp_cubic_clear_state(tp); tcp_cubic_pre_fr(tp); } /* * Close the congestion window down to one segment as a retransmit * timeout might indicate severe congestion. */ tp->snd_cwnd = tp->t_maxseg; }