MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bbr_get_pacing_delay

Function bbr_get_pacing_delay

freebsd/netinet/tcp_stacks/bbr.c:3555–3607  ·  view source on GitHub ↗

* Given a gain and a length return the delay in useconds that * should be used to evenly space out packets * on the connection (based on the gain factor). */

Source from the content-addressed store, hash-verified

3553 * on the connection (based on the gain factor).
3554 */
3555static uint32_t
3556bbr_get_pacing_delay(struct tcp_bbr *bbr, uint16_t gain, int32_t len, uint32_t cts, int nolog)
3557{
3558 uint64_t bw, lentim, res;
3559 uint32_t usecs, srtt, over = 0;
3560 uint32_t seg_oh, num_segs, maxseg;
3561
3562 if (len == 0)
3563 return (0);
3564
3565 maxseg = bbr->rc_tp->t_maxseg - bbr->rc_last_options;
3566 num_segs = (len + maxseg - 1) / maxseg;
3567 if (bbr->rc_use_google == 0) {
3568 seg_oh = bbr_get_header_oh(bbr);
3569 len += (num_segs * seg_oh);
3570 }
3571 gain = bbr_gain_adjust(bbr, gain);
3572 bw = bbr_get_bw(bbr);
3573 if (bbr->rc_use_google) {
3574 uint64_t cbw;
3575
3576 /*
3577 * Reduce the b/w by the google discount
3578 * factor 10 = 1%.
3579 */
3580 cbw = bw * (uint64_t)(1000 - bbr->r_ctl.bbr_google_discount);
3581 cbw /= (uint64_t)1000;
3582 /* We don't apply a discount if it results in 0 */
3583 if (cbw > 0)
3584 bw = cbw;
3585 }
3586 lentim = ((uint64_t)len *
3587 (uint64_t)USECS_IN_SECOND *
3588 (uint64_t)BBR_UNIT);
3589 res = lentim / ((uint64_t)gain * bw);
3590 if (res == 0)
3591 res = 1;
3592 usecs = (uint32_t)res;
3593 srtt = bbr_get_rtt(bbr, BBR_SRTT);
3594 if (bbr_hptsi_max_mul && bbr_hptsi_max_div &&
3595 (bbr->rc_use_google == 0) &&
3596 (usecs > ((srtt * bbr_hptsi_max_mul) / bbr_hptsi_max_div))) {
3597 /*
3598 * We cannot let the delay be more than 1/2 the srtt time.
3599 * Otherwise we cannot pace out or send properly.
3600 */
3601 over = usecs = (srtt * bbr_hptsi_max_mul) / bbr_hptsi_max_div;
3602 BBR_STAT_INC(bbr_hpts_min_time);
3603 }
3604 if (!nolog)
3605 bbr_log_pacing_delay_calc(bbr, gain, len, cts, usecs, bw, over, 1);
3606 return (usecs);
3607}
3608
3609static void
3610bbr_ack_received(struct tcpcb *tp, struct tcp_bbr *bbr, struct tcphdr *th, uint32_t bytes_this_ack,

Callers 3

bbr_adjust_for_hw_pacingFunction · 0.85
bbr_log_outputFunction · 0.85
bbr.cFile · 0.85

Calls 5

bbr_get_header_ohFunction · 0.85
bbr_gain_adjustFunction · 0.85
bbr_get_bwFunction · 0.85
bbr_get_rttFunction · 0.85

Tested by

no test coverage detected