/* Measure RTT for each ack. */ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last) { struct illinois *ca = inet_csk_ca(sk); u32 rtt; ca->acked = pkts_acked; if (ktime_equal(last, net_invalid_timestamp())) return; rtt = ktime_to_us(net_timedelta(last)); /* ignore bogus values, this prevents wraparound in alpha math */ if (rtt > RTT_MAX) rtt = RTT_MAX; /* keep track of minimum RTT seen so far */ if (ca->base_rtt > rtt) ca->base_rtt = rtt; /* and max */ if (ca->max_rtt < rtt) ca->max_rtt = rtt; ++ca->cnt_rtt; ca->sum_rtt += rtt; }
/* Do rtt sampling needed for Veno. */ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) { struct veno *veno = inet_csk_ca(sk); u32 vrtt; if (ktime_equal(last, net_invalid_timestamp())) return; /* Never allow zero rtt or baseRTT */ vrtt = ktime_to_us(net_timedelta(last)) + 1; /* Filter to find propagation delay: */ if (vrtt < veno->basertt) veno->basertt = vrtt; /* Find the min rtt during the last rtt to find * the current prop. delay + queuing delay: */ veno->minrtt = min(veno->minrtt, vrtt); veno->cntrtt++; }
/* Do RTT sampling needed for Vegas. * Basically we: * o min-filter RTT samples from within an RTT to get the current * propagation delay + queuing delay (we are min-filtering to try to * avoid the effects of delayed ACKs) * o min-filter RTT samples from a much longer window (forever for now) * to find the propagation delay (baseRTT) */ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) { cnt = cnt; struct vegas *vegas = inet_csk_ca(sk); u32 vrtt; if (ktime_equal(last, net_invalid_timestamp())) return; /* Never allow zero rtt or baseRTT */ vrtt = ktime_to_us(net_timedelta(last)) + 1; /* Filter to find propagation delay: */ if (vrtt < vegas->baseRTT) vegas->baseRTT = vrtt; /* Find the min RTT during the last RTT to find * the current prop. delay + queuing delay: */ vegas->minRTT = min(vegas->minRTT, vrtt); vegas->cntRTT++; }
/* Do RTT sampling needed for Vegas. * Basically we: * o min-filter RTT samples from within an RTT to get the current * propagation delay + queuing delay (we are min-filtering to try to * avoid the effects of delayed ACKs) * o min-filter RTT samples from a much longer window (forever for now) * to find the propagation delay (baseRTT) */ void tcp_sod_delay_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) { struct tcp_sock *tp = tcp_sk(sk); struct sod_delay *sod = inet_csk_ca(sk); u64 vrtt; u64 qd_plus_td, remain_qd; u16 est_ql = 0; if (ktime_equal(last, net_invalid_timestamp())) return; /* Never allow zero rtt or baseRTT */ vrtt = ktime_to_us(net_timedelta(last)) + 1; /* Filter to find propagation delay: */ if (vrtt < sod->baseRTT) sod->baseRTT = vrtt; qd_plus_td = vrtt - sod->baseRTT; if (tp->td_last_index == 0) est_ql = 0; else { if (qd_plus_td < tp->ary_td[tp->td_last_index -1].td_i) est_ql = 1; else { u32 td_index = tp->td_last_index -1; remain_qd = qd_plus_td - tp->ary_td[td_index].td_i; while (remain_qd > 0 && td_index != tp->td_head_index) { if (tp->td_head_index >= tp->td_last_index && td_index == 0 ) { if (tp->td_count > 1) td_index = tp->td_count -1; else break; } else td_index--; if (remain_qd > tp->ary_td[td_index].td_i) { remain_qd -= tp->ary_td[td_index].td_i; est_ql++; } else { est_ql++; break; } } est_ql++; } } sod->curQL = est_ql; sod->minQL = min(sod->minQL, est_ql); //printf("current estimation: %lu\n", sod->curQL); /* Find the min RTT during the last RTT to find * the current prop. delay + queuing delay: */ sod->minRTT = min(sod->minRTT, vrtt); sod->cntRTT++; }