Permalink
Browse files

Expose both send and receive rate in rate_sample

  • Loading branch information...
ngsrinivas committed Apr 26, 2017
1 parent 1fa9835 commit a84f0a6db796a84411547a7055d619d2792d871c
Showing with 23 additions and 7 deletions.
  1. +2 −0 include/net/tcp.h
  2. +3 −0 net/ipv4/tcp_rate.c
  3. +18 −7 net/ipv4/tcp_testrate.c
@@ -893,6 +893,8 @@ struct rate_sample {
u32 prior_delivered; /* tp->delivered at "prior_mstamp" */
s32 delivered; /* number of packets delivered over interval */
long interval_us; /* time for tp->delivered to incr "delivered" */
long snd_int_us; /* snd interval for delivered packets */
long rcv_int_us; /* rcv interval for delivered packets */
long rtt_us; /* RTT of last (S)ACKed packet (or -1) */
int losses; /* number of packets marked lost upon ACK */
u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */
@@ -140,6 +140,9 @@ void tcp_rate_gen(struct sock *sk, u32 delivered, u32 lost,
snd_us = rs->interval_us; /* send phase */
ack_us = skb_mstamp_us_delta(now, &rs->prior_mstamp); /* ack phase */
rs->interval_us = max(snd_us, ack_us);
/* Record both segment send and ack receive intervals. */
rs->snd_int_us = snd_us;
rs->rcv_int_us = ack_us;
/* Normally we expect interval_us >= min-rtt.
* Note that rate may still be over-estimated when a spuriously
@@ -43,7 +43,8 @@ static int rate_sample_valid(const struct rate_sample *rs)
void tcp_testrate_cong_control(struct sock *sk, const struct rate_sample *rs)
{
u64 bw_bps; /* delivered bandwidth in bytes per second */
u64 snd_bw_bps; /* send bandwidth in bytes per second */
u64 rcv_bw_bps; /* recv bandwidth in bytes per second */
u32 diff_bps; /* difference in delivered and set bandwidths */
u64 segs_in_flight; /* compute desired cwnd as rate * rtt */
@@ -52,16 +53,26 @@ void tcp_testrate_cong_control(struct sock *sk, const struct rate_sample *rs)
/* Report rate mismatches beyond a threshold of BW_ERROR_PERC_THRESH
percent. */
if (rate_sample_valid(rs)) {
bw_bps = (u64)rs->delivered * MTU * S_TO_US;
do_div(bw_bps, rs->interval_us);
diff_bps = ca->rate - bw_bps;
if (ca->rate > bw_bps &&
rcv_bw_bps = snd_bw_bps = (u64)rs->delivered * MTU * S_TO_US;
/* Compute send rate either using the send time or receive time. */
if (rs->snd_int_us > 0)
do_div(snd_bw_bps, rs->snd_int_us);
else
do_div(snd_bw_bps, rs->interval_us);
/* Compute receive rate using receive time, if possible. */
if (rs->rcv_int_us > 0)
do_div(rcv_bw_bps, rs->rcv_int_us);
/* Check rate mismatch through a threshold difference between the set and
achieved send rates. */
diff_bps = ca->rate - snd_bw_bps;
if (ca->rate > snd_bw_bps &&
diff_bps > (BW_ERROR_PERC_THRESH * (ca->rate / 100))) {
pr_info("tcp_testrate found a rate mismatch %d %d %ld %lld\n",
pr_info("tcp_testrate found a rate mismatch %d %d %ld %lld %lld\n",
diff_bps,
rs->delivered,
rs->interval_us,
bw_bps);
snd_bw_bps,
rcv_bw_bps);
ca->mismatch_cnt++;
}

0 comments on commit a84f0a6

Please sign in to comment.