OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_unacked_packet_map.h" | 5 #include "net/quic/quic_unacked_packet_map.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "net/quic/quic_bug_tracker.h" | 9 #include "net/quic/quic_bug_tracker.h" |
10 #include "net/quic/quic_connection_stats.h" | 10 #include "net/quic/quic_connection_stats.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 DCHECK_GE(packet_number, least_unacked_ + unacked_packets_.size()); | 42 DCHECK_GE(packet_number, least_unacked_ + unacked_packets_.size()); |
43 while (least_unacked_ + unacked_packets_.size() < packet_number) { | 43 while (least_unacked_ + unacked_packets_.size() < packet_number) { |
44 unacked_packets_.push_back(TransmissionInfo()); | 44 unacked_packets_.push_back(TransmissionInfo()); |
45 unacked_packets_.back().is_unackable = true; | 45 unacked_packets_.back().is_unackable = true; |
46 } | 46 } |
47 | 47 |
48 const bool has_crypto_handshake = | 48 const bool has_crypto_handshake = |
49 packet->has_crypto_handshake == IS_HANDSHAKE; | 49 packet->has_crypto_handshake == IS_HANDSHAKE; |
50 TransmissionInfo info(packet->encryption_level, packet->packet_number_length, | 50 TransmissionInfo info(packet->encryption_level, packet->packet_number_length, |
51 transmission_type, sent_time, bytes_sent, | 51 transmission_type, sent_time, bytes_sent, |
52 has_crypto_handshake, packet->needs_padding); | 52 has_crypto_handshake, packet->num_padding_bytes); |
53 if (old_packet_number > 0) { | 53 if (old_packet_number > 0) { |
54 TransferRetransmissionInfo(old_packet_number, packet_number, | 54 TransferRetransmissionInfo(old_packet_number, packet_number, |
55 transmission_type, &info); | 55 transmission_type, &info); |
56 } | 56 } |
57 | 57 |
58 largest_sent_packet_ = packet_number; | 58 largest_sent_packet_ = packet_number; |
59 if (set_in_flight) { | 59 if (set_in_flight) { |
60 bytes_in_flight_ += bytes_sent; | 60 bytes_in_flight_ += bytes_sent; |
61 info.in_flight = true; | 61 info.in_flight = true; |
62 } | 62 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 DCHECK_GE(new_packet_number, least_unacked_ + unacked_packets_.size()); | 100 DCHECK_GE(new_packet_number, least_unacked_ + unacked_packets_.size()); |
101 DCHECK_NE(NOT_RETRANSMISSION, transmission_type); | 101 DCHECK_NE(NOT_RETRANSMISSION, transmission_type); |
102 | 102 |
103 TransmissionInfo* transmission_info = | 103 TransmissionInfo* transmission_info = |
104 &unacked_packets_.at(old_packet_number - least_unacked_); | 104 &unacked_packets_.at(old_packet_number - least_unacked_); |
105 QuicFrames* frames = &transmission_info->retransmittable_frames; | 105 QuicFrames* frames = &transmission_info->retransmittable_frames; |
106 for (AckListenerWrapper& wrapper : transmission_info->ack_listeners) { | 106 for (AckListenerWrapper& wrapper : transmission_info->ack_listeners) { |
107 wrapper.ack_listener->OnPacketRetransmitted(wrapper.length); | 107 wrapper.ack_listener->OnPacketRetransmitted(wrapper.length); |
108 } | 108 } |
109 | 109 |
110 // Swap the frames and preserve needs_padding and has_crypto_handshake. | 110 // Swap the frames and preserve num_padding_bytes and has_crypto_handshake. |
111 frames->swap(info->retransmittable_frames); | 111 frames->swap(info->retransmittable_frames); |
112 info->has_crypto_handshake = transmission_info->has_crypto_handshake; | 112 info->has_crypto_handshake = transmission_info->has_crypto_handshake; |
113 transmission_info->has_crypto_handshake = false; | 113 transmission_info->has_crypto_handshake = false; |
114 info->needs_padding = transmission_info->needs_padding; | 114 info->num_padding_bytes = transmission_info->num_padding_bytes; |
115 | 115 |
116 // Transfer the AckListeners if any are present. | 116 // Transfer the AckListeners if any are present. |
117 info->ack_listeners.swap(transmission_info->ack_listeners); | 117 info->ack_listeners.swap(transmission_info->ack_listeners); |
118 QUIC_BUG_IF(frames == nullptr) | 118 QUIC_BUG_IF(frames == nullptr) |
119 << "Attempt to retransmit packet with no " | 119 << "Attempt to retransmit packet with no " |
120 << "retransmittable frames: " << old_packet_number; | 120 << "retransmittable frames: " << old_packet_number; |
121 | 121 |
122 // Don't link old transmissions to new ones when version or | 122 // Don't link old transmissions to new ones when version or |
123 // encryption changes. | 123 // encryption changes. |
124 if (transmission_type == ALL_INITIAL_RETRANSMISSION || | 124 if (transmission_type == ALL_INITIAL_RETRANSMISSION || |
125 transmission_type == ALL_UNACKED_RETRANSMISSION) { | 125 transmission_type == ALL_UNACKED_RETRANSMISSION) { |
126 RemoveAckability(transmission_info); | 126 RemoveAckability(transmission_info); |
127 } else { | 127 } else { |
128 transmission_info->retransmission = new_packet_number; | 128 transmission_info->retransmission = new_packet_number; |
129 } | 129 } |
130 // Proactively remove obsolete packets so the least unacked can be raised. | 130 // Proactively remove obsolete packets so the least unacked can be raised. |
131 RemoveObsoletePackets(); | 131 RemoveObsoletePackets(); |
132 } | 132 } |
133 | 133 |
134 bool QuicUnackedPacketMap::HasRetransmittableFrames( | 134 bool QuicUnackedPacketMap::HasRetransmittableFrames( |
135 QuicPacketNumber packet_number) const { | 135 QuicPacketNumber packet_number) const { |
136 DCHECK_GE(packet_number, least_unacked_); | 136 DCHECK_GE(packet_number, least_unacked_); |
137 DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); | 137 DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); |
138 return !unacked_packets_[packet_number - least_unacked_] | 138 return !unacked_packets_[packet_number - least_unacked_] |
139 .retransmittable_frames.empty(); | 139 .retransmittable_frames.empty(); |
140 } | 140 } |
141 | 141 |
142 void QuicUnackedPacketMap::NackPacket(QuicPacketNumber packet_number, | 142 void QuicUnackedPacketMap::NackPacket(QuicPacketNumber packet_number, |
143 uint16_t min_nacks) { | 143 uint16_t min_nacks) { |
| 144 DCHECK(!FLAGS_quic_simplify_loss_detection); |
144 DCHECK_GE(packet_number, least_unacked_); | 145 DCHECK_GE(packet_number, least_unacked_); |
145 DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); | 146 DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); |
146 unacked_packets_[packet_number - least_unacked_].nack_count = max( | 147 unacked_packets_[packet_number - least_unacked_].nack_count = max( |
147 min_nacks, unacked_packets_[packet_number - least_unacked_].nack_count); | 148 min_nacks, unacked_packets_[packet_number - least_unacked_].nack_count); |
148 } | 149 } |
149 | 150 |
150 void QuicUnackedPacketMap::RemoveRetransmittability(TransmissionInfo* info) { | 151 void QuicUnackedPacketMap::RemoveRetransmittability(TransmissionInfo* info) { |
151 while (info->retransmission != 0) { | 152 while (info->retransmission != 0) { |
152 const QuicPacketNumber retransmission = info->retransmission; | 153 const QuicPacketNumber retransmission = info->retransmission; |
153 info->retransmission = 0; | 154 info->retransmission = 0; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } | 349 } |
349 } | 350 } |
350 return false; | 351 return false; |
351 } | 352 } |
352 | 353 |
353 QuicPacketNumber QuicUnackedPacketMap::GetLeastUnacked() const { | 354 QuicPacketNumber QuicUnackedPacketMap::GetLeastUnacked() const { |
354 return least_unacked_; | 355 return least_unacked_; |
355 } | 356 } |
356 | 357 |
357 } // namespace net | 358 } // namespace net |
OLD | NEW |