Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Unified Diff: net/quic/quic_sent_packet_manager.cc

Issue 523813003: Revert of Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_sent_packet_manager.cc
diff --git a/net/quic/quic_sent_packet_manager.cc b/net/quic/quic_sent_packet_manager.cc
index c592e133a2c99892ae72119de8fe85efd0185618..21a4fbcd84b6f16856a8ba4e21e8f2a851baee31 100644
--- a/net/quic/quic_sent_packet_manager.cc
+++ b/net/quic/quic_sent_packet_manager.cc
@@ -144,11 +144,8 @@
if (serialized_packet.retransmittable_frames) {
ack_notifier_manager_.OnSerializedPacket(serialized_packet);
}
+
unacked_packets_.AddPacket(serialized_packet);
-
- if (debug_delegate_ != NULL) {
- debug_delegate_->OnSerializedPacket(serialized_packet);
- }
}
void QuicSentPacketManager::OnRetransmittedPacket(
@@ -197,7 +194,6 @@
HandleAckForSentPackets(ack_frame);
InvokeLossDetection(ack_receive_time);
MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight);
- unacked_packets_.RemoveObsoletePackets();
sustained_bandwidth_recorder_.RecordEstimate(
send_algorithm_->InRecovery(),
@@ -261,15 +257,15 @@
// incoming_ack shows they've been seen by the peer.
QuicTime::Delta delta_largest_observed =
ack_frame.delta_time_largest_observed;
- QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
- for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
- it != unacked_packets_.end(); ++it, ++sequence_number) {
+ QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
+ while (it != unacked_packets_.end()) {
+ QuicPacketSequenceNumber sequence_number = it->first;
if (sequence_number > ack_frame.largest_observed) {
// These packets are still in flight.
break;
}
- if (ContainsKey(ack_frame.missing_packets, sequence_number)) {
+ if (IsAwaitingPacket(ack_frame, sequence_number)) {
// Consider it multiple nacks when there is a gap between the missing
// packet and the largest observed, since the purpose of a nack
// threshold is to tolerate re-ordering. This handles both StretchAcks
@@ -281,16 +277,17 @@
min_nacks = 1;
}
unacked_packets_.NackPacket(sequence_number, min_nacks);
+ ++it;
continue;
}
// Packet was acked, so remove it from our unacked packet list.
DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number;
// If data is associated with the most recent transmission of this
// packet, then inform the caller.
- if (it->in_flight) {
- packets_acked_[sequence_number] = *it;
- }
- MarkPacketHandled(sequence_number, *it, delta_largest_observed);
+ if (it->second.in_flight) {
+ packets_acked_[sequence_number] = it->second;
+ }
+ it = MarkPacketHandled(it, delta_largest_observed);
}
// Discard any retransmittable frames associated with revived packets.
@@ -308,25 +305,26 @@
void QuicSentPacketManager::RetransmitUnackedPackets(
RetransmissionType retransmission_type) {
- QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
- for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
- it != unacked_packets_.end(); ++it, ++sequence_number) {
- const RetransmittableFrames* frames = it->retransmittable_frames;
+ QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
+ while (it != unacked_packets_.end()) {
+ const RetransmittableFrames* frames = it->second.retransmittable_frames;
// TODO(ianswett): Consider adding a new retransmission type which removes
// all these old packets from unacked and retransmits them as new sequence
// numbers with no connection to the previous ones.
if (frames != NULL && (retransmission_type == ALL_PACKETS ||
frames->encryption_level() == ENCRYPTION_INITIAL)) {
- MarkForRetransmission(sequence_number, ALL_UNACKED_RETRANSMISSION);
- }
+ MarkForRetransmission(it->first, ALL_UNACKED_RETRANSMISSION);
+ }
+ ++it;
}
}
void QuicSentPacketManager::NeuterUnencryptedPackets() {
- QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
- for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
- it != unacked_packets_.end(); ++it, ++sequence_number) {
- const RetransmittableFrames* frames = it->retransmittable_frames;
+ QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
+ while (it != unacked_packets_.end()) {
+ const RetransmittableFrames* frames = it->second.retransmittable_frames;
+ QuicPacketSequenceNumber sequence_number = it->first;
+ ++it;
if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) {
// Once you're forward secure, no unencrypted packets will be sent, crypto
// or otherwise. Unencrypted packets are neutered and abandoned, to ensure
@@ -334,6 +332,8 @@
// perspective.
pending_retransmissions_.erase(sequence_number);
unacked_packets_.RemoveFromInFlight(sequence_number);
+ // RemoveRetransmittibility is safe because only the newest sequence
+ // number can have frames.
unacked_packets_.RemoveRetransmittability(sequence_number);
}
}
@@ -358,7 +358,7 @@
}
void QuicSentPacketManager::RecordSpuriousRetransmissions(
- const SequenceNumberList& all_transmissions,
+ const SequenceNumberSet& all_transmissions,
QuicPacketSequenceNumber acked_sequence_number) {
if (acked_sequence_number < first_rto_transmission_) {
// Cancel all pending RTO transmissions and restore their in flight status.
@@ -376,9 +376,11 @@
first_rto_transmission_ = 0;
++stats_->spurious_rto_count;
}
- for (SequenceNumberList::const_reverse_iterator it =
- all_transmissions.rbegin();
- it != all_transmissions.rend() && *it > acked_sequence_number; ++it) {
+ for (SequenceNumberSet::const_iterator
+ it = all_transmissions.upper_bound(acked_sequence_number),
+ end = all_transmissions.end();
+ it != end;
+ ++it) {
const TransmissionInfo& retransmit_info =
unacked_packets_.GetTransmissionInfo(*it);
@@ -436,8 +438,7 @@
const TransmissionInfo& transmission_info =
unacked_packets_.GetTransmissionInfo(sequence_number);
QuicPacketSequenceNumber newest_transmission =
- transmission_info.all_transmissions == NULL ?
- sequence_number : *transmission_info.all_transmissions->rbegin();
+ *transmission_info.all_transmissions->rbegin();
// This packet has been revived at the receiver. If we were going to
// retransmit it, do not retransmit it anymore.
pending_retransmissions_.erase(newest_transmission);
@@ -452,36 +453,53 @@
unacked_packets_.RemoveRetransmittability(sequence_number);
}
-void QuicSentPacketManager::MarkPacketHandled(
- QuicPacketSequenceNumber sequence_number,
- const TransmissionInfo& info,
+QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled(
+ QuicUnackedPacketMap::const_iterator it,
QuicTime::Delta delta_largest_observed) {
+ LOG_IF(DFATAL, it == unacked_packets_.end())
+ << "MarkPacketHandled must be passed a valid iterator entry.";
+ const QuicPacketSequenceNumber sequence_number = it->first;
+ const TransmissionInfo& transmission_info = it->second;
+
QuicPacketSequenceNumber newest_transmission =
- info.all_transmissions == NULL ?
- sequence_number : *info.all_transmissions->rbegin();
+ *transmission_info.all_transmissions->rbegin();
// Remove the most recent packet, if it is pending retransmission.
pending_retransmissions_.erase(newest_transmission);
- // The AckNotifierManager needs to be notified about the most recent
- // transmission, since that's the one only one it tracks.
- ack_notifier_manager_.OnPacketAcked(newest_transmission,
- delta_largest_observed);
- if (newest_transmission != sequence_number) {
- RecordSpuriousRetransmissions(*info.all_transmissions, sequence_number);
- // Remove the most recent packet from flight if it's a crypto handshake
- // packet, since they won't be acked now that one has been processed.
- // Other crypto handshake packets won't be in flight, only the newest
- // transmission of a crypto packet is in flight at once.
- // TODO(ianswett): Instead of handling all crypto packets special,
- // only handle NULL encrypted packets in a special way.
- if (HasCryptoHandshake(
- unacked_packets_.GetTransmissionInfo(newest_transmission))) {
- unacked_packets_.RemoveFromInFlight(newest_transmission);
- }
- }
-
+ // Notify observers about the ACKed packet.
+ {
+ // The AckNotifierManager needs to be notified about the most recent
+ // transmission, since that's the one only one it tracks.
+ ack_notifier_manager_.OnPacketAcked(newest_transmission,
+ delta_largest_observed);
+ if (newest_transmission != sequence_number) {
+ RecordSpuriousRetransmissions(*transmission_info.all_transmissions,
+ sequence_number);
+ }
+ }
+
+ // Two cases for MarkPacketHandled:
+ // 1) Handle the most recent or a crypto packet, so remove all transmissions.
+ // 2) Handle old transmission, keep all other pending transmissions,
+ // but disassociate them from one another.
+
+ // If it's a crypto handshake packet, discard it and all retransmissions,
+ // since they won't be acked now that one has been processed.
+ // TODO(ianswett): Instead of handling all crypto packets in a special way,
+ // only handle NULL encrypted packets in a special way.
+ if (HasCryptoHandshake(
+ unacked_packets_.GetTransmissionInfo(newest_transmission))) {
+ unacked_packets_.RemoveFromInFlight(newest_transmission);
+ }
unacked_packets_.RemoveFromInFlight(sequence_number);
unacked_packets_.RemoveRetransmittability(sequence_number);
+
+ QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin();
+ while (next_unacked != unacked_packets_.end() &&
+ next_unacked->first <= sequence_number) {
+ ++next_unacked;
+ }
+ return next_unacked;
}
bool QuicSentPacketManager::IsUnacked(
@@ -495,7 +513,7 @@
QuicPacketSequenceNumber
QuicSentPacketManager::GetLeastUnackedSentPacket() const {
- return unacked_packets_.GetLeastUnacked();
+ return unacked_packets_.GetLeastUnackedSentPacket();
}
bool QuicSentPacketManager::OnPacketSent(
@@ -529,8 +547,7 @@
unacked_packets_.SetSent(sequence_number, sent_time, bytes, in_flight);
if (debug_delegate_ != NULL) {
- debug_delegate_->OnSentPacket(
- sequence_number, sent_time, bytes, transmission_type);
+ debug_delegate_->OnSentPacket(sequence_number, sent_time, bytes);
}
// Reset the retransmission timer anytime a pending packet is sent.
@@ -580,12 +597,13 @@
min(kMaxHandshakeRetransmissionBackoffs,
consecutive_crypto_retransmission_count_ + 1);
bool packet_retransmitted = false;
- QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
- it != unacked_packets_.end(); ++it, ++sequence_number) {
+ it != unacked_packets_.end(); ++it) {
+ QuicPacketSequenceNumber sequence_number = it->first;
+ const RetransmittableFrames* frames = it->second.retransmittable_frames;
// Only retransmit frames which are in flight, and therefore have been sent.
- if (!it->in_flight || it->retransmittable_frames == NULL ||
- it->retransmittable_frames->HasCryptoHandshake() != IS_HANDSHAKE) {
+ if (!it->second.in_flight || frames == NULL ||
+ frames->HasCryptoHandshake() != IS_HANDSHAKE) {
continue;
}
packet_retransmitted = true;
@@ -599,15 +617,16 @@
if (pending_timer_transmission_count_ == 0) {
return false;
}
- QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
- it != unacked_packets_.end(); ++it, ++sequence_number) {
+ it != unacked_packets_.end(); ++it) {
+ QuicPacketSequenceNumber sequence_number = it->first;
+ const RetransmittableFrames* frames = it->second.retransmittable_frames;
// Only retransmit frames which are in flight, and therefore have been sent.
- if (!it->in_flight || it->retransmittable_frames == NULL) {
+ if (!it->second.in_flight || frames == NULL) {
continue;
}
if (!handshake_confirmed_) {
- DCHECK_NE(IS_HANDSHAKE, it->retransmittable_frames->HasCryptoHandshake());
+ DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake());
}
MarkForRetransmission(sequence_number, TLP_RETRANSMISSION);
return true;
@@ -619,17 +638,18 @@
void QuicSentPacketManager::RetransmitAllPackets() {
DVLOG(1) << "RetransmitAllPackets() called with "
- << unacked_packets_.GetNumUnackedPacketsDebugOnly()
- << " unacked packets.";
+ << unacked_packets_.GetNumUnackedPackets() << " unacked packets.";
// Request retransmission of all retransmittable packets when the RTO
// fires, and let the congestion manager decide how many to send
// immediately and the remaining packets will be queued.
// Abandon any non-retransmittable packets that are sufficiently old.
bool packets_retransmitted = false;
- QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
- for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
- it != unacked_packets_.end(); ++it, ++sequence_number) {
- if (it->retransmittable_frames != NULL) {
+ QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
+ while (it != unacked_packets_.end()) {
+ const RetransmittableFrames* frames = it->second.retransmittable_frames;
+ QuicPacketSequenceNumber sequence_number = it->first;
+ ++it;
+ if (frames != NULL) {
packets_retransmitted = true;
MarkForRetransmission(sequence_number, RTO_RETRANSMISSION);
} else {
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698