Expose smoothed RTT and RTT variance measurements to userland via

socket option TCP_INFO.
Note that the units used in the original Linux API are in microseconds,
so use a 64-bit mantissa to convert FreeBSD's internal measurements
from struct tcpcb from ticks.
This commit is contained in:
Bruce M Simpson 2007-02-02 18:34:18 +00:00
parent e8117c82f6
commit 1baaf8347c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=166433
2 changed files with 6 additions and 2 deletions

View File

@ -208,8 +208,8 @@ struct tcp_info {
/* Metrics; variable units. */
u_int32_t __tcpi_pmtu;
u_int32_t __tcpi_rcv_ssthresh;
u_int32_t __tcpi_rtt;
u_int32_t __tcpi_rttvar;
u_int32_t tcpi_rtt; /* Smoothed RTT in usecs. */
u_int32_t tcpi_rttvar; /* RTT variance in usecs. */
u_int32_t tcpi_snd_ssthresh; /* Slow start threshold. */
u_int32_t tcpi_snd_cwnd; /* Send congestion window. */
u_int32_t __tcpi_advmss;

View File

@ -1245,6 +1245,10 @@ tcp_fill_info(tp, ti)
ti->tcpi_snd_wscale = tp->snd_scale;
ti->tcpi_rcv_wscale = tp->rcv_scale;
}
ti->tcpi_rtt = ((u_int64_t)tp->t_srtt * tick) >> TCP_RTT_SHIFT;
ti->tcpi_rttvar = ((u_int64_t)tp->t_rttvar * tick) >> TCP_RTTVAR_SHIFT;
ti->tcpi_snd_ssthresh = tp->snd_ssthresh;
ti->tcpi_snd_cwnd = tp->snd_cwnd;