Turn ConnectionStateOnSentPacket into an opaque class.
This will be useful when experimenting with alternative internal representations of ConnectionStateOnSentPacket fields.
PiperOrigin-RevId: 619277286
diff --git a/quiche/quic/core/congestion_control/bandwidth_sampler.cc b/quiche/quic/core/congestion_control/bandwidth_sampler.cc
index 05687d7..6b93c13 100644
--- a/quiche/quic/core/congestion_control/bandwidth_sampler.cc
+++ b/quiche/quic/core/congestion_control/bandwidth_sampler.cc
@@ -269,7 +269,7 @@
connection_state_map_.Remove(
packet_number, [&](const ConnectionStateOnSentPacket& sent_packet) {
QUIC_CODE_COUNT(quic_bandwidth_sampler_packet_neutered);
- total_bytes_neutered_ += sent_packet.size;
+ total_bytes_neutered_ += sent_packet.size();
});
}
@@ -402,10 +402,10 @@
BandwidthSample BandwidthSampler::OnPacketAcknowledgedInner(
QuicTime ack_time, QuicPacketNumber packet_number,
const ConnectionStateOnSentPacket& sent_packet) {
- total_bytes_acked_ += sent_packet.size;
+ total_bytes_acked_ += sent_packet.size();
total_bytes_sent_at_last_acked_packet_ =
- sent_packet.send_time_state.total_bytes_sent;
- last_acked_packet_sent_time_ = sent_packet.sent_time;
+ sent_packet.send_time_state().total_bytes_sent;
+ last_acked_packet_sent_time_ = sent_packet.sent_time();
last_acked_packet_ack_time_ = ack_time;
if (overestimate_avoidance_) {
recent_ack_points_.Update(ack_time, total_bytes_acked_);
@@ -426,7 +426,7 @@
// There might have been no packets acknowledged at the moment when the
// current packet was sent. In that case, there is no bandwidth sample to
// make.
- if (sent_packet.last_acked_packet_sent_time == QuicTime::Zero()) {
+ if (sent_packet.last_acked_packet_sent_time() == QuicTime::Zero()) {
QUIC_BUG(quic_bug_10437_4)
<< "sent_packet.last_acked_packet_sent_time is zero";
return BandwidthSample();
@@ -435,20 +435,20 @@
// Infinite rate indicates that the sampler is supposed to discard the
// current send rate sample and use only the ack rate.
QuicBandwidth send_rate = QuicBandwidth::Infinite();
- if (sent_packet.sent_time > sent_packet.last_acked_packet_sent_time) {
+ if (sent_packet.sent_time() > sent_packet.last_acked_packet_sent_time()) {
send_rate = QuicBandwidth::FromBytesAndTimeDelta(
- sent_packet.send_time_state.total_bytes_sent -
- sent_packet.total_bytes_sent_at_last_acked_packet,
- sent_packet.sent_time - sent_packet.last_acked_packet_sent_time);
+ sent_packet.send_time_state().total_bytes_sent -
+ sent_packet.total_bytes_sent_at_last_acked_packet(),
+ sent_packet.sent_time() - sent_packet.last_acked_packet_sent_time());
}
AckPoint a0;
if (overestimate_avoidance_ &&
- ChooseA0Point(sent_packet.send_time_state.total_bytes_acked, &a0)) {
+ ChooseA0Point(sent_packet.send_time_state().total_bytes_acked, &a0)) {
QUIC_DVLOG(2) << "Using a0 point: " << a0;
} else {
- a0.ack_time = sent_packet.last_acked_packet_ack_time,
- a0.total_bytes_acked = sent_packet.send_time_state.total_bytes_acked;
+ a0.ack_time = sent_packet.last_acked_packet_ack_time(),
+ a0.total_bytes_acked = sent_packet.send_time_state().total_bytes_acked;
}
// During the slope calculation, ensure that ack time of the current packet is
@@ -457,7 +457,7 @@
if (ack_time <= a0.ack_time) {
// TODO(wub): Compare this code count before and after fixing clock jitter
// issue.
- if (a0.ack_time == sent_packet.sent_time) {
+ if (a0.ack_time == sent_packet.sent_time()) {
// This is the 1st packet after quiescense.
QUIC_CODE_COUNT_N(quic_prev_ack_time_larger_than_current_ack_time, 1, 2);
} else {
@@ -482,7 +482,7 @@
// Note: this sample does not account for delayed acknowledgement time. This
// means that the RTT measurements here can be artificially high, especially
// on low bandwidth connections.
- sample.rtt = ack_time - sent_packet.sent_time;
+ sample.rtt = ack_time - sent_packet.sent_time();
sample.send_rate = send_rate;
SentPacketToSendTimeState(sent_packet, &sample.state_at_send);
@@ -547,7 +547,7 @@
void BandwidthSampler::SentPacketToSendTimeState(
const ConnectionStateOnSentPacket& sent_packet,
SendTimeState* send_time_state) const {
- *send_time_state = sent_packet.send_time_state;
+ *send_time_state = sent_packet.send_time_state();
send_time_state->is_valid = true;
}
diff --git a/quiche/quic/core/congestion_control/bandwidth_sampler.h b/quiche/quic/core/congestion_control/bandwidth_sampler.h
index 87989dc..457dbcd 100644
--- a/quiche/quic/core/congestion_control/bandwidth_sampler.h
+++ b/quiche/quic/core/congestion_control/bandwidth_sampler.h
@@ -454,28 +454,35 @@
// and the state of the connection at the moment the packet was sent,
// specifically the information about the most recently acknowledged packet at
// that moment.
- struct QUICHE_EXPORT ConnectionStateOnSentPacket {
+ class QUICHE_EXPORT ConnectionStateOnSentPacket {
+ public:
// Time at which the packet is sent.
- QuicTime sent_time;
+ QuicTime sent_time() const { return sent_time_; }
// Size of the packet.
- QuicByteCount size;
+ QuicByteCount size() const { return size_; }
// The value of |total_bytes_sent_at_last_acked_packet_| at the time the
// packet was sent.
- QuicByteCount total_bytes_sent_at_last_acked_packet;
+ QuicByteCount total_bytes_sent_at_last_acked_packet() const {
+ return total_bytes_sent_at_last_acked_packet_;
+ }
// The value of |last_acked_packet_sent_time_| at the time the packet was
// sent.
- QuicTime last_acked_packet_sent_time;
+ QuicTime last_acked_packet_sent_time() const {
+ return last_acked_packet_sent_time_;
+ }
// The value of |last_acked_packet_ack_time_| at the time the packet was
// sent.
- QuicTime last_acked_packet_ack_time;
+ QuicTime last_acked_packet_ack_time() const {
+ return last_acked_packet_ack_time_;
+ }
// Send time states that are returned to the congestion controller when the
// packet is acked or lost.
- SendTimeState send_time_state;
+ const SendTimeState& send_time_state() const { return send_time_state_; }
// Snapshot constructor. Records the current state of the bandwidth
// sampler.
@@ -483,35 +490,43 @@
ConnectionStateOnSentPacket(QuicTime sent_time, QuicByteCount size,
QuicByteCount bytes_in_flight,
const BandwidthSampler& sampler)
- : sent_time(sent_time),
- size(size),
- total_bytes_sent_at_last_acked_packet(
+ : sent_time_(sent_time),
+ size_(size),
+ total_bytes_sent_at_last_acked_packet_(
sampler.total_bytes_sent_at_last_acked_packet_),
- last_acked_packet_sent_time(sampler.last_acked_packet_sent_time_),
- last_acked_packet_ack_time(sampler.last_acked_packet_ack_time_),
- send_time_state(sampler.is_app_limited_, sampler.total_bytes_sent_,
- sampler.total_bytes_acked_, sampler.total_bytes_lost_,
- bytes_in_flight) {}
+ last_acked_packet_sent_time_(sampler.last_acked_packet_sent_time_),
+ last_acked_packet_ack_time_(sampler.last_acked_packet_ack_time_),
+ send_time_state_(sampler.is_app_limited_, sampler.total_bytes_sent_,
+ sampler.total_bytes_acked_,
+ sampler.total_bytes_lost_, bytes_in_flight) {}
// Default constructor. Required to put this structure into
// PacketNumberIndexedQueue.
ConnectionStateOnSentPacket()
- : sent_time(QuicTime::Zero()),
- size(0),
- total_bytes_sent_at_last_acked_packet(0),
- last_acked_packet_sent_time(QuicTime::Zero()),
- last_acked_packet_ack_time(QuicTime::Zero()) {}
+ : sent_time_(QuicTime::Zero()),
+ size_(0),
+ total_bytes_sent_at_last_acked_packet_(0),
+ last_acked_packet_sent_time_(QuicTime::Zero()),
+ last_acked_packet_ack_time_(QuicTime::Zero()) {}
friend QUICHE_EXPORT std::ostream& operator<<(
std::ostream& os, const ConnectionStateOnSentPacket& p) {
- os << "{sent_time:" << p.sent_time << ", size:" << p.size
+ os << "{sent_time:" << p.sent_time() << ", size:" << p.size()
<< ", total_bytes_sent_at_last_acked_packet:"
- << p.total_bytes_sent_at_last_acked_packet
- << ", last_acked_packet_sent_time:" << p.last_acked_packet_sent_time
- << ", last_acked_packet_ack_time:" << p.last_acked_packet_ack_time
- << ", send_time_state:" << p.send_time_state << "}";
+ << p.total_bytes_sent_at_last_acked_packet()
+ << ", last_acked_packet_sent_time:" << p.last_acked_packet_sent_time()
+ << ", last_acked_packet_ack_time:" << p.last_acked_packet_ack_time()
+ << ", send_time_state:" << p.send_time_state() << "}";
return os;
}
+
+ private:
+ QuicTime sent_time_;
+ QuicByteCount size_;
+ QuicByteCount total_bytes_sent_at_last_acked_packet_;
+ QuicTime last_acked_packet_sent_time_;
+ QuicTime last_acked_packet_ack_time_;
+ SendTimeState send_time_state_;
};
BandwidthSample OnPacketAcknowledged(QuicTime ack_time,
diff --git a/quiche/quic/core/congestion_control/bandwidth_sampler_test.cc b/quiche/quic/core/congestion_control/bandwidth_sampler_test.cc
index 97a0bf3..7d3d54b 100644
--- a/quiche/quic/core/congestion_control/bandwidth_sampler_test.cc
+++ b/quiche/quic/core/congestion_control/bandwidth_sampler_test.cc
@@ -26,7 +26,7 @@
static QuicByteCount GetPacketSize(const BandwidthSampler& sampler,
QuicPacketNumber packet_number) {
- return sampler.connection_state_map_.GetEntry(packet_number)->size;
+ return sampler.connection_state_map_.GetEntry(packet_number)->size();
}
};