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

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

Issue 698703003: Delay a QUIC server's use of the FORWARD_SECURE encrypter until the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Change_QUIC_Reno_congestion_controller_78728349
Patch Set: set FLAGS_enable_quic_delay_forward_security to true Created 6 years, 1 month 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const PacketWriterFactory& writer_factory, 189 const PacketWriterFactory& writer_factory,
190 bool owns_writer, 190 bool owns_writer,
191 bool is_server, 191 bool is_server,
192 const QuicVersionVector& supported_versions) 192 const QuicVersionVector& supported_versions)
193 : framer_(supported_versions, helper->GetClock()->ApproximateNow(), 193 : framer_(supported_versions, helper->GetClock()->ApproximateNow(),
194 is_server), 194 is_server),
195 helper_(helper), 195 helper_(helper),
196 writer_(writer_factory.Create(this)), 196 writer_(writer_factory.Create(this)),
197 owns_writer_(owns_writer), 197 owns_writer_(owns_writer),
198 encryption_level_(ENCRYPTION_NONE), 198 encryption_level_(ENCRYPTION_NONE),
199 has_forward_secure_encrypter_(false),
200 first_required_forward_secure_packet_(0),
199 clock_(helper->GetClock()), 201 clock_(helper->GetClock()),
200 random_generator_(helper->GetRandomGenerator()), 202 random_generator_(helper->GetRandomGenerator()),
201 connection_id_(connection_id), 203 connection_id_(connection_id),
202 peer_address_(address), 204 peer_address_(address),
203 migrating_peer_port_(0), 205 migrating_peer_port_(0),
204 last_packet_decrypted_(false), 206 last_packet_decrypted_(false),
205 last_packet_revived_(false), 207 last_packet_revived_(false),
206 last_size_(0), 208 last_size_(0),
207 last_decrypted_packet_level_(ENCRYPTION_NONE), 209 last_decrypted_packet_level_(ENCRYPTION_NONE),
208 largest_seen_packet_with_ack_(0), 210 largest_seen_packet_with_ack_(0),
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 return true; 452 return true;
451 } 453 }
452 454
453 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { 455 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
454 return true; 456 return true;
455 } 457 }
456 458
457 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { 459 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) {
458 last_decrypted_packet_level_ = level; 460 last_decrypted_packet_level_ = level;
459 last_packet_decrypted_ = true; 461 last_packet_decrypted_ = true;
462 // If this packet was foward-secure encrypted and the forward-secure encrypter
463 // is not being used, start using it.
464 if (FLAGS_enable_quic_delay_forward_security &&
465 encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
466 has_forward_secure_encrypter_ &&
467 level == ENCRYPTION_FORWARD_SECURE) {
468 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
469 }
460 } 470 }
461 471
462 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { 472 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
463 if (debug_visitor_.get() != nullptr) { 473 if (debug_visitor_.get() != nullptr) {
464 debug_visitor_->OnPacketHeader(header); 474 debug_visitor_->OnPacketHeader(header);
465 } 475 }
466 476
467 if (!ProcessValidatedPacket()) { 477 if (!ProcessValidatedPacket()) {
468 return false; 478 return false;
469 } 479 }
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 1556
1547 void QuicConnection::OnWriteError(int error_code) { 1557 void QuicConnection::OnWriteError(int error_code) {
1548 DVLOG(1) << ENDPOINT << "Write failed with error: " << error_code 1558 DVLOG(1) << ENDPOINT << "Write failed with error: " << error_code
1549 << " (" << ErrorToString(error_code) << ")"; 1559 << " (" << ErrorToString(error_code) << ")";
1550 // We can't send an error as the socket is presumably borked. 1560 // We can't send an error as the socket is presumably borked.
1551 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); 1561 CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
1552 } 1562 }
1553 1563
1554 void QuicConnection::OnSerializedPacket( 1564 void QuicConnection::OnSerializedPacket(
1555 const SerializedPacket& serialized_packet) { 1565 const SerializedPacket& serialized_packet) {
1566 // If a forward-secure encrypter is available but is not being used and this
1567 // packet's sequence number is after the first packet which requires
1568 // forward security, start using the forward-secure encrypter.
1569 if (FLAGS_enable_quic_delay_forward_security &&
1570 encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
1571 has_forward_secure_encrypter_ &&
1572 serialized_packet.sequence_number >=
1573 first_required_forward_secure_packet_) {
1574 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
1575 }
1556 if (serialized_packet.retransmittable_frames) { 1576 if (serialized_packet.retransmittable_frames) {
1557 serialized_packet.retransmittable_frames-> 1577 serialized_packet.retransmittable_frames->
1558 set_encryption_level(encryption_level_); 1578 set_encryption_level(encryption_level_);
1559 } 1579 }
1560 SendOrQueuePacket(QueuedPacket(serialized_packet, encryption_level_)); 1580 SendOrQueuePacket(QueuedPacket(serialized_packet, encryption_level_));
1561 } 1581 }
1562 1582
1563 void QuicConnection::OnCongestionWindowChange(QuicByteCount congestion_window) { 1583 void QuicConnection::OnCongestionWindowChange(QuicByteCount congestion_window) {
1564 packet_generator_.OnCongestionWindowChange(congestion_window); 1584 packet_generator_.OnCongestionWindowChange(congestion_window);
1565 visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); 1585 visitor_->OnCongestionWindowChange(clock_->ApproximateNow());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 QuicTime rto_timeout = sent_packet_manager_.GetRetransmissionTime(); 1666 QuicTime rto_timeout = sent_packet_manager_.GetRetransmissionTime();
1647 if (rto_timeout.IsInitialized()) { 1667 if (rto_timeout.IsInitialized()) {
1648 retransmission_alarm_->Set(rto_timeout); 1668 retransmission_alarm_->Set(rto_timeout);
1649 } 1669 }
1650 } 1670 }
1651 } 1671 }
1652 1672
1653 void QuicConnection::SetEncrypter(EncryptionLevel level, 1673 void QuicConnection::SetEncrypter(EncryptionLevel level,
1654 QuicEncrypter* encrypter) { 1674 QuicEncrypter* encrypter) {
1655 framer_.SetEncrypter(level, encrypter); 1675 framer_.SetEncrypter(level, encrypter);
1676 if (FLAGS_enable_quic_delay_forward_security &&
1677 level == ENCRYPTION_FORWARD_SECURE) {
1678 has_forward_secure_encrypter_ = true;
1679 first_required_forward_secure_packet_ =
1680 sequence_number_of_last_sent_packet_ +
1681 // 3 times the current congestion window (in slow start) should cover
1682 // about two full round trips worth of packets, which should be
1683 // sufficient.
1684 3 * sent_packet_manager_.GetCongestionWindow() / max_packet_length();
1685 }
1656 } 1686 }
1657 1687
1658 const QuicEncrypter* QuicConnection::encrypter(EncryptionLevel level) const { 1688 const QuicEncrypter* QuicConnection::encrypter(EncryptionLevel level) const {
1659 return framer_.encrypter(level); 1689 return framer_.encrypter(level);
1660 } 1690 }
1661 1691
1662 void QuicConnection::SetDefaultEncryptionLevel(EncryptionLevel level) { 1692 void QuicConnection::SetDefaultEncryptionLevel(EncryptionLevel level) {
1663 encryption_level_ = level; 1693 encryption_level_ = level;
1664 packet_generator_.set_encryption_level(level); 1694 packet_generator_.set_encryption_level(level);
1665 } 1695 }
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 } 2103 }
2074 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2104 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2075 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2105 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2076 return true; 2106 return true;
2077 } 2107 }
2078 } 2108 }
2079 return false; 2109 return false;
2080 } 2110 }
2081 2111
2082 } // namespace net 2112 } // 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