tcp: retry lost retransmits

Add heuristic that detects lost retransmitted segments and retries
sending them.

Type: feature

Change-Id: I34d1bb16799e1993779222eb2bfad4b40704159e
Signed-off-by: Florin Coras <fcoras@cisco.com>
This commit is contained in:
Florin Coras
2019-09-27 08:16:40 -07:00
committed by Dave Barach
parent 5b1379be3e
commit be237bf023
7 changed files with 205 additions and 155 deletions

View File

@ -125,7 +125,7 @@ session_add_self_custom_tx_evt (transport_connection_t * tc, u8 has_prio)
s = session_get (tc->s_index, tc->thread_index);
ASSERT (s->thread_index == vlib_get_thread_index ());
ASSERT (s->session_state < SESSION_STATE_TRANSPORT_DELETED);
ASSERT (s->session_state != SESSION_STATE_TRANSPORT_DELETED);
if (!(s->flags & SESSION_F_CUSTOM_TX))
{
s->flags |= SESSION_F_CUSTOM_TX;

View File

@ -1421,6 +1421,8 @@ session_node_cmp_event (session_event_t * e, svm_fifo_t * f)
case SESSION_IO_EVT_RX:
case SESSION_IO_EVT_TX:
case SESSION_IO_EVT_BUILTIN_RX:
case SESSION_IO_EVT_BUILTIN_TX:
case SESSION_IO_EVT_TX_FLUSH:
if (e->session_index == f->master_session_index)
return 1;
break;
@ -1470,13 +1472,25 @@ session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e)
found = session_node_cmp_event (e, f);
if (found)
return 1;
if (++index == mq->q->maxsize)
index = 0;
index = (index + 1) % mq->q->maxsize;
}
/*
* Search pending events vector
*/
/* *INDENT-OFF* */
clib_llist_foreach (wrk->event_elts, evt_list,
pool_elt_at_index (wrk->event_elts, wrk->new_head),
elt, ({
found = session_node_cmp_event (&elt->evt, f);
if (found)
{
clib_memcpy_fast (e, &elt->evt, sizeof (*e));
goto done;
}
}));
/* *INDENT-ON* */
/* *INDENT-OFF* */
clib_llist_foreach (wrk->event_elts, evt_list,
pool_elt_at_index (wrk->event_elts, wrk->old_head),
@ -1485,12 +1499,12 @@ session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e)
if (found)
{
clib_memcpy_fast (e, &elt->evt, sizeof (*e));
break;
goto done;
}
}));
/* *INDENT-ON* */
done:
return found;
}

View File

@ -566,9 +566,14 @@ u8 *
format_transport_pacer (u8 * s, va_list * args)
{
spacer_t *pacer = va_arg (*args, spacer_t *);
vlib_main_t *vm = vlib_get_main ();
u64 now, diff;
s = format (s, "bucket %u tokens/period %.3f last_update %x",
pacer->bucket, pacer->tokens_per_period, pacer->last_update);
now = vm->clib_time.last_cpu_time;
diff = now - (pacer->last_update << SPACER_CPU_TICKS_PER_PERIOD_SHIFT);
s = format (s, "rate %u bucket %u t/p %.3f last_update %.3f",
pacer->bytes_per_sec, pacer->bucket, pacer->tokens_per_period,
diff * vm->clib_time.seconds_per_clock);
return s;
}

View File

