summaryrefslogtreecommitdiffstats
path: root/net/quic/quic_connection_test.cc
diff options
context:
space:
mode:
authorrtenneti <rtenneti@chromium.org>2014-11-03 20:17:00 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-04 04:17:20 +0000
commit33da8ab021168895957e45ad4d1af9e991a2c665 (patch)
treec212fcc3dab23e9df9d0e0e14156ac6a31da366d /net/quic/quic_connection_test.cc
parent3e7c2a6ee80e05fc6b8090bee850c40b8a2a3810 (diff)
downloadchromium_src-33da8ab021168895957e45ad4d1af9e991a2c665.zip
chromium_src-33da8ab021168895957e45ad4d1af9e991a2c665.tar.gz
chromium_src-33da8ab021168895957e45ad4d1af9e991a2c665.tar.bz2
Land Recent QUIC Changes.
Tiny refactor of QuicSentPacketManager::NetworkChangeVisitor's OnCongestionWindowChange() method to take no arguments, and require the caller to fetch the updated congestion window. Slightly simplifies the code. In preparation for the larger GetCongestionWindowInPackets() cleanup. Merge internal change: 78883300 https://codereview.chromium.org/694383002/ Change the number of emulated connections in QUIC's congestion control as the number of open streams changes when the NCON connection option is supplied. Merge internal change: 78876869 https://codereview.chromium.org/682293004/ Merge changes to keep chromium source tree same as internal source tree. Merge internal change: 78853598 https://codereview.chromium.org/693253002/ QUIC: Only send a new SCUP if enough packets have been sent since the last SCUP. Merge internal change: 78841268 https://codereview.chromium.org/699433002/ Fixes reduction for n-connection emulation in TCP Reno. Merge internal change: 78812645 https://codereview.chromium.org/680253005/ Delay a QUIC server's use of the FORWARD_SECURE encrypter until the client has had a chance to start using it. Protected by FLAGS_enable_quic_delay_forward_security. When the forward secure encrypter is available, don't use it until one of two things happens: 1) the peers starts sending forward secure encrypted packets 2) 2 round trips worth of packets have been sent, in case something (MitM?) is preventing the peer from using forward secure encryption. Merge internal change: 78801773 Set FLAGS_enable_quic_delay_forward_security to true in chromium. https://codereview.chromium.org/698703003/ Change QUIC's Reno congestion controller to use a higher beta. Fixed tests to be independent of beta. Merge internal change: 78728349 https://codereview.chromium.org/698713002/ R=rch@chromium.org Review URL: https://codereview.chromium.org/694393002 Cr-Commit-Position: refs/heads/master@{#302571}
Diffstat (limited to 'net/quic/quic_connection_test.cc')
-rw-r--r--net/quic/quic_connection_test.cc61
1 files changed, 60 insertions, 1 deletions
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 4dbbe13..b230fd5 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -2447,6 +2447,63 @@ TEST_P(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) {
connection_.RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION);
}
+TEST_P(QuicConnectionTest, DelayForwardSecureEncryptionUntilClientIsReady) {
+ ValueRestore<bool> old_flag(&FLAGS_enable_quic_delay_forward_security, true);
+
+ // A TaggingEncrypter puts kTagSize copies of the given byte (0x02 here) at
+ // the end of the packet. We can test this to check which encrypter was used.
+ use_tagging_decrypter();
+ connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02));
+ connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Set a forward-secure encrypter but do not make it the default, and verify
+ // that it is not yet used.
+ connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
+ new TaggingEncrypter(0x03));
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Now simulate receipt of a forward-secure packet and verify that the
+ // forward-secure encrypter is now used.
+ connection_.OnDecryptedPacket(ENCRYPTION_FORWARD_SECURE);
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet());
+}
+
+TEST_P(QuicConnectionTest, DelayForwardSecureEncryptionUntilManyPacketSent) {
+ ValueRestore<bool> old_flag(&FLAGS_enable_quic_delay_forward_security, true);
+
+ // Set a congestion window of 10 packets.
+ QuicPacketCount congestion_window = 10;
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
+ Return(congestion_window * kDefaultMaxPacketSize));
+
+ // A TaggingEncrypter puts kTagSize copies of the given byte (0x02 here) at
+ // the end of the packet. We can test this to check which encrypter was used.
+ use_tagging_decrypter();
+ connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02));
+ connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Set a forward-secure encrypter but do not make it the default, and
+ // verify that it is not yet used.
+ connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
+ new TaggingEncrypter(0x03));
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Now send a packet "Far enough" after the encrypter was set and verify that
+ // the forward-secure encrypter is now used.
+ for (uint64 i = 0; i < 3 * congestion_window - 1; ++i) {
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+ SendAckPacketToPeer();
+ }
+ EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet());
+}
+
TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
// SetFromConfig is always called after construction from InitializeSession.
EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
@@ -4012,7 +4069,9 @@ TEST_P(QuicConnectionTest, NetworkChangeVisitorCallbacksChangeFecState) {
EXPECT_TRUE(visitor);
// Increase FEC group size by increasing congestion window to a large number.
- visitor->OnCongestionWindowChange(1000 * kDefaultTCPMSS);
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
+ Return(1000 * kDefaultTCPMSS));
+ visitor->OnCongestionWindowChange();
EXPECT_LT(max_packets_per_fec_group, creator->max_packets_per_fec_group());
}