/* Highlights: * 1. The major difference between this bpf program and tcp_cubic.c * is that this bpf program relies on `cong_control` rather than * `cong_avoid` in the struct tcp_congestion_ops. * 2. Logic such as tcp_cwnd_reduction, tcp_cong_avoid, and * tcp_update_pacing_rate is bypassed when `cong_control` is * defined, so moving these logic to `cong_control`. * 3. WARNING: This bpf program is NOT the same as tcp_cubic.c. * The main purpose is to show use cases of the arguments in * `cong_control`. For simplicity's sake, it reuses tcp cubic's * kernel functions.
*/
/* set sk_pacing_rate to 200 % of current rate (mss * cwnd / srtt) */
rate = (__u64)tp->mss_cache * ((USEC_PER_SEC / 100) << 3);
/* current rate is (cwnd * mss) / srtt * In Slow Start [1], set sk_pacing_rate to 200 % the current rate. * In Congestion Avoidance phase, set it to 120 % the current rate. * * [1] : Normal Slow Start condition is (tp->snd_cwnd < tp->snd_ssthresh) * If snd_cwnd >= (tp->snd_ssthresh / 2), we are approaching * end of slow start and should slow down.
*/ if (tp->snd_cwnd < tp->snd_ssthresh / 2)
rate *= TCP_PACING_SS_RATIO; else
rate *= TCP_PACING_CA_RATIO;
rate *= max(tp->snd_cwnd, tp->packets_out);
if (tp->srtt_us)
rate = div64_u64(rate, (__u64)tp->srtt_us);
if (delta < 0) {
__u64 dividend =
(__u64)tp->snd_ssthresh * prr_delivered + tp->prior_cwnd - 1;
sndcnt = (__u32)div64_u64(dividend, (__u64)tp->prior_cwnd) - tp->prr_out;
} else {
sndcnt = max(prr_delivered - tp->prr_out, newly_acked_sacked); if (flag & FLAG_SND_UNA_ADVANCED && !newly_lost)
sndcnt++;
sndcnt = min(delta, sndcnt);
} /* Force a fast retransmit upon entering fast recovery */
sndcnt = max(sndcnt, (tp->prr_out ? 0 : 1));
tp->snd_cwnd = pkts_in_flight + sndcnt;
}
/* Decide whether to run the increase function of congestion control. */ staticbool tcp_may_raise_cwnd(conststruct sock *sk, constint flag)
{ if (tcp_sk(sk)->reordering > TCP_REORDERING) return flag & FLAG_FORWARD_PROGRESS;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.