module_param(nv_pad, int, 0644);
MODULE_PARM_DESC(nv_pad, "max queued packets allowed in network");
module_param(nv_reset_period, int, 0644);
MODULE_PARM_DESC(nv_reset_period, "nv_min_rtt reset period (secs)");
module_param(nv_min_cwnd, int, 0644);
MODULE_PARM_DESC(nv_min_cwnd, "NV will not decrease cwnd below this value" " without losses");
/* TCP NV Parameters */ struct tcpnv { unsignedlong nv_min_rtt_reset_jiffies; /* when to switch to
* nv_min_rtt_new */
s8 cwnd_growth_factor; /* Current cwnd growth factor,
* < 0 => less than 1 packet/RTT */
u8 available8;
u16 available16;
u8 nv_allow_cwnd_growth:1, /* whether cwnd can grow */
nv_reset:1, /* whether to reset values */
nv_catchup:1; /* whether we are growing because
* of temporary cwnd decrease */
u8 nv_eval_call_cnt; /* call count since last eval */
u8 nv_min_cwnd; /* nv won't make a ca decision if cwnd is *smallerthanthis.Itmaygrowtohandle *TSO,LROandinterruptcoalescencebecause *withtheseasmallcwndcannotsaturate *thelink.Notethatthisisdifferentfrom
* the file local nv_min_cwnd */
u8 nv_rtt_cnt; /* RTTs without making ca decision */;
u32 nv_last_rtt; /* last rtt */
u32 nv_min_rtt; /* active min rtt. Used to determine slope */
u32 nv_min_rtt_new; /* min rtt for future use */
u32 nv_base_rtt; /* If non-zero it represents the threshold for
* congestion */
u32 nv_lower_bound_rtt; /* Used in conjunction with nv_base_rtt. It is *setto80%ofnv_base_rtt.Ithelpsreduce
* unfairness between flows */
u32 nv_rtt_max_rate; /* max rate seen during current RTT */
u32 nv_rtt_start_seq; /* current RTT ends when packet arrives
* acking beyond nv_rtt_start_seq */
u32 nv_last_snd_una; /* Previous value of tp->snd_una. It is *usedtodeterminebytesackedsincelast
* call to bictcp_acked */
u32 nv_no_cong_cnt; /* Consecutive no congestion decisions */
};
/* Some calls are for duplicates without timetamps */ if (sample->rtt_us < 0) return;
/* If not in TCP_CA_Open or TCP_CA_Disorder states, skip. */ if (icsk->icsk_ca_state != TCP_CA_Open &&
icsk->icsk_ca_state != TCP_CA_Disorder) return;
/* Stop cwnd growth if we were in catch up mode */ if (ca->nv_catchup && tcp_snd_cwnd(tp) >= nv_min_cwnd) {
ca->nv_catchup = 0;
ca->nv_allow_cwnd_growth = 0;
}
/* rate in 100's bits per second */
rate64 = ((u64)sample->in_flight) * 80000;
do_div(rate64, avg_rtt ?: 1);
rate = (u32)rate64;
/* Remember the maximum rate seen during this RTT *Note:ItmaybemorethanoneRTT.Thisfunctionshouldbe *calledatleastnv_dec_eval_min_callstimes.
*/ if (ca->nv_rtt_max_rate < rate)
ca->nv_rtt_max_rate = rate;
/* We have valid information, increment counter */ if (ca->nv_eval_call_cnt < 255)
ca->nv_eval_call_cnt++;
/* Apply bounds to rtt. Only used to update min_rtt */
avg_rtt = nv_get_bounded_rtt(ca, avg_rtt);
/* update min rtt if necessary */ if (avg_rtt < ca->nv_min_rtt)
ca->nv_min_rtt = avg_rtt;
/* update future min_rtt if necessary */ if (avg_rtt < ca->nv_min_rtt_new)
ca->nv_min_rtt_new = avg_rtt;
/* nv_min_rtt is updated with the minimum (possibley averaged) rtt *seeninthelastsysctl_tcp_nv_reset_periodseconds(i.e.a *warmreset).Thisnewnv_min_rttwillbecontinuedtobeupdated *andbeusedforanothersysctl_tcp_nv_reset_periodseconds, *whenitwillbeupdatedagain. *Inpracticeweintroducesomerandomness,sotheactualperiodused *ischosenrandomlyfromtherange: *[sysctl_tcp_nv_reset_period*3/4,sysctl_tcp_nv_reset_period*5/4)
*/ if (time_after_eq(now, ca->nv_min_rtt_reset_jiffies)) { unsignedchar rand;
ca->nv_min_rtt = ca->nv_min_rtt_new;
ca->nv_min_rtt_new = NV_INIT_RTT;
get_random_bytes(&rand, 1);
ca->nv_min_rtt_reset_jiffies =
now + ((nv_reset_period * (384 + rand) * HZ) >> 9); /* Every so often we decrease ca->nv_min_cwnd in case previous *valueisnolongeraccurate.
*/
ca->nv_min_cwnd = max(ca->nv_min_cwnd / 2, NV_MIN_CWND);
}
/* Once per RTT check if we need to do congestion avoidance */ if (before(ca->nv_rtt_start_seq, tp->snd_una)) {
ca->nv_rtt_start_seq = tp->snd_nxt; if (ca->nv_rtt_cnt < 0xff) /* Increase counter for RTTs without CA decision */
ca->nv_rtt_cnt++;
/* If this function is only called once within an RTT *thecwndisprobablytoosmall(insomecasesdueto *tso,lroorinterruptcoalescence),soweincrease *ca->nv_min_cwnd.
*/ if (ca->nv_eval_call_cnt == 1 &&
bytes_acked >= (ca->nv_min_cwnd - 1) * tp->mss_cache &&
ca->nv_min_cwnd < (NV_TSO_CWND_BOUND + 1)) {
ca->nv_min_cwnd = min(ca->nv_min_cwnd
+ NV_MIN_CWND_GROW,
NV_TSO_CWND_BOUND + 1);
ca->nv_rtt_start_seq = tp->snd_nxt +
ca->nv_min_cwnd * tp->mss_cache;
ca->nv_eval_call_cnt = 0;
ca->nv_allow_cwnd_growth = 1; return;
}
/* Find the ideal cwnd for current rate from slope *slope=80000.0*mss/nv_min_rtt *cwnd_by_slope=nv_rtt_max_rate/slope
*/
cwnd_by_slope = (u32)
div64_u64(((u64)ca->nv_rtt_max_rate) * ca->nv_min_rtt, 80000ULL * tp->mss_cache);
max_win = cwnd_by_slope + nv_pad;
/* If cwnd > max_win, decrease cwnd *ifcwnd<max_win,growcwnd *elseleavethesame
*/ if (tcp_snd_cwnd(tp) > max_win) { /* there is congestion, check that it is ok *tomakeaCAdecision *1.Weshouldhaveatleastnv_dec_eval_min_calls *datapointsbeforemakingaCAdecision *2.Weonlymakeacongesiondecisionafter *nv_rtt_min_cntRTTs
*/ if (ca->nv_rtt_cnt < nv_rtt_min_cnt) { return;
} elseif (tp->snd_ssthresh == TCP_INFINITE_SSTHRESH) { if (ca->nv_eval_call_cnt <
nv_ssthresh_eval_min_calls) return; /* otherwise we will decrease cwnd */
} elseif (ca->nv_eval_call_cnt <
nv_dec_eval_min_calls) { if (ca->nv_allow_cwnd_growth &&
ca->nv_rtt_cnt > nv_stop_rtt_cnt)
ca->nv_allow_cwnd_growth = 0; return;
}
/* We have enough data to determine we are congested */
ca->nv_allow_cwnd_growth = 0;
tp->snd_ssthresh =
(nv_ssthresh_factor * max_win) >> 3; if (tcp_snd_cwnd(tp) - max_win > 2) { /* gap > 2, we do exponential cwnd decrease */ int dec;
dec = max(2U, ((tcp_snd_cwnd(tp) - max_win) *
nv_cong_dec_mult) >> 7);
tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) - dec);
} elseif (nv_cong_dec_mult > 0) {
tcp_snd_cwnd_set(tp, max_win);
} if (ca->cwnd_growth_factor > 0)
ca->cwnd_growth_factor = 0;
ca->nv_no_cong_cnt = 0;
} elseif (tcp_snd_cwnd(tp) <= max_win - nv_pad_buffer) { /* There is no congestion, grow cwnd if allowed*/ if (ca->nv_eval_call_cnt < nv_inc_eval_min_calls) return;
/* Don't want to make cwnd < nv_min_cwnd *(itwasn'tbefore,ifitisnowisbecausenv *decreasedit).
*/ if (tcp_snd_cwnd(tp) < nv_min_cwnd)
tcp_snd_cwnd_set(tp, nv_min_cwnd);
}
}
/* Extract info for Tcp socket info provided via netlink */ static size_t tcpnv_get_info(struct sock *sk, u32 ext, int *attr, union tcp_cc_info *info)
{ conststruct tcpnv *ca = inet_csk_ca(sk);
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.16Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-29)
¤
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.