1 // Copyright 2023 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "quiche/quic/core/web_transport_stats.h" 6 7 #include "absl/time/time.h" 8 #include "quiche/quic/core/congestion_control/rtt_stats.h" 9 #include "quiche/quic/core/quic_session.h" 10 #include "quiche/web_transport/web_transport.h" 11 12 namespace quic { 13 WebTransportDatagramStatsForQuicSession(const QuicSession & session)14webtransport::DatagramStats WebTransportDatagramStatsForQuicSession( 15 const QuicSession& session) { 16 webtransport::DatagramStats result; 17 result.expired_outgoing = session.expired_datagrams_in_default_queue(); 18 result.lost_outgoing = session.total_datagrams_lost(); 19 return result; 20 } 21 WebTransportStatsForQuicSession(const QuicSession & session)22webtransport::SessionStats WebTransportStatsForQuicSession( 23 const QuicSession& session) { 24 const RttStats* rtt_stats = 25 session.connection()->sent_packet_manager().GetRttStats(); 26 webtransport::SessionStats result; 27 result.min_rtt = rtt_stats->min_rtt().ToAbsl(); 28 result.smoothed_rtt = rtt_stats->smoothed_rtt().ToAbsl(); 29 result.rtt_variation = rtt_stats->mean_deviation().ToAbsl(); 30 result.estimated_send_rate_bps = session.connection() 31 ->sent_packet_manager() 32 .BandwidthEstimate() 33 .ToBitsPerSecond(); 34 result.datagram_stats = WebTransportDatagramStatsForQuicSession(session); 35 return result; 36 } 37 38 } // namespace quic 39