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

Side by Side Diff: net/quic/quic_connection.cc

Issue 908493004: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix valgrind error Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 it != queued_packets_.end(); ++it) { 284 it != queued_packets_.end(); ++it) {
285 delete it->serialized_packet.retransmittable_frames; 285 delete it->serialized_packet.retransmittable_frames;
286 delete it->serialized_packet.packet; 286 delete it->serialized_packet.packet;
287 } 287 }
288 } 288 }
289 289
290 void QuicConnection::SetFromConfig(const QuicConfig& config) { 290 void QuicConnection::SetFromConfig(const QuicConfig& config) {
291 if (config.negotiated()) { 291 if (config.negotiated()) {
292 SetNetworkTimeouts(QuicTime::Delta::Infinite(), 292 SetNetworkTimeouts(QuicTime::Delta::Infinite(),
293 config.IdleConnectionStateLifetime()); 293 config.IdleConnectionStateLifetime());
294 if (FLAGS_quic_allow_silent_close && config.SilentClose()) { 294 if (config.SilentClose()) {
295 silent_close_enabled_ = true; 295 silent_close_enabled_ = true;
296 } 296 }
297 } else { 297 } else {
298 SetNetworkTimeouts(config.max_time_before_crypto_handshake(), 298 SetNetworkTimeouts(config.max_time_before_crypto_handshake(),
299 config.max_idle_time_before_crypto_handshake()); 299 config.max_idle_time_before_crypto_handshake());
300 } 300 }
301 301
302 sent_packet_manager_.SetFromConfig(config); 302 sent_packet_manager_.SetFromConfig(config);
303 if (config.HasReceivedBytesForConnectionId() && 303 if (config.HasReceivedBytesForConnectionId() &&
304 can_truncate_connection_ids_) { 304 can_truncate_connection_ids_) {
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 962 }
963 // This occurs if there are received packet gaps and the peer does not raise 963 // This occurs if there are received packet gaps and the peer does not raise
964 // the least unacked fast enough. 964 // the least unacked fast enough.
965 if (received_packet_manager_.NumTrackedPackets() > kMaxTrackedPackets) { 965 if (received_packet_manager_.NumTrackedPackets() > kMaxTrackedPackets) {
966 SendConnectionCloseWithDetails( 966 SendConnectionCloseWithDetails(
967 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, 967 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS,
968 StringPrintf("More than %" PRIu64 " outstanding.", kMaxTrackedPackets)); 968 StringPrintf("More than %" PRIu64 " outstanding.", kMaxTrackedPackets));
969 } 969 }
970 } 970 }
971 971
972 QuicAckFrame* QuicConnection::CreateAckFrame() { 972 void QuicConnection::PopulateAckFrame(QuicAckFrame* ack) {
973 QuicAckFrame* outgoing_ack = new QuicAckFrame(); 973 received_packet_manager_.UpdateReceivedPacketInfo(ack,
974 received_packet_manager_.UpdateReceivedPacketInfo( 974 clock_->ApproximateNow());
975 outgoing_ack, clock_->ApproximateNow());
976 DVLOG(1) << ENDPOINT << "Creating ack frame: " << *outgoing_ack;
977 return outgoing_ack;
978 } 975 }
979 976
980 QuicStopWaitingFrame* QuicConnection::CreateStopWaitingFrame() { 977 void QuicConnection::PopulateStopWaitingFrame(
981 QuicStopWaitingFrame stop_waiting; 978 QuicStopWaitingFrame* stop_waiting) {
982 UpdateStopWaiting(&stop_waiting); 979 stop_waiting->least_unacked = GetLeastUnacked();
983 return new QuicStopWaitingFrame(stop_waiting); 980 stop_waiting->entropy_hash = sent_entropy_manager_.GetCumulativeEntropy(
981 stop_waiting->least_unacked - 1);
984 } 982 }
985 983
986 bool QuicConnection::ShouldLastPacketInstigateAck() const { 984 bool QuicConnection::ShouldLastPacketInstigateAck() const {
987 if (!last_stream_frames_.empty() || 985 if (!last_stream_frames_.empty() ||
988 !last_goaway_frames_.empty() || 986 !last_goaway_frames_.empty() ||
989 !last_rst_frames_.empty() || 987 !last_rst_frames_.empty() ||
990 !last_window_update_frames_.empty() || 988 !last_window_update_frames_.empty() ||
991 !last_blocked_frames_.empty() || 989 !last_blocked_frames_.empty() ||
992 !last_ping_frames_.empty()) { 990 !last_ping_frames_.empty()) {
993 return true; 991 return true;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 } 1430 }
1433 } else { 1431 } else {
1434 encrypted_deleter.reset(encrypted); 1432 encrypted_deleter.reset(encrypted);
1435 } 1433 }
1436 1434
1437 if (!FLAGS_quic_allow_oversized_packets_for_test) { 1435 if (!FLAGS_quic_allow_oversized_packets_for_test) {
1438 DCHECK_LE(encrypted->length(), kMaxPacketSize); 1436 DCHECK_LE(encrypted->length(), kMaxPacketSize);
1439 } 1437 }
1440 DCHECK_LE(encrypted->length(), packet_generator_.max_packet_length()); 1438 DCHECK_LE(encrypted->length(), packet_generator_.max_packet_length());
1441 DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number << " : " 1439 DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number << " : "
1442 << (packet->serialized_packet.packet->is_fec_packet() ? "FEC " : 1440 << (packet->serialized_packet.is_fec_packet
1443 (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA 1441 ? "FEC "
1444 ? "data bearing " : " ack only ")) 1442 : (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA
1445 << ", encryption level: " 1443 ? "data bearing "
1444 : " ack only ")) << ", encryption level: "
1446 << QuicUtils::EncryptionLevelToString(packet->encryption_level) 1445 << QuicUtils::EncryptionLevelToString(packet->encryption_level)
1447 << ", length:" 1446 << ", length:" << packet->serialized_packet.packet->length()
1448 << packet->serialized_packet.packet->length() 1447 << ", encrypted length:" << encrypted->length();
1449 << ", encrypted length:"
1450 << encrypted->length();
1451 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl 1448 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl
1452 << QuicUtils::StringToHexASCIIDump( 1449 << QuicUtils::StringToHexASCIIDump(
1453 packet->serialized_packet.packet->AsStringPiece()); 1450 packet->serialized_packet.packet->AsStringPiece());
1454 1451
1455 QuicTime packet_send_time = QuicTime::Zero(); 1452 QuicTime packet_send_time = QuicTime::Zero();
1456 if (FLAGS_quic_record_send_time_before_write) { 1453 if (FLAGS_quic_record_send_time_before_write) {
1457 // Measure the RTT from before the write begins to avoid underestimating the 1454 // Measure the RTT from before the write begins to avoid underestimating the
1458 // min_rtt_, especially in cases where the thread blocks or gets swapped out 1455 // min_rtt_, especially in cases where the thread blocks or gets swapped out
1459 // during the WritePacket below. 1456 // during the WritePacket below.
1460 packet_send_time = clock_->Now(); 1457 packet_send_time = clock_->Now();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 1594 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
1598 } 1595 }
1599 if (serialized_packet.retransmittable_frames) { 1596 if (serialized_packet.retransmittable_frames) {
1600 serialized_packet.retransmittable_frames-> 1597 serialized_packet.retransmittable_frames->
1601 set_encryption_level(encryption_level_); 1598 set_encryption_level(encryption_level_);
1602 1599
1603 if (FLAGS_quic_ack_notifier_informed_on_serialized) { 1600 if (FLAGS_quic_ack_notifier_informed_on_serialized) {
1604 sent_packet_manager_.OnSerializedPacket(serialized_packet); 1601 sent_packet_manager_.OnSerializedPacket(serialized_packet);
1605 } 1602 }
1606 } 1603 }
1607 if (serialized_packet.packet->is_fec_packet() && fec_alarm_->IsSet()) { 1604 if (serialized_packet.is_fec_packet && fec_alarm_->IsSet()) {
1608 // If an FEC packet is serialized with the FEC alarm set, cancel the alarm. 1605 // If an FEC packet is serialized with the FEC alarm set, cancel the alarm.
1609 fec_alarm_->Cancel(); 1606 fec_alarm_->Cancel();
1610 } 1607 }
1611 SendOrQueuePacket(QueuedPacket(serialized_packet, encryption_level_)); 1608 SendOrQueuePacket(QueuedPacket(serialized_packet, encryption_level_));
1612 } 1609 }
1613 1610
1614 void QuicConnection::OnCongestionWindowChange() { 1611 void QuicConnection::OnCongestionWindowChange() {
1615 packet_generator_.OnCongestionWindowChange( 1612 packet_generator_.OnCongestionWindowChange(
1616 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); 1613 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length()));
1617 visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); 1614 visitor_->OnCongestionWindowChange(clock_->ApproximateNow());
(...skipping 28 matching lines...) Expand all
1646 } 1643 }
1647 1644
1648 sent_entropy_manager_.RecordPacketEntropyHash( 1645 sent_entropy_manager_.RecordPacketEntropyHash(
1649 packet.serialized_packet.sequence_number, 1646 packet.serialized_packet.sequence_number,
1650 packet.serialized_packet.entropy_hash); 1647 packet.serialized_packet.entropy_hash);
1651 if (!WritePacket(&packet)) { 1648 if (!WritePacket(&packet)) {
1652 queued_packets_.push_back(packet); 1649 queued_packets_.push_back(packet);
1653 } 1650 }
1654 } 1651 }
1655 1652
1656 void QuicConnection::UpdateStopWaiting(QuicStopWaitingFrame* stop_waiting) {
1657 stop_waiting->least_unacked = GetLeastUnacked();
1658 stop_waiting->entropy_hash = sent_entropy_manager_.GetCumulativeEntropy(
1659 stop_waiting->least_unacked - 1);
1660 }
1661
1662 void QuicConnection::SendPing() { 1653 void QuicConnection::SendPing() {
1663 if (retransmission_alarm_->IsSet()) { 1654 if (retransmission_alarm_->IsSet()) {
1664 return; 1655 return;
1665 } 1656 }
1666 packet_generator_.AddControlFrame(QuicFrame(new QuicPingFrame)); 1657 packet_generator_.AddControlFrame(QuicFrame(new QuicPingFrame));
1667 } 1658 }
1668 1659
1669 void QuicConnection::SendAck() { 1660 void QuicConnection::SendAck() {
1670 ack_alarm_->Cancel(); 1661 ack_alarm_->Cancel();
1671 stop_waiting_count_ = 0; 1662 stop_waiting_count_ = 0;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 } 2101 }
2111 for (const QuicFrame& frame : retransmittable_frames->frames()) { 2102 for (const QuicFrame& frame : retransmittable_frames->frames()) {
2112 if (frame.type == CONNECTION_CLOSE_FRAME) { 2103 if (frame.type == CONNECTION_CLOSE_FRAME) {
2113 return true; 2104 return true;
2114 } 2105 }
2115 } 2106 }
2116 return false; 2107 return false;
2117 } 2108 }
2118 2109
2119 } // namespace net 2110 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698