@@ -9,16 +9,20 @@ pub struct TcpStats {
99 /// Our receive window in bytes.
1010 pub rwnd : u32 ,
1111 /// Our send window (= the peer's advertised receive window) in bytes.
12+ #[ cfg( target_os = "macos" ) ]
1213 pub snd_wnd : u32 ,
1314 /// The most recent RTT sample.
15+ #[ cfg( target_os = "macos" ) ]
1416 pub last_rtt : Duration ,
1517 /// The smoothed round-trip time.
1618 pub smoothed_rtt : Duration ,
1719 /// The round-trip time variance.
1820 pub rtt_var : Duration ,
1921 /// Total bytes sent on the socket.
22+ #[ cfg( target_os = "macos" ) ]
2023 pub tx_bytes : u64 ,
2124 /// Total bytes received on the socket.
25+ #[ cfg( target_os = "macos" ) ]
2226 pub rx_bytes : u64 ,
2327 /// Total sender retransmitted bytes on the socket.
2428 pub retransmitted_bytes : u64 ,
@@ -133,31 +137,15 @@ impl From<libc::tcp_info> for TcpStats {
133137 let rwnd = info. tcpi_rcv_space ;
134138
135139 // RTT fields are reported in microseconds.
136- let last_rtt = Duration :: from_micros ( info. tcpi_rtt as u64 ) ;
137140 let smoothed_rtt = Duration :: from_micros ( info. tcpi_rtt as u64 ) ;
138141 let rtt_var = Duration :: from_micros ( info. tcpi_rttvar as u64 ) ;
139142
140- // Volumes: approximate using segment counts * MSS.
141- let tx_bytes = ( info. tcpi_segs_out as u64 ) . saturating_mul ( info. tcpi_snd_mss as u64 ) ;
142- let rx_bytes = ( info. tcpi_segs_in as u64 ) . saturating_mul ( info. tcpi_rcv_mss as u64 ) ;
143-
144143 // Retransmissions
145144 let retransmitted_packets = info. tcpi_total_retrans as u64 ;
146145 let retransmitted_bytes = retransmitted_packets. saturating_mul ( info. tcpi_snd_mss as u64 ) ;
147146 // RTO is in microseconds.
148147 let rto = Duration :: from_micros ( info. tcpi_rto as u64 ) ;
149148
150- Self {
151- cwnd,
152- rwnd,
153- last_rtt,
154- smoothed_rtt,
155- rtt_var,
156- tx_bytes,
157- rx_bytes,
158- retransmitted_bytes,
159- retransmitted_packets,
160- rto,
161- }
149+ Self { cwnd, rwnd, smoothed_rtt, rtt_var, retransmitted_bytes, retransmitted_packets, rto }
162150 }
163151}
0 commit comments