QUIC ACKM: Add function to get PTO

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19703)
This commit is contained in:
Hugo Landau 2022-11-01 16:39:09 +00:00
parent 27003aa6eb
commit 4ed9e0a1e3
2 changed files with 22 additions and 0 deletions

View File

@ -225,4 +225,10 @@ int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn);
int ossl_ackm_mark_packet_pseudo_lost(OSSL_ACKM *ackm,
int pkt_space, QUIC_PN pn);
/*
* Returns the PTO duration as currently calculated. This is a quantity of time.
* This duration is used in various parts of QUIC besides the ACKM.
*/
OSSL_TIME ossl_ackm_get_pto_duration(OSSL_ACKM *ackm);
#endif

View File

@ -1663,3 +1663,19 @@ int ossl_ackm_mark_packet_pseudo_lost(OSSL_ACKM *ackm,
ackm_on_pkts_lost(ackm, pkt_space, pkt, /*pseudo=*/1);
return 1;
}
OSSL_TIME ossl_ackm_get_pto_duration(OSSL_ACKM *ackm)
{
OSSL_TIME duration;
OSSL_RTT_INFO rtt;
ossl_statm_get_rtt_info(ackm->statm, &rtt);
duration = ossl_time_add(rtt.smoothed_rtt,
ossl_time_max(ossl_time_multiply(rtt.rtt_variance, 4),
ossl_ticks2time(K_GRANULARITY)));
if (!ossl_time_is_infinite(rtt.max_ack_delay))
duration = ossl_time_add(duration, rtt.max_ack_delay);
return duration;
}