FreeBSD/sys/netinet/cc/cc_dctcp.c
/*
 * Perform any necessary tasks before we enter congestion recovery.
 */
Perform any necessary tasks before we enter congestion recovery.
Perform any necessary tasks before we enter congestion recovery .
static void
dctcp_cong_signal(struct cc_var *ccv, uint32_t type)
{
	struct dctcp *dctcp_data;
	u_int win, mss;
	dctcp_data = ccv->cc_data;
	win = CCV(ccv, snd_cwnd);
	mss = CCV(ccv, t_maxseg);
	switch (type) {
	case CC_NDUPACK:
		if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
			if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
				CCV(ccv, snd_ssthresh) = mss *
				    max(win / 2 / mss, 2);
				dctcp_data->num_cong_events++;
			} else {
				win = CCV(ccv, snd_cwnd_prev);
				CCV(ccv, snd_ssthresh) =
				    max(win / 2 / mss, 2) * mss;
			}
			ENTER_RECOVERY(CCV(ccv, t_flags));
		}
		break;
	case CC_ECN:
		CCV(ccv, snd_cwnd_prev) = win;
		if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
			if (V_dctcp_slowstart &&
			    dctcp_data->num_cong_events++ == 0) {
				CCV(ccv, snd_ssthresh) =
				    mss * max(win / 2 / mss, 2);
				dctcp_data->alpha = MAX_ALPHA_VALUE;
				dctcp_data->bytes_ecn = 0;
				dctcp_data->bytes_total = 0;
				dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
			} else
				CCV(ccv, snd_ssthresh) = max((win - ((win *
				    dctcp_data->alpha) >> 11)) / mss, 2) * mss;
			CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh);
			ENTER_CONGRECOVERY(CCV(ccv, t_flags));
		}
		dctcp_data->ece_curr = 1;
		break;
	case CC_RTO:
		if (CCV(ccv, t_flags) & TF_ECN_PERMIT) {
			CCV(ccv, t_flags) |= TF_ECN_SND_CWR;
			dctcp_update_alpha(ccv);
			dctcp_data->save_sndnxt += CCV(ccv, t_maxseg);
			dctcp_data->num_cong_events++;
		}
		break;
	}
}
static void dctcp_cong_signal ( struct cc_var * ccv , uint32_t type ) { struct dctcp * dctcp_data ; u_int win , mss ; dctcp_data = ccv -> cc_data ; win = CCV ( ccv , snd_cwnd ) ; mss = CCV ( ccv , t_maxseg ) ; switch ( type ) { case CC_NDUPACK : if ( ! IN_FASTRECOVERY ( CCV ( ccv , t_flags ) ) ) { if ( ! IN_CONGRECOVERY ( CCV ( ccv , t_flags ) ) ) { CCV ( ccv , snd_ssthresh ) = mss * max ( win / 2 / mss , 2 ) ; dctcp_data -> num_cong_events ++ ; } else { win = CCV ( ccv , snd_cwnd_prev ) ; CCV ( ccv , snd_ssthresh ) = max ( win / 2 / mss , 2 ) * mss ; } ENTER_RECOVERY ( CCV ( ccv , t_flags ) ) ; } break ; case CC_ECN : CCV ( ccv , snd_cwnd_prev ) = win ; if ( ! IN_CONGRECOVERY ( CCV ( ccv , t_flags ) ) ) { if ( V_dctcp_slowstart && dctcp_data -> num_cong_events ++ == 0 ) { CCV ( ccv , snd_ssthresh ) = mss * max ( win / 2 / mss , 2 ) ; dctcp_data -> alpha = MAX_ALPHA_VALUE ; dctcp_data -> bytes_ecn = 0 ; dctcp_data -> bytes_total = 0 ; dctcp_data -> save_sndnxt = CCV ( ccv , snd_nxt ) ; } else CCV ( ccv , snd_ssthresh ) = max ( ( win - ( ( win * dctcp_data -> alpha ) >> 11 ) ) / mss , 2 ) * mss ; CCV ( ccv , snd_cwnd ) = CCV ( ccv , snd_ssthresh ) ; ENTER_CONGRECOVERY ( CCV ( ccv , t_flags ) ) ; } dctcp_data -> ece_curr = 1 ; break ; case CC_RTO : if ( CCV ( ccv , t_flags ) & TF_ECN_PERMIT ) { CCV ( ccv , t_flags ) |= TF_ECN_SND_CWR ; dctcp_update_alpha ( ccv ) ; dctcp_data -> save_sndnxt += CCV ( ccv , t_maxseg ) ; dctcp_data -> num_cong_events ++ ; } break ; } }
Perform any necessary tasks before we enter congestion recovery.
Perform any necessary tasks before we enter congestion recovery .
/* cwnd has already updated as congestion
				 * recovery. Reverse cwnd value using
				 * snd_cwnd_prev and recalculate snd_ssthresh
				 */ /*
		 * Save current snd_cwnd when the host encounters both
		 * congestion recovery and fast recovery.
		 */