From d6ae4bf13a7819d64d128d196d491af4700fa948 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Sat, 12 Oct 2019 18:10:20 -0700 Subject: tcp: improve rate samples for retansmitted segments Type: fix - Initialize max_seq on both transmitted and retransmitted segments - Keep track of segments that have been sacked. - Track new data segments sent during recovery Change-Id: Ice55231a3da200ae6171702e54b2ce155f831143 Signed-off-by: Florin Coras --- src/vnet/tcp/tcp_output.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/vnet/tcp/tcp_output.c') diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index 0047f3c22e3..45282168bd7 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -406,7 +406,7 @@ tcp_update_burst_snd_vars (tcp_connection_t * tc) tcp_update_rcv_wnd (tc); if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE) - tc->flags |= TCP_CONN_TRACK_BURST; + tcp_bt_check_app_limited (tc); if (tc->snd_una == tc->snd_nxt) { @@ -1124,17 +1124,22 @@ tcp_push_hdr_i (tcp_connection_t * tc, vlib_buffer_t * b, u32 snd_nxt, TCP_EVT (TCP_EVT_PKTIZE, tc); } +always_inline u32 +tcp_buffer_len (vlib_buffer_t * b) +{ + u32 data_len = b->current_length; + if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT)) + data_len += b->total_length_not_including_first_buffer; + return data_len; +} + u32 tcp_session_push_header (transport_connection_t * tconn, vlib_buffer_t * b) { tcp_connection_t *tc = (tcp_connection_t *) tconn; - if (tc->flags & TCP_CONN_TRACK_BURST) - { - tcp_bt_check_app_limited (tc); - tcp_bt_track_tx (tc); - tc->flags &= ~TCP_CONN_TRACK_BURST; - } + if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE) + tcp_bt_track_tx (tc, tcp_buffer_len (b)); tcp_push_hdr_i (tc, b, tc->snd_nxt, /* compute opts */ 0, /* burst */ 1, /* update_snd_nxt */ 1); @@ -1736,7 +1741,7 @@ tcp_timer_persist_handler (u32 index) if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE) { tcp_bt_check_app_limited (tc); - tcp_bt_track_tx (tc); + tcp_bt_track_tx (tc, n_bytes); } tcp_push_hdr_i (tc, b, tc->snd_nxt, /* compute opts */ 0, @@ -1783,6 +1788,9 @@ tcp_transmit_unsent (tcp_worker_ctx_t * wrk, tcp_connection_t * tc, available_wnd = tc->snd_wnd - offset; burst_size = clib_min (burst_size, available_wnd / tc->snd_mss); + if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE) + tcp_bt_check_app_limited (tc); + while (n_segs < burst_size) { n_written = tcp_prepare_segment (wrk, tc, offset, tc->snd_mss, &b); @@ -1794,6 +1802,9 @@ tcp_transmit_unsent (tcp_worker_ctx_t * wrk, tcp_connection_t * tc, offset += n_written; n_segs += 1; + if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE) + tcp_bt_track_tx (tc, n_written); + tc->snd_nxt += n_written; tc->snd_una_max = seq_max (tc->snd_nxt, tc->snd_una_max); } -- cgit 1.2.3-korg