| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_connection.h" | 5 #include "net/quic/quic_connection.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 debug_visitor_->OnUnauthenticatedHeader(header); | 616 debug_visitor_->OnUnauthenticatedHeader(header); |
| 617 } | 617 } |
| 618 | 618 |
| 619 // Check that any public reset packet with a different connection ID that was | 619 // Check that any public reset packet with a different connection ID that was |
| 620 // routed to this QuicConnection has been redirected before control reaches | 620 // routed to this QuicConnection has been redirected before control reaches |
| 621 // here. | 621 // here. |
| 622 DCHECK_EQ(connection_id_, header.public_header.connection_id); | 622 DCHECK_EQ(connection_id_, header.public_header.connection_id); |
| 623 | 623 |
| 624 // If this packet has already been seen, or the sender has told us that it | 624 // If this packet has already been seen, or the sender has told us that it |
| 625 // will not be retransmitted, then stop processing the packet. | 625 // will not be retransmitted, then stop processing the packet. |
| 626 if (!received_packet_manager_.IsAwaitingPacket(header.packet_number)) { | 626 if (FLAGS_quic_drop_non_awaited_packets && |
| 627 !received_packet_manager_.IsAwaitingPacket(header.packet_number)) { |
| 627 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number | 628 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number |
| 628 << " no longer being waited for. Discarding."; | 629 << " no longer being waited for. Discarding."; |
| 629 if (debug_visitor_ != nullptr) { | 630 if (debug_visitor_ != nullptr) { |
| 630 debug_visitor_->OnDuplicatePacket(header.packet_number); | 631 debug_visitor_->OnDuplicatePacket(header.packet_number); |
| 631 } | 632 } |
| 632 ++stats_.packets_dropped; | 633 ++stats_.packets_dropped; |
| 633 return false; | 634 return false; |
| 634 } | 635 } |
| 635 | 636 |
| 636 return true; | 637 return true; |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 StringPiece(revived_payload, len)); | 1977 StringPiece(revived_payload, len)); |
| 1977 } | 1978 } |
| 1978 | 1979 |
| 1979 ++stats_.packets_revived; | 1980 ++stats_.packets_revived; |
| 1980 framer_.ProcessRevivedPacket(&revived_header, | 1981 framer_.ProcessRevivedPacket(&revived_header, |
| 1981 StringPiece(revived_payload, len)); | 1982 StringPiece(revived_payload, len)); |
| 1982 } | 1983 } |
| 1983 | 1984 |
| 1984 QuicFecGroup* QuicConnection::GetFecGroup() { | 1985 QuicFecGroup* QuicConnection::GetFecGroup() { |
| 1985 QuicFecGroupNumber fec_group_num = last_header_.fec_group; | 1986 QuicFecGroupNumber fec_group_num = last_header_.fec_group; |
| 1986 if (fec_group_num == 0) { | 1987 if (fec_group_num == 0 || |
| 1988 (FLAGS_quic_drop_non_awaited_packets && |
| 1989 fec_group_num < |
| 1990 received_packet_manager_.peer_least_packet_awaiting_ack() && |
| 1991 !ContainsKey(group_map_, fec_group_num))) { |
| 1992 // If the group number is below peer_least_packet_awaiting_ack and this |
| 1993 // group does not exist, which means this group has missing packets below |
| 1994 // |peer_least_packet_awaiting_ack| which we would never receive, so return |
| 1995 // nullptr. |
| 1987 return nullptr; | 1996 return nullptr; |
| 1988 } | 1997 } |
| 1989 if (!ContainsKey(group_map_, fec_group_num)) { | 1998 if (!ContainsKey(group_map_, fec_group_num)) { |
| 1990 if (group_map_.size() >= kMaxFecGroups) { // Too many groups | 1999 if (group_map_.size() >= kMaxFecGroups) { // Too many groups |
| 1991 if (fec_group_num < group_map_.begin()->first) { | 2000 if (fec_group_num < group_map_.begin()->first) { |
| 1992 // The group being requested is a group we've seen before and deleted. | 2001 // The group being requested is a group we've seen before and deleted. |
| 1993 // Don't recreate it. | 2002 // Don't recreate it. |
| 1994 return nullptr; | 2003 return nullptr; |
| 1995 } | 2004 } |
| 1996 // Clear the lowest group number. | 2005 // Clear the lowest group number. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 | 2080 |
| 2072 // Opportunistically bundle an ack with this outgoing packet. | 2081 // Opportunistically bundle an ack with this outgoing packet. |
| 2073 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); | 2082 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); |
| 2074 packet_generator_.AddControlFrame( | 2083 packet_generator_.AddControlFrame( |
| 2075 QuicFrame(new QuicGoAwayFrame(error, last_good_stream_id, reason))); | 2084 QuicFrame(new QuicGoAwayFrame(error, last_good_stream_id, reason))); |
| 2076 } | 2085 } |
| 2077 | 2086 |
| 2078 void QuicConnection::CloseFecGroupsBefore(QuicPacketNumber packet_number) { | 2087 void QuicConnection::CloseFecGroupsBefore(QuicPacketNumber packet_number) { |
| 2079 FecGroupMap::iterator it = group_map_.begin(); | 2088 FecGroupMap::iterator it = group_map_.begin(); |
| 2080 while (it != group_map_.end()) { | 2089 while (it != group_map_.end()) { |
| 2081 // If this is the current group or the group doesn't protect this packet | 2090 // If the group doesn't protect this packet we can ignore it. |
| 2082 // we can ignore it. | 2091 if ((!FLAGS_quic_drop_non_awaited_packets && |
| 2083 if (last_header_.fec_group == it->first || | 2092 last_header_.fec_group == it->first) || |
| 2084 !it->second->IsWaitingForPacketBefore(packet_number)) { | 2093 !it->second->IsWaitingForPacketBefore(packet_number)) { |
| 2085 ++it; | 2094 ++it; |
| 2086 continue; | 2095 continue; |
| 2087 } | 2096 } |
| 2088 QuicFecGroup* fec_group = it->second; | 2097 QuicFecGroup* fec_group = it->second; |
| 2089 DCHECK(!fec_group->CanRevive()); | 2098 DCHECK(!fec_group->CanRevive()); |
| 2090 FecGroupMap::iterator next = it; | 2099 FecGroupMap::iterator next = it; |
| 2091 ++next; | 2100 ++next; |
| 2092 group_map_.erase(it); | 2101 group_map_.erase(it); |
| 2093 delete fec_group; | 2102 delete fec_group; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 SendMtuDiscoveryPacket(mtu_discovery_target_); | 2413 SendMtuDiscoveryPacket(mtu_discovery_target_); |
| 2405 | 2414 |
| 2406 DCHECK(!mtu_discovery_alarm_->IsSet()); | 2415 DCHECK(!mtu_discovery_alarm_->IsSet()); |
| 2407 } | 2416 } |
| 2408 | 2417 |
| 2409 bool QuicConnection::ack_frame_updated() const { | 2418 bool QuicConnection::ack_frame_updated() const { |
| 2410 return received_packet_manager_.ack_frame_updated(); | 2419 return received_packet_manager_.ack_frame_updated(); |
| 2411 } | 2420 } |
| 2412 | 2421 |
| 2413 } // namespace net | 2422 } // namespace net |
| OLD | NEW |