+ tcp_retransmit_timer_update (&wrk->timer_wheel, tc);
+
+ return;
+
+update_scheduler:
+
+ if (tcp_is_descheduled (tc))
+ transport_connection_reschedule (&tc->connection);
+}
+
+/**
+ * Retransmit first unacked segment
+ */
+int
+tcp_retransmit_first_unacked (tcp_worker_ctx_t * wrk, tcp_connection_t * tc)
+{
+ vlib_main_t *vm = wrk->vm;
+ vlib_buffer_t *b;
+ u32 bi, n_bytes;
+
+ TCP_EVT (TCP_EVT_CC_EVT, tc, 1);
+
+ n_bytes = tcp_prepare_retransmit_segment (wrk, tc, 0, tc->snd_mss, &b);
+ if (!n_bytes)
+ return -1;
+
+ bi = vlib_get_buffer_index (vm, b);
+ tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
+
+ return 0;
+}
+
+static int
+tcp_transmit_unsent (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
+ u32 burst_size)
+{
+ u32 offset, n_segs = 0, n_written, bi, available_wnd;
+ vlib_main_t *vm = wrk->vm;
+ vlib_buffer_t *b = 0;
+
+ offset = tc->snd_nxt - tc->snd_una;
+ 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);
+ if (!n_written)
+ goto done;
+
+ bi = vlib_get_buffer_index (vm, b);
+ tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
+ 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;
+ }
+
+done:
+ return n_segs;
+}
+
+/**
+ * Estimate send space using proportional rate reduction (RFC6937)
+ */
+int
+tcp_fastrecovery_prr_snd_space (tcp_connection_t * tc)
+{
+ u32 pipe, prr_out;
+ int space;
+
+ pipe = tcp_flight_size (tc);
+ prr_out = tc->snd_rxt_bytes + (tc->snd_nxt - tc->snd_congestion);
+
+ if (pipe > tc->ssthresh)
+ {
+ space = ((int) tc->prr_delivered * ((f64) tc->ssthresh / tc->prev_cwnd))
+ - prr_out;
+ }
+ else
+ {
+ 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;