summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-09-10 23:26:27 -0700
committerDave Barach <openvpp@barachs.net>2019-09-18 14:40:43 +0000
commit7436b436733ea7217e745f3cc9971aaff1e3dfa4 (patch)
tree9a37720468bc5d0b4294de98c9bb781145550577
parent43765e2b4eaa8e1f2a5f1562414e04962c777ff3 (diff)
tcp: compute snd time for rate sample
Type: feature Change-Id: I6bd675dc28dbc34293e895911efe986844c0564f Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/plugins/unittest/tcp_test.c40
-rw-r--r--src/vnet/tcp/tcp.h4
-rw-r--r--src/vnet/tcp/tcp_bt.c13
3 files changed, 28 insertions, 29 deletions
diff --git a/src/plugins/unittest/tcp_test.c b/src/plugins/unittest/tcp_test.c
index 42fa423bfae..f6a389c5c88 100644
--- a/src/plugins/unittest/tcp_test.c
+++ b/src/plugins/unittest/tcp_test.c
@@ -820,14 +820,6 @@ tbt_seq_lt (u32 a, u32 b)
return seq_lt (a, b);
}
-static inline int
-approx_equal (u32 a, u32 b)
-{
- if (b > 0.99 * a && b < 1.01 * a)
- return 1;
- return 0;
-}
-
static int
tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
{
@@ -894,9 +886,8 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (rs->interval_time == 1, "ack time should be 1");
TCP_TEST (rs->delivered == burst, "delivered should be 100");
TCP_TEST (rs->prior_delivered == 0, "sample delivered should be 0");
- TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
- rs->tx_rate);
TCP_TEST (!(rs->flags & TCP_BTS_IS_RXT), "not retransmitted");
+ TCP_TEST (tc->first_tx_time == 1, "first_tx_time %u", tc->first_tx_time);
/* 3) track second burst at time 2 */
tcp_bt_track_tx (tc);
@@ -934,10 +925,9 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (rs->interval_time == 2, "ack time should be 2");
TCP_TEST (rs->delivered == 2 * burst, "delivered should be 200");
TCP_TEST (rs->prior_delivered == burst, "delivered should be 100");
- TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
- rs->tx_rate);
TCP_TEST (!(rs->flags & TCP_BTS_IS_RXT), "not retransmitted");
TCP_TEST (!(bts->flags & TCP_BTS_IS_APP_LIMITED), "not app limited");
+ TCP_TEST (tc->first_tx_time == 2, "first_tx_time %u", tc->first_tx_time);
/*
* Track retransmissions
@@ -947,7 +937,7 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
snd_una = tc->snd_una;
- /* 1) track first burst a time 4 */
+ /* 1) track first burst at time 4 */
tcp_bt_track_tx (tc);
tc->snd_nxt += burst;
@@ -1003,10 +993,11 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (rs->delivered == 30, "delivered should be 30");
TCP_TEST (rs->prior_delivered == 3 * burst,
"sample delivered should be %u", 3 * burst);
- TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
- rs->tx_rate);
TCP_TEST (!(rs->flags & TCP_BTS_IS_RXT), "not retransmitted");
TCP_TEST (!(rs->flags & TCP_BTS_IS_APP_LIMITED), "not app limited");
+ /* All 3 samples have the same delivered number of bytes. The first
+ * sets the first tx time */
+ TCP_TEST (tc->first_tx_time == 4, "first_tx_time %u", tc->first_tx_time);
/* 6) Retransmit and track at time 9
*
@@ -1079,20 +1070,22 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (tc->delivered_time == 10, "delivered time should be 10");
TCP_TEST (tc->delivered == 5 * burst + 40, "delivered should be %u is %u",
5 * burst + 40, tc->delivered);
- /* A rxt was acked and delivered time for it is 8 (last ack time) */
- TCP_TEST (rs->interval_time == 2, "ack time should be 2 is %.2f",
+ /* A rxt was acked and delivered time for it is 8 (last ack time) so
+ * ack_time is 2 (8 - 10). However, first_tx_time for rxt was 4 and rxt
+ * time 9. Therefore snd_time is 5 (9 - 4)*/
+ TCP_TEST (rs->interval_time == 5, "ack time should be 5 is %.2f",
rs->interval_time);
/* delivered_now - delivered_rxt ~ 5 * burst + 40 - 3 * burst - 30 */
TCP_TEST (rs->delivered == 2 * burst + 10, "delivered should be 210 is %u",
rs->delivered);
TCP_TEST (rs->prior_delivered == 3 * burst + 30,
"sample delivered should be %u", 3 * burst + 30);
- TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
- rs->tx_rate);
TCP_TEST (rs->flags & TCP_BTS_IS_RXT, "is retransmitted");
/* Sample is app limited because of the retransmits */
TCP_TEST (rs->flags & TCP_BTS_IS_APP_LIMITED, "is app limited");
TCP_TEST (tc->app_limited, "app limited should be set");
+ TCP_TEST (tc->first_tx_time == 9, "first_tx_time %u", tc->first_tx_time);
+
/*
* 8) check delivery rate at time 11
@@ -1112,8 +1105,10 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (tc->delivered_time == 11, "delivered time should be 11");
TCP_TEST (tc->delivered == 7 * burst, "delivered should be %u is %u",
7 * burst, tc->delivered);
- /* Last rxt was at time 8 */
- TCP_TEST (rs->interval_time == 3, "ack time should be 3 is %.2f",
+ /* Delivered time at retransmit was 8 so ack_time is 11 - 8 = 3. However,
+ * first_tx_time for rxt was 4 and rxt time was 9. Therefore snd_time
+ * is 9 - 4 = 5 */
+ TCP_TEST (rs->interval_time == 5, "ack time should be 5 is %.2f",
rs->interval_time);
/* delivered_now - delivered_rxt ~ 7 * burst - 3 * burst - 30.
* That's because we didn't retransmit any new segment. */
@@ -1121,11 +1116,10 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
rs->delivered);
TCP_TEST (rs->prior_delivered == 3 * burst + 30,
"sample delivered should be %u", 3 * burst + 30);
- TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
- rs->tx_rate);
TCP_TEST (rs->flags & TCP_BTS_IS_RXT, "is retransmitted");
TCP_TEST (rs->flags & TCP_BTS_IS_APP_LIMITED, "is app limited");
TCP_TEST (tc->app_limited == 0, "app limited should be cleared");
+ TCP_TEST (tc->first_tx_time == 9, "first_tx_time %u", tc->first_tx_time);
/*
* 9) test flush
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index 4c4a9a525af..227b3f8a856 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -240,7 +240,7 @@ typedef struct tcp_bt_sample_
u64 delivered; /**< Total delivered bytes for sample */
f64 delivered_time; /**< Delivered time when sample taken */
f64 tx_time; /**< Transmit time for the burst */
- u64 tx_rate; /**< Tx pacing rate */
+ f64 first_tx_time; /**< Connection first tx time at tx */
tcp_bts_flags_t flags; /**< Sample flag */
} tcp_bt_sample_t;
@@ -251,7 +251,6 @@ typedef struct tcp_rate_sample_
f64 prior_time; /**< Delivered time of sample used for rate */
f64 interval_time; /**< Time to ack the bytes delivered */
f64 rtt_time; /**< RTT for sample */
- u64 tx_rate; /**< Tx pacing rate */
u32 delivered; /**< Bytes delivered in interval_time */
u32 acked_and_sacked; /**< Bytes acked + sacked now */
u32 lost; /**< Bytes lost now */
@@ -394,6 +393,7 @@ typedef struct _tcp_connection
u64 delivered; /**< Total bytes delivered to peer */
u64 app_limited; /**< Delivered when app-limited detected */
f64 delivered_time; /**< Time last bytes were acked */
+ f64 first_tx_time; /**< Send time for recently delivered/sent */
tcp_byte_tracker_t *bt; /**< Tx byte tracker */
tcp_errors_t errors; /**< Soft connection errors */
diff --git a/src/vnet/tcp/tcp_bt.c b/src/vnet/tcp/tcp_bt.c
index fe007543cd0..b550fdd65dd 100644
--- a/src/vnet/tcp/tcp_bt.c
+++ b/src/vnet/tcp/tcp_bt.c
@@ -241,8 +241,8 @@ tcp_bt_alloc_tx_sample (tcp_connection_t * tc, u32 min_seq)
bts = bt_alloc_sample (tc->bt, min_seq);
bts->delivered = tc->delivered;
bts->delivered_time = tc->delivered_time;
- bts->tx_rate = transport_connection_tx_pacer_rate (&tc->connection);
bts->tx_time = tcp_time_now_us (tc->c_thread_index);
+ bts->first_tx_time = tc->first_tx_time;
bts->flags |= tc->app_limited ? TCP_BTS_IS_APP_LIMITED : 0;
return bts;
}
@@ -270,7 +270,10 @@ tcp_bt_track_tx (tcp_connection_t * tc)
u32 bts_index;
if (tc->snd_una == tc->snd_nxt)
- tc->delivered_time = tcp_time_now_us (tc->c_thread_index);
+ {
+ tc->delivered_time = tcp_time_now_us (tc->c_thread_index);
+ tc->first_tx_time = tc->delivered_time;
+ }
bts = tcp_bt_alloc_tx_sample (tc, tc->snd_nxt);
bts_index = bt_sample_index (bt, bts);
@@ -421,9 +424,10 @@ tcp_bt_sample_to_rate_sample (tcp_connection_t * tc, tcp_bt_sample_t * bts,
rs->prior_delivered = bts->delivered;
rs->prior_time = bts->delivered_time;
+ rs->interval_time = bts->tx_time - bts->first_tx_time;
rs->rtt_time = bts->tx_time;
- rs->tx_rate = bts->tx_rate;
rs->flags = bts->flags;
+ tc->first_tx_time = bts->tx_time;
}
static void
@@ -529,7 +533,8 @@ tcp_bt_sample_delivery_rate (tcp_connection_t * tc, tcp_rate_sample_t * rs)
if (tc->sack_sb.last_sacked_bytes)
tcp_bt_walk_samples_ooo (tc, rs);
- rs->interval_time = tc->delivered_time - rs->prior_time;
+ rs->interval_time = clib_max (tc->delivered_time - rs->prior_time,
+ rs->interval_time);
rs->delivered = tc->delivered - rs->prior_delivered;
rs->rtt_time = tc->delivered_time - rs->rtt_time;
rs->acked_and_sacked = delivered;