+static void tcp_rexmt_save_state(struct tcpcb *tp)
+{
+ u_int32_t fsize;
+ if (TSTMP_SUPPORTED(tp)) {
+ /*
+ * Since timestamps are supported on the connection,
+ * we can do recovery as described in rfc 4015.
+ */
+ fsize = tp->snd_max - tp->snd_una;
+ tp->snd_ssthresh_prev = max(fsize, tp->snd_ssthresh);
+ tp->snd_recover_prev = tp->snd_recover;
+ } else {
+ /*
+ * Timestamp option is not supported on this connection.
+ * Record ssthresh and cwnd so they can
+ * be recovered if this turns out to be a "bad" retransmit.
+ * A retransmit is considered "bad" if an ACK for this
+ * segment is received within RTT/2 interval; the assumption
+ * here is that the ACK was already in flight. See
+ * "On Estimating End-to-End Network Path Properties" by
+ * Allman and Paxson for more details.
+ */
+ tp->snd_cwnd_prev = tp->snd_cwnd;
+ tp->snd_ssthresh_prev = tp->snd_ssthresh;
+ tp->snd_recover_prev = tp->snd_recover;
+ if (IN_FASTRECOVERY(tp))
+ tp->t_flags |= TF_WASFRECOVERY;
+ else
+ tp->t_flags &= ~TF_WASFRECOVERY;
+ }
+ tp->t_srtt_prev = (tp->t_srtt >> TCP_RTT_SHIFT) + 2;
+ tp->t_rttvar_prev = (tp->t_rttvar >> TCP_RTTVAR_SHIFT);
+ tp->t_flagsext &= ~(TF_RECOMPUTE_RTT);
+}
+