diff options
Diffstat (limited to 'net/quic/quic_connection.cc')
| -rw-r--r-- | net/quic/quic_connection.cc | 339 |
1 files changed, 85 insertions, 254 deletions
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc index a210022..74bc9e3 100644 --- a/net/quic/quic_connection.cc +++ b/net/quic/quic_connection.cc @@ -31,7 +31,6 @@ #include "net/quic/quic_bandwidth.h" #include "net/quic/quic_bug_tracker.h" #include "net/quic/quic_config.h" -#include "net/quic/quic_fec_group.h" #include "net/quic/quic_flags.h" #include "net/quic/quic_packet_generator.h" #include "net/quic/quic_utils.h" @@ -60,10 +59,6 @@ namespace { // This will likely have to be tuned. const QuicPacketNumber kMaxPacketGap = 5000; -// Limit the number of FEC groups to two. If we get enough out of order packets -// that this becomes limiting, we can revisit. -const size_t kMaxFecGroups = 2; - // Maximum number of acks received before sending an ack in response. const QuicPacketCount kMaxPacketsReceivedBeforeAckSend = 20; @@ -91,10 +86,10 @@ class AckAlarm : public QuicAlarm::Delegate { public: explicit AckAlarm(QuicConnection* connection) : connection_(connection) {} - QuicTime OnAlarm() override { + void OnAlarm() override { DCHECK(connection_->ack_frame_updated()); - connection_->SendAck(); - return QuicTime::Zero(); + QuicConnection::ScopedPacketBundler bundler(connection_, + QuicConnection::SEND_ACK); } private: @@ -111,10 +106,7 @@ class RetransmissionAlarm : public QuicAlarm::Delegate { explicit RetransmissionAlarm(QuicConnection* connection) : connection_(connection) {} - QuicTime OnAlarm() override { - connection_->OnRetransmissionTimeout(); - return QuicTime::Zero(); - } + void OnAlarm() override { connection_->OnRetransmissionTimeout(); } private: QuicConnection* connection_; @@ -128,11 +120,7 @@ class SendAlarm : public QuicAlarm::Delegate { public: explicit SendAlarm(QuicConnection* connection) : connection_(connection) {} - QuicTime OnAlarm() override { - connection_->WriteIfNotBlocked(); - // Never reschedule the alarm, since CanWrite does that. - return QuicTime::Zero(); - } + void OnAlarm() override { connection_->WriteAndBundleAcksIfNotBlocked(); } private: QuicConnection* connection_; @@ -144,11 +132,7 @@ class TimeoutAlarm : public QuicAlarm::Delegate { public: explicit TimeoutAlarm(QuicConnection* connection) : connection_(connection) {} - QuicTime OnAlarm() override { - connection_->CheckForTimeout(); - // Never reschedule the alarm, since CheckForTimeout does that. - return QuicTime::Zero(); - } + void OnAlarm() override { connection_->CheckForTimeout(); } private: QuicConnection* connection_; @@ -160,10 +144,7 @@ class PingAlarm : public QuicAlarm::Delegate { public: explicit PingAlarm(QuicConnection* connection) : connection_(connection) {} - QuicTime OnAlarm() override { - connection_->OnPingTimeout(); - return QuicTime::Zero(); - } + void OnAlarm() override { connection_->OnPingTimeout(); } private: QuicConnection* connection_; @@ -176,11 +157,7 @@ class MtuDiscoveryAlarm : public QuicAlarm::Delegate { explicit MtuDiscoveryAlarm(QuicConnection* connection) : connection_(connection) {} - QuicTime OnAlarm() override { - connection_->DiscoverMtu(); - // DiscoverMtu() handles rescheduling the alarm by itself. - return QuicTime::Zero(); - } + void OnAlarm() override { connection_->DiscoverMtu(); } private: QuicConnection* connection_; @@ -188,23 +165,6 @@ class MtuDiscoveryAlarm : public QuicAlarm::Delegate { DISALLOW_COPY_AND_ASSIGN(MtuDiscoveryAlarm); }; -// This alarm may be scheduled when an FEC protected packet is sent out. -class FecAlarm : public QuicAlarm::Delegate { - public: - explicit FecAlarm(QuicPacketGenerator* packet_generator) - : packet_generator_(packet_generator) {} - - QuicTime OnAlarm() override { - packet_generator_->OnFecTimeout(); - return QuicTime::Zero(); - } - - private: - QuicPacketGenerator* packet_generator_; - - DISALLOW_COPY_AND_ASSIGN(FecAlarm); -}; - // Listens for acks of MTU discovery packets and raises the maximum packet size // of the connection if the probe succeeds. class MtuDiscoveryAckListener : public QuicAckListenerInterface { @@ -265,8 +225,8 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id, peer_address_(address), migrating_peer_port_(0), last_packet_decrypted_(false), - last_packet_revived_(false), last_size_(0), + current_packet_data_(nullptr), last_decrypted_packet_level_(ENCRYPTION_NONE), should_last_packet_instigate_acks_(false), largest_seen_packet_with_ack_(0), @@ -278,11 +238,13 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id, received_packet_manager_(&stats_), ack_queued_(false), num_retransmittable_packets_received_since_last_ack_sent_(0), + last_ack_had_missing_packets_(false), num_packets_received_since_last_ack_sent_(0), stop_waiting_count_(0), - ack_decimation_enabled_(false), + ack_mode_(TCP_ACKING), delay_setting_retransmission_alarm_(false), pending_retransmission_alarm_(false), + defer_send_in_response_to_packets_(false), arena_(), ack_alarm_(helper->CreateAlarm(arena_.New<AckAlarm>(this), &arena_)), retransmission_alarm_( @@ -302,8 +264,6 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id, random_generator_, helper->GetBufferAllocator(), this), - fec_alarm_(helper->CreateAlarm(arena_.New<FecAlarm>(&packet_generator_), - &arena_)), idle_network_timeout_(QuicTime::Delta::Infinite()), handshake_timeout_(QuicTime::Delta::Infinite()), time_of_last_received_packet_(clock_->ApproximateNow()), @@ -356,7 +316,6 @@ QuicConnection::~QuicConnection() { if (termination_packets_.get() != nullptr) { STLDeleteElements(termination_packets_.get()); } - STLDeleteValues(&group_map_); ClearQueuedPackets(); } @@ -395,16 +354,6 @@ void QuicConnection::SetFromConfig(const QuicConfig& config) { } max_undecryptable_packets_ = config.max_undecryptable_packets(); - if (config.HasClientSentConnectionOption(kFSPA, perspective_)) { - packet_generator_.set_fec_send_policy(FecSendPolicy::FEC_ALARM_TRIGGER); - } - if (config.HasClientSentConnectionOption(kFRTT, perspective_)) { - // TODO(rtenneti): Delete this code after the 0.25 RTT FEC experiment. - const float kFecTimeoutRttMultiplier = 0.25; - packet_generator_.set_rtt_multiplier_for_fec_timeout( - kFecTimeoutRttMultiplier); - } - if (config.HasClientSentConnectionOption(kMTUH, perspective_)) { SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeHigh); } @@ -415,7 +364,11 @@ void QuicConnection::SetFromConfig(const QuicConfig& config) { debug_visitor_->OnSetFromConfig(config); } if (config.HasClientSentConnectionOption(kACKD, perspective_)) { - ack_decimation_enabled_ = true; + ack_mode_ = ACK_DECIMATION; + } + if (FLAGS_quic_ack_decimation2 && + config.HasClientSentConnectionOption(kAKD2, perspective_)) { + ack_mode_ = ACK_DECIMATION_WITH_REORDERING; } } @@ -470,20 +423,8 @@ void QuicConnection::OnError(QuicFramer* framer) { SendConnectionCloseWithDetails(framer->error(), framer->detailed_error()); } -void QuicConnection::MaybeSetFecAlarm(QuicPacketNumber packet_number) { - if (fec_alarm_->IsSet()) { - return; - } - QuicTime::Delta timeout = packet_generator_.GetFecTimeout(packet_number); - if (!timeout.IsInfinite()) { - fec_alarm_->Update(clock_->ApproximateNow().Add(timeout), - QuicTime::Delta::FromMilliseconds(1)); - } -} - void QuicConnection::OnPacket() { last_packet_decrypted_ = false; - last_packet_revived_ = false; } void QuicConnection::OnPublicResetPacket(const QuicPublicResetPacket& packet) { @@ -601,8 +542,6 @@ void QuicConnection::OnVersionNegotiationPacket( RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION); } -void QuicConnection::OnRevivedPacket() {} - bool QuicConnection::OnUnauthenticatedPublicHeader( const QuicPacketPublicHeader& header) { if (header.connection_id == connection_id_) { @@ -689,15 +628,6 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { return true; } -void QuicConnection::OnFecProtectedPayload(StringPiece payload) { - DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); - DCHECK_NE(0u, last_header_.fec_group); - QuicFecGroup* group = GetFecGroup(); - if (group != nullptr) { - group->Update(last_decrypted_packet_level_, last_header_, payload); - } -} - bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { DCHECK(connected_); if (debug_visitor_ != nullptr) { @@ -708,6 +638,7 @@ bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { QUIC_BUG << ENDPOINT << "Received an unencrypted data frame: closing connection" << " packet_number:" << last_header_.packet_number + << " stream_id:" << frame.stream_id << " received_packets:" << received_packet_manager_.ack_frame(); SendConnectionCloseWithDetails(QUIC_UNENCRYPTED_STREAM_DATA, "Unencrypted stream data seen"); @@ -773,8 +704,6 @@ void QuicConnection::ProcessStopWaitingFrame( const QuicStopWaitingFrame& stop_waiting) { largest_seen_packet_with_stop_waiting_ = last_header_.packet_number; received_packet_manager_.UpdatePacketInformationSentByPeer(stop_waiting); - // Possibly close any FecGroups which are now irrelevant. - CloseFecGroupsBefore(stop_waiting.least_unacked + 1); } bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { @@ -820,7 +749,10 @@ const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { if (incoming_ack.largest_observed < sent_packet_manager_.largest_observed()) { LOG(WARNING) << ENDPOINT << "Peer's largest_observed packet decreased:" << incoming_ack.largest_observed << " vs " - << sent_packet_manager_.largest_observed(); + << sent_packet_manager_.largest_observed() + << " packet_number:" << last_header_.packet_number + << " largest seen with ack:" << largest_seen_packet_with_ack_ + << " connection_id: " << connection_id_; // A new ack has a diminished largest_observed value. Error out. // If this was an old packet, we wouldn't even have checked. return "Largest observed too low"; @@ -854,14 +786,6 @@ const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { return "Invalid entropy"; } - if (incoming_ack.latest_revived_packet != 0 && - !incoming_ack.missing_packets.Contains( - incoming_ack.latest_revived_packet)) { - LOG(WARNING) << ENDPOINT - << "Peer specified revived packet which was not missing." - << " revived_packet:" << incoming_ack.latest_revived_packet; - return "Invalid revived packet"; - } return nullptr; } @@ -887,15 +811,6 @@ const char* QuicConnection::ValidateStopWaitingFrame( return nullptr; } -void QuicConnection::OnFecData(StringPiece redundancy) { - DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); - DCHECK_NE(0u, last_header_.fec_group); - QuicFecGroup* group = GetFecGroup(); - if (group != nullptr) { - group->UpdateFec(last_decrypted_packet_level_, last_header_, redundancy); - } -} - bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { DCHECK(connected_); if (debug_visitor_ != nullptr) { @@ -987,8 +902,7 @@ void QuicConnection::OnPacketComplete() { return; } - DVLOG(1) << ENDPOINT << (last_packet_revived_ ? "Revived" : "Got") - << " packet " << last_header_.packet_number << " for " + DVLOG(1) << ENDPOINT << "Got packet " << last_header_.packet_number << " for " << last_header_.public_header.connection_id; // An ack will be sent if a missing retransmittable packet was received; @@ -996,15 +910,11 @@ void QuicConnection::OnPacketComplete() { should_last_packet_instigate_acks_ && received_packet_manager_.IsMissing(last_header_.packet_number); - // Record received or revived packet to populate ack info correctly before - // processing stream frames, since the processing may result in a response - // packet with a bundled ack. - if (last_packet_revived_) { - received_packet_manager_.RecordPacketRevived(last_header_.packet_number); - } else { - received_packet_manager_.RecordPacketReceived( - last_size_, last_header_, time_of_last_received_packet_); - } + // Record received to populate ack info correctly before processing stream + // frames, since the processing may result in a response packet with a bundled + // ack. + received_packet_manager_.RecordPacketReceived(last_size_, last_header_, + time_of_last_received_packet_); // Process stop waiting frames here, instead of inline, because the packet // needs to be considered 'received' before the entropy can be updated. @@ -1019,7 +929,6 @@ void QuicConnection::OnPacketComplete() { ClearLastFrames(); MaybeCloseIfTooManyOutstandingPackets(); - MaybeProcessRevivedPacket(); } void QuicConnection::MaybeQueueAck(bool was_missing) { @@ -1033,13 +942,16 @@ void QuicConnection::MaybeQueueAck(bool was_missing) { // Determine whether the newly received packet was missing before recording // the received packet. - if (was_missing) { + // Ack decimation with reordering relies on the timer to send an ack, but if + // missing packets we reported in the previous ack, send an ack immediately. + if (was_missing && (ack_mode_ != ACK_DECIMATION_WITH_REORDERING || + last_ack_had_missing_packets_)) { ack_queued_ = true; } if (should_last_packet_instigate_acks_ && !ack_queued_) { ++num_retransmittable_packets_received_since_last_ack_sent_; - if (ack_decimation_enabled_ && + if (ack_mode_ != TCP_ACKING && last_header_.packet_number > kMinReceivedBeforeAckDecimation) { // Ack up to 10 packets at once. if (num_retransmittable_packets_received_since_last_ack_sent_ >= @@ -1064,10 +976,18 @@ void QuicConnection::MaybeQueueAck(bool was_missing) { } // If there are new missing packets to report, send an ack immediately. - // TODO(ianswett): Consider allowing 1ms of reordering for the - // ack decimation experiment. if (received_packet_manager_.HasNewMissingPackets()) { - ack_queued_ = true; + if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) { + // Wait the minimum of an eighth min_rtt and the existing ack time. + QuicTime ack_time = clock_->ApproximateNow().Add( + sent_packet_manager_.GetRttStats()->min_rtt().Multiply(0.125)); + if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) { + ack_alarm_->Cancel(); + ack_alarm_->Set(ack_time); + } + } else { + ack_queued_ = true; + } } } @@ -1119,11 +1039,14 @@ void QuicConnection::MaybeSendInResponseToPacket() { if (!connected_) { return; } - ScopedPacketBundler bundler(this, ack_queued_ ? SEND_ACK : NO_ACK); - // Now that we have received an ack, we might be able to send packets which // are queued locally, or drain streams which are blocked. - WriteIfNotBlocked(); + if (defer_send_in_response_to_packets_) { + send_alarm_->Cancel(); + send_alarm_->Set(clock_->ApproximateNow()); + } else { + WriteAndBundleAcksIfNotBlocked(); + } } void QuicConnection::SendVersionNegotiationPacket() { @@ -1162,7 +1085,6 @@ QuicConsumedData QuicConnection::SendStreamData( QuicIOVector iov, QuicStreamOffset offset, bool fin, - FecProtection fec_protection, QuicAckListenerInterface* listener) { if (!fin && iov.total_length == 0) { QUIC_BUG << "Attempt to send empty stream frame"; @@ -1184,8 +1106,7 @@ QuicConsumedData QuicConnection::SendStreamData( // processing left that may cause received_info_ to change. ScopedRetransmissionScheduler alarm_delayer(this); ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); - return packet_generator_.ConsumeData(id, iov, offset, fin, fec_protection, - listener); + return packet_generator_.ConsumeData(id, iov, offset, fin, listener); } void QuicConnection::SendRstStream(QuicStreamId id, @@ -1263,7 +1184,7 @@ const QuicConnectionStats& QuicConnection::GetStats() { stats_.srtt_us = srtt.ToMicroseconds(); stats_.estimated_bandwidth = sent_packet_manager_.BandwidthEstimate(); - stats_.max_packet_size = packet_generator_.GetMaxPacketLength(); + stats_.max_packet_size = packet_generator_.GetCurrentMaxPacketLength(); stats_.max_received_packet_size = largest_received_packet_size_; return stats_; } @@ -1278,6 +1199,7 @@ void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, debug_visitor_->OnPacketReceived(self_address, peer_address, packet); } last_size_ = packet.length(); + current_packet_data_ = packet.data(); if (FLAGS_check_peer_address_change_after_decryption) { last_packet_destination_address_ = self_address; @@ -1309,6 +1231,7 @@ void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, } DVLOG(1) << ENDPOINT << "Unable to process packet. Last packet processed: " << last_header_.packet_number; + current_packet_data_ = nullptr; return; } @@ -1316,6 +1239,7 @@ void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, MaybeProcessUndecryptablePackets(); MaybeSendInResponseToPacket(); SetPingAlarm(); + current_packet_data_ = nullptr; } void QuicConnection::CheckForAddressMigration(const IPEndPoint& self_address, @@ -1384,7 +1308,19 @@ void QuicConnection::WriteIfNotBlocked() { } } +void QuicConnection::WriteAndBundleAcksIfNotBlocked() { + if (!writer_->IsWriteBlocked()) { + ScopedPacketBundler bundler(this, ack_queued_ ? SEND_ACK : NO_ACK); + OnCanWrite(); + } +} + bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { + if (header.fec_flag) { + // Drop any FEC packet. + return false; + } + if (FLAGS_check_peer_address_change_after_decryption) { if (perspective_ == Perspective::IS_SERVER && IsInitializedIPEndPoint(self_address_) && @@ -1459,7 +1395,7 @@ bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { if (perspective_ == Perspective::IS_SERVER && encryption_level_ == ENCRYPTION_NONE && - last_size_ > packet_generator_.GetMaxPacketLength()) { + last_size_ > packet_generator_.GetCurrentMaxPacketLength()) { SetMaxPacketLength(last_size_); } return true; @@ -1492,7 +1428,6 @@ void QuicConnection::WritePendingRetransmissions() { } // Re-packetize the frames with a new packet number for retransmission. - // Retransmitted data packets do not use FEC, even when it's enabled. // Retransmitted packets use the same packet number length as the // original. // Flush the packet generator before making a new packet. @@ -1615,13 +1550,11 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { } DCHECK_LE(encrypted_length, kMaxPacketSize); - DCHECK_LE(encrypted_length, packet_generator_.GetMaxPacketLength()); + DCHECK_LE(encrypted_length, packet_generator_.GetCurrentMaxPacketLength()); DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " - << (packet->is_fec_packet - ? "FEC " - : (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA - ? "data bearing " - : " ack only ")) + << (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA + ? "data bearing " + : " ack only ") << ", encryption level: " << QuicUtils::EncryptionLevelToString(packet->encryption_level) << ", encrypted length:" << encrypted_length; @@ -1663,7 +1596,6 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { } } SetPingAlarm(); - MaybeSetFecAlarm(packet_number); MaybeSetMtuAlarm(); DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " << packet_send_time.ToDebuggingValue(); @@ -1751,10 +1683,6 @@ void QuicConnection::OnSerializedPacket(SerializedPacket* serialized_packet) { CloseConnection(QUIC_ENCRYPTION_FAILURE, ConnectionCloseSource::FROM_SELF); return; } - if (serialized_packet->is_fec_packet && fec_alarm_->IsSet()) { - // If an FEC packet is serialized with the FEC alarm set, cancel the alarm. - fec_alarm_->Cancel(); - } SendOrQueuePacket(serialized_packet); } @@ -1765,17 +1693,7 @@ void QuicConnection::OnUnrecoverableError(QuicErrorCode error, CloseConnection(error, source); } -void QuicConnection::OnResetFecGroup() { - if (!fec_alarm_->IsSet()) { - return; - } - // If an FEC Group is closed with the FEC alarm set, cancel the alarm. - fec_alarm_->Cancel(); -} - void QuicConnection::OnCongestionWindowChange() { - packet_generator_.OnCongestionWindowChange( - sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); } @@ -1786,9 +1704,9 @@ void QuicConnection::OnRttChange() { rtt = QuicTime::Delta::FromMicroseconds( sent_packet_manager_.GetRttStats()->initial_rtt_us()); } + if (debug_visitor_) debug_visitor_->OnRttChanged(rtt); - packet_generator_.OnRttChange(rtt); } void QuicConnection::OnPathDegrading() { @@ -1853,6 +1771,7 @@ void QuicConnection::SendAck() { ack_queued_ = false; stop_waiting_count_ = 0; num_retransmittable_packets_received_since_last_ack_sent_ = 0; + last_ack_had_missing_packets_ = received_packet_manager_.HasMissingPackets(); num_packets_received_since_last_ack_sent_ = 0; packet_generator_.SetShouldSendAck(true); @@ -1969,75 +1888,6 @@ void QuicConnection::MaybeProcessUndecryptablePackets() { } } -void QuicConnection::MaybeProcessRevivedPacket() { - QuicFecGroup* group = GetFecGroup(); - if (!connected_ || group == nullptr || !group->CanRevive()) { - return; - } - QuicPacketHeader revived_header; - char revived_payload[kMaxPacketSize]; - size_t len = group->Revive(&revived_header, revived_payload, kMaxPacketSize); - if (!received_packet_manager_.IsAwaitingPacket( - revived_header.packet_number)) { - // Close this FEC group because all packets in the group has been received. - group_map_.erase(last_header_.fec_group); - delete group; - return; - } - revived_header.public_header.connection_id = connection_id_; - revived_header.public_header.connection_id_length = - last_header_.public_header.connection_id_length; - revived_header.public_header.version_flag = false; - revived_header.public_header.reset_flag = false; - revived_header.public_header.packet_number_length = - last_header_.public_header.packet_number_length; - revived_header.fec_flag = false; - revived_header.is_in_fec_group = NOT_IN_FEC_GROUP; - revived_header.fec_group = 0; - group_map_.erase(last_header_.fec_group); - last_decrypted_packet_level_ = group->EffectiveEncryptionLevel(); - DCHECK_LT(last_decrypted_packet_level_, NUM_ENCRYPTION_LEVELS); - delete group; - - last_packet_revived_ = true; - if (debug_visitor_ != nullptr) { - debug_visitor_->OnRevivedPacket(revived_header, - StringPiece(revived_payload, len)); - } - - ++stats_.packets_revived; - framer_.ProcessRevivedPacket(&revived_header, - StringPiece(revived_payload, len)); -} - -QuicFecGroup* QuicConnection::GetFecGroup() { - QuicFecGroupNumber fec_group_num = last_header_.fec_group; - if (fec_group_num == 0 || - (fec_group_num < - received_packet_manager_.peer_least_packet_awaiting_ack() && - !ContainsKey(group_map_, fec_group_num))) { - // If the group number is below peer_least_packet_awaiting_ack and this - // group does not exist, which means this group has missing packets below - // |peer_least_packet_awaiting_ack| which we would never receive, so return - // nullptr. - return nullptr; - } - if (!ContainsKey(group_map_, fec_group_num)) { - if (group_map_.size() >= kMaxFecGroups) { // Too many groups - if (fec_group_num < group_map_.begin()->first) { - // The group being requested is a group we've seen before and deleted. - // Don't recreate it. - return nullptr; - } - // Clear the lowest group number. - delete group_map_.begin()->second; - group_map_.erase(group_map_.begin()); - } - group_map_[fec_group_num] = new QuicFecGroup(fec_group_num); - } - return group_map_[fec_group_num]; -} - void QuicConnection::SendConnectionCloseWithDetails(QuicErrorCode error, const string& details) { if (!connected_) { @@ -2087,7 +1937,6 @@ void QuicConnection::CloseConnection(QuicErrorCode error, // connection is closed. ack_alarm_->Cancel(); ping_alarm_->Cancel(); - fec_alarm_->Cancel(); resume_writes_alarm_->Cancel(); retransmission_alarm_->Cancel(); send_alarm_->Cancel(); @@ -2112,31 +1961,12 @@ void QuicConnection::SendGoAway(QuicErrorCode error, QuicFrame(new QuicGoAwayFrame(error, last_good_stream_id, reason))); } -void QuicConnection::CloseFecGroupsBefore(QuicPacketNumber packet_number) { - FecGroupMap::iterator it = group_map_.begin(); - while (it != group_map_.end()) { - // If the group doesn't protect this packet we can ignore it. - if (!it->second->IsWaitingForPacketBefore(packet_number)) { - ++it; - continue; - } - QuicFecGroup* fec_group = it->second; - DCHECK(!fec_group->CanRevive()); - FecGroupMap::iterator next = it; - ++next; - group_map_.erase(it); - delete fec_group; - it = next; - } -} - QuicByteCount QuicConnection::max_packet_length() const { - return packet_generator_.GetMaxPacketLength(); + return packet_generator_.GetCurrentMaxPacketLength(); } void QuicConnection::SetMaxPacketLength(QuicByteCount length) { - return packet_generator_.SetMaxPacketLength(LimitMaxPacketSize(length), - /*force=*/false); + return packet_generator_.SetMaxPacketLength(LimitMaxPacketSize(length)); } bool QuicConnection::HasQueuedData() const { @@ -2184,14 +2014,8 @@ void QuicConnection::SetNetworkTimeouts(QuicTime::Delta handshake_timeout, void QuicConnection::CheckForTimeout() { QuicTime now = clock_->ApproximateNow(); - QuicTime time_of_last_packet = QuicTime::Zero(); - if (!FLAGS_quic_use_new_idle_timeout) { - time_of_last_packet = - max(time_of_last_received_packet_, time_of_last_sent_new_packet_); - } else { - time_of_last_packet = - max(time_of_last_received_packet_, last_send_for_timeout_); - } + QuicTime time_of_last_packet = + max(time_of_last_received_packet_, last_send_for_timeout_); // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet| // is accurate time. However, this should not change the behavior of @@ -2502,4 +2326,11 @@ bool QuicConnection::ack_frame_updated() const { return received_packet_manager_.ack_frame_updated(); } +StringPiece QuicConnection::GetCurrentPacket() { + if (current_packet_data_ == nullptr) { + return StringPiece(); + } + return StringPiece(current_packet_data_, last_size_); +} + } // namespace net |