@ -915,17 +915,26 @@ static u8 *
format_tcp_congestion (u8 * s, va_list * args)
{
tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
u32 indent = format_get_indent (s);
u32 indent = format_get_indent (s), prr_space = 0;
s = format (s, "%U ", format_tcp_congestion_status, tc);
s = format (s, "algo %s cwnd %u ssthresh %u bytes_acked %u\n",
tc->cc_algo->name, tc->cwnd, tc->ssthresh, tc->bytes_acked);
s = format (s, "%Ucc space %u prev_cwnd %u prev_ssthresh %u rxt_bytes %u\n",
s = format (s, "%Ucc space %u prev_cwnd %u prev_ssthresh %u\n",
format_white_space, indent, tcp_available_cc_snd_space (tc),
tc->prev_cwnd, tc->prev_ssthresh, tc->snd_rxt_bytes);
s = format (s, "%Usnd_congestion %u dupack %u limited_transmit %u\n",
tc->prev_cwnd, tc->prev_ssthresh);
s = format (s, "%Usnd_cong %u dupack %u limited_tx %u\n",
format_white_space, indent, tc->snd_congestion - tc->iss,
tc->rcv_dupacks, tc->limited_transmit - tc->iss);
s = format (s, "%Urxt_bytes %u rxt_delivered %u rxt_head %u rxt_ts %u\n",
format_white_space, indent, tc->snd_rxt_bytes,
tc->rxt_delivered, tc->rxt_head - tc->iss,
tcp_time_now_w_thread (tc->c_thread_index) - tc->snd_rxt_ts);
if (tcp_in_fastrecovery (tc))
prr_space = tcp_fastrecovery_prr_snd_space (tc);
s = format (s, "%Uprr_start %u prr_delivered %u prr space %u\n",
format_white_space, indent, tc->prr_start - tc->iss,
tc->prr_delivered, prr_space);
return s;
}
@ -1140,10 +1149,11 @@ format_tcp_scoreboard (u8 * s, va_list * args)
sack_scoreboard_hole_t *hole;
u32 indent = format_get_indent (s);
s = format (s, "sacked %u last_sacked %u lost %u last_lost %u\n",
s = format (s, "sacked %u last_sacked %u lost %u last_lost %u"
" rxt_sacked %u\n",
sb->sacked_bytes, sb->last_sacked_bytes, sb->lost_bytes,
sb->last_lost_bytes);
s = format (s, "%Ulast_bytes_delivered %u high_sacked %u is_reneging %u\n",
sb->last_lost_bytes, sb->rxt_sacked);
s = format (s, "%Ulast_delivered %u high_sacked %u is_reneging %u\n",
format_white_space, indent, sb->last_bytes_delivered,
sb->high_sacked - tc->iss, sb->is_reneging);
s = format (s, "%Ucur_rxt_hole %u high_rxt %u rescue_rxt %u",

View File

@ -168,7 +168,7 @@ typedef struct _sack_scoreboard
u32 sacked_bytes; /**< Number of bytes sacked in sb */
u32 last_sacked_bytes; /**< Number of bytes last sacked */
u32 last_bytes_delivered; /**< Sack bytes delivered to app */
u32 rxt_sacked; /**< Rxt last delivered */
u32 rxt_sacked; /**< Rxt bytes last delivered */
u32 high_sacked; /**< Highest byte sacked (fack) */
u32 high_rxt; /**< Highest retransmitted sequence */
u32 rescue_rxt; /**< Rescue sequence number */
@ -226,7 +226,7 @@ sack_scoreboard_hole_t *scoreboard_last_hole (sack_scoreboard_t * sb);
void scoreboard_clear (sack_scoreboard_t * sb);
void scoreboard_clear_reneging (sack_scoreboard_t * sb, u32 start, u32 end);
void scoreboard_init (sack_scoreboard_t * sb);
void scoreboard_init_high_rxt (sack_scoreboard_t * sb, u32 snd_una);
void scoreboard_init_rxt (sack_scoreboard_t * sb, u32 snd_una);
u8 *format_tcp_scoreboard (u8 * s, va_list * args);
#define TCP_BTS_INVALID_INDEX ((u32)~0)
@ -369,7 +369,9 @@ typedef struct _tcp_connection
u32 snd_rxt_bytes; /**< Retransmitted bytes during current cc event */
u32 snd_rxt_ts; /**< Timestamp when first packet is retransmitted */
u32 prr_delivered; /**< RFC6937 bytes delivered during current event */
u32 prr_start; /**< snd_una when prr starts */
u32 rxt_delivered; /**< Rxt bytes delivered during current cc event */
u32 rxt_head; /**< snd_una last time we re rxted the head */
u32 tsecr_last_ack; /**< Timestamp echoed to us in last healthy ACK */
u32 snd_congestion; /**< snd_una_max when congestion is detected */
u32 tx_fifo_size; /**< Tx fifo size. Used to constrain cwnd */
@ -957,8 +959,7 @@ tcp_is_lost_fin (tcp_connection_t * tc)
}
u32 tcp_snd_space (tcp_connection_t * tc);
//void tcp_cc_init_congestion (tcp_connection_t * tc);
//void tcp_cc_fastrecovery_clear (tcp_connection_t * tc);
int tcp_fastrecovery_prr_snd_space (tcp_connection_t * tc);
fib_node_index_t tcp_lookup_rmt_in_fib (tcp_connection_t * tc);

File diff suppressed because it is too large Load Diff

View File

@ -1599,7 +1599,7 @@ tcp_timer_retransmit_handler (u32 tc_index)
}
if (tcp_opts_sack_permitted (&tc->rcv_opts))
scoreboard_init_high_rxt (&tc->sack_sb, tc->snd_una + tc->snd_mss);
scoreboard_init_rxt (&tc->sack_sb, tc->snd_una + n_bytes);
tcp_program_retransmit (tc);
}
@ -1858,7 +1858,7 @@ done:
/**
* Estimate send space using proportional rate reduction (RFC6937)
*/
static int
int
tcp_fastrecovery_prr_snd_space (tcp_connection_t * tc)
{
u32 pipe, prr_out;
@ -1874,13 +1874,24 @@ tcp_fastrecovery_prr_snd_space (tcp_connection_t * tc)
}
else
{
int limit = tc->prr_delivered - prr_out + tc->snd_mss;
int limit;
limit = clib_max ((int) (tc->prr_delivered - prr_out), 0) + tc->snd_mss;
space = clib_min (tc->ssthresh - pipe, limit);
}
space = clib_max (space, prr_out ? 0 : tc->snd_mss);
return space;
}
static inline u8
tcp_retransmit_should_retry_head (tcp_connection_t * tc,
sack_scoreboard_t * sb)
{
u32 tx_adv_sack = sb->high_sacked - tc->snd_congestion;
f64 rr = (f64) tc->ssthresh / tc->prev_cwnd;
return (tx_adv_sack > (tc->snd_una - tc->prr_start) * rr);
}
#define scoreboard_rescue_rxt_valid(_sb, _tc) \
(seq_geq (_sb->rescue_rxt, _tc->snd_una) \
&& seq_leq (_sb->rescue_rxt, _tc->snd_congestion))
@ -1917,8 +1928,31 @@ tcp_retransmit_sack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
return 0;
}
TCP_EVT (TCP_EVT_CC_EVT, tc, 0);
sb = &tc->sack_sb;
/* Check if snd_una is a lost retransmit */
if (seq_gt (sb->high_sacked, tc->snd_congestion)
&& tc->rxt_head != tc->snd_una
&& tcp_retransmit_should_retry_head (tc, sb))
{
n_written = tcp_prepare_retransmit_segment (wrk, tc, 0, tc->snd_mss,
&b);
if (!n_written)
{
tcp_program_retransmit (tc);
goto done;
}
bi = vlib_get_buffer_index (vm, b);
tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
n_segs = 1;
tc->rxt_head = tc->snd_una;
tc->rxt_delivered += n_written;
tc->prr_delivered += n_written;
ASSERT (tc->rxt_delivered <= tc->snd_rxt_bytes);
}
TCP_EVT (TCP_EVT_CC_EVT, tc, 0);
hole = scoreboard_get_hole (sb, sb->cur_rxt_hole);
max_deq = transport_max_tx_dequeue (&tc->connection);
@ -1931,7 +1965,7 @@ tcp_retransmit_sack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
if (!hole)
{
/* We are out of lost holes to retransmit so send some new data. */
if (max_deq)
if (max_deq > tc->snd_mss)
{
u32 n_segs_new, av_window;
av_window = tc->snd_wnd - (tc->snd_nxt - tc->snd_una);