@@ -43,7 +43,8 @@ static int rate_sample_valid(const struct rate_sample *rs)
4343
4444void tcp_testrate_cong_control (struct sock * sk , const struct rate_sample * rs )
4545{
46- u64 bw_bps ; /* delivered bandwidth in bytes per second */
46+ u64 snd_bw_bps ; /* send bandwidth in bytes per second */
47+ u64 rcv_bw_bps ; /* recv bandwidth in bytes per second */
4748 u32 diff_bps ; /* difference in delivered and set bandwidths */
4849 u64 segs_in_flight ; /* compute desired cwnd as rate * rtt */
4950
@@ -52,16 +53,26 @@ void tcp_testrate_cong_control(struct sock *sk, const struct rate_sample *rs)
5253 /* Report rate mismatches beyond a threshold of BW_ERROR_PERC_THRESH
5354 percent. */
5455 if (rate_sample_valid (rs )) {
55- bw_bps = (u64 )rs -> delivered * MTU * S_TO_US ;
56- do_div (bw_bps , rs -> interval_us );
57- diff_bps = ca -> rate - bw_bps ;
58- if (ca -> rate > bw_bps &&
56+ rcv_bw_bps = snd_bw_bps = (u64 )rs -> delivered * MTU * S_TO_US ;
57+ /* Compute send rate either using the send time or receive time. */
58+ if (rs -> snd_int_us > 0 )
59+ do_div (snd_bw_bps , rs -> snd_int_us );
60+ else
61+ do_div (snd_bw_bps , rs -> interval_us );
62+ /* Compute receive rate using receive time, if possible. */
63+ if (rs -> rcv_int_us > 0 )
64+ do_div (rcv_bw_bps , rs -> rcv_int_us );
65+ /* Check rate mismatch through a threshold difference between the set and
66+ achieved send rates. */
67+ diff_bps = ca -> rate - snd_bw_bps ;
68+ if (ca -> rate > snd_bw_bps &&
5969 diff_bps > (BW_ERROR_PERC_THRESH * (ca -> rate / 100 ))) {
60- pr_info ("tcp_testrate found a rate mismatch %d %d %ld %lld\n" ,
70+ pr_info ("tcp_testrate found a rate mismatch %d %d %ld %lld %lld \n" ,
6171 diff_bps ,
6272 rs -> delivered ,
6373 rs -> interval_us ,
64- bw_bps );
74+ snd_bw_bps ,
75+ rcv_bw_bps );
6576 ca -> mismatch_cnt ++ ;
6677 }
6778
0 commit comments