summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 19:39:43 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 19:39:43 +0000
commit3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2 (patch)
tree034a554e79e1d254e4c15c20ad0d9347c8e7c9e3
parent697b287ede25a3263473acc870a532ca863163bf (diff)
downloadchromium_src-3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2.zip
chromium_src-3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2.tar.gz
chromium_src-3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2.tar.bz2
Land Recent QUIC Changes.
Allow running the test server in secure mode. Merge internal change: 62164374 https://codereview.chromium.org/181413007/ Implement special behaviors (closing and timing out) in the test server. Testing only. Merge internal change: 62158630 https://codereview.chromium.org/177293008/ Moving a preexisting DCHECK to a new and more helpful dfatal. Merge internal change: 62089588 https://codereview.chromium.org/181463007/ PACKET_NBYTE_GUID -> PACKET_NBYTE_CONNECTION_ID GUID->ConnectionId QuicGuid->QuicConnectionId guid->connection_id except for the dos proto, which I'm leaving alone for now. renaming quic guid to connection id. no functional change. Merge internal change: 62087636 https://codereview.chromium.org/181483006/ QUIC-local change to extend per-connection stats. Extending QuicConnectionStats to add two Cubic-related stats. Merge internal change: 61977906 https://codereview.chromium.org/177843017/ Implement an early retransmit timer in QUIC's TcpLossAlgorithm to replace immediate loss and retransmission. Merge internal change: 61976680 https://codereview.chromium.org/182083002/ Add a time based loss detection algorithm to QUIC that loses packets after 1.25RTTs and at least one nack. Merge internal change: 61975778 https://codereview.chromium.org/182063002/ QUIC test cleanup to always use MockLossAlgorithm in QuicConnectionTest. Merge internal change: 61972606 https://codereview.chromium.org/180783003/ Minor optimizations to QuicUnackedPacketMap and QuicSentPacketManager to improve load testing. Merge internal change: 61961987 https://codereview.chromium.org/181433007/ Cleanup: Rename http_message_test_utils.{h,cc,_test.cc} to http_message.{h,cc,_test.cc} This is how it should be named (defines/tests class HTTPMessage), and it's confusingly similar to the unrelated http_message_utils.h n/a (test only) Merge internal change: 61955207 https://codereview.chromium.org/181703005/ Test-only change to QuicConnectionTest to use MockLossAlgorithm instead of specific details of the TCP loss detection algorithm. Merge internal change: 61953382 https://codereview.chromium.org/181693005/ Add mock methods for SendBlocked and SendWindowUpdate in QuicConnection (test only) Merge internal change: 61945606 https://codereview.chromium.org/181973002/ Add SendWindowUpdate and SendBlocked methods to QuicConnection. Not used yet. Merge internal change: 61915742 https://codereview.chromium.org/181413005/ Start using the loss timeout in QuicSentPacketManager and add a mock implementation of the LossDetectionInterface for testing. Merge internal change: 61903890 https://codereview.chromium.org/181723003/ R=rch@chromium.org Review URL: https://codereview.chromium.org/182523002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253899 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/net.gyp7
-rw-r--r--net/quic/congestion_control/cubic.cc40
-rw-r--r--net/quic/congestion_control/cubic.h9
-rw-r--r--net/quic/congestion_control/cubic_test.cc59
-rw-r--r--net/quic/congestion_control/fix_rate_sender.h1
-rw-r--r--net/quic/congestion_control/loss_detection_interface.h7
-rw-r--r--net/quic/congestion_control/send_algorithm_interface.cc6
-rw-r--r--net/quic/congestion_control/send_algorithm_interface.h4
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender.cc5
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender.h4
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender_test.cc4
-rw-r--r--net/quic/congestion_control/tcp_loss_algorithm.cc50
-rw-r--r--net/quic/congestion_control/tcp_loss_algorithm.h9
-rw-r--r--net/quic/congestion_control/tcp_loss_algorithm_test.cc27
-rw-r--r--net/quic/congestion_control/time_loss_algorithm.cc64
-rw-r--r--net/quic/congestion_control/time_loss_algorithm.h49
-rw-r--r--net/quic/congestion_control/time_loss_algorithm_test.cc136
-rw-r--r--net/quic/crypto/crypto_handshake.h8
-rw-r--r--net/quic/crypto/crypto_server_test.cc2
-rw-r--r--net/quic/crypto/quic_crypto_client_config.cc11
-rw-r--r--net/quic/crypto/quic_crypto_client_config.h4
-rw-r--r--net/quic/crypto/quic_crypto_server_config.cc10
-rw-r--r--net/quic/crypto/quic_crypto_server_config.h5
-rw-r--r--net/quic/quic_client_session.cc2
-rw-r--r--net/quic/quic_connection.cc48
-rw-r--r--net/quic/quic_connection.h17
-rw-r--r--net/quic/quic_connection_logger.cc4
-rw-r--r--net/quic/quic_connection_stats.cc9
-rw-r--r--net/quic/quic_connection_stats.h9
-rw-r--r--net/quic/quic_connection_test.cc212
-rw-r--r--net/quic/quic_crypto_client_stream.cc4
-rw-r--r--net/quic/quic_crypto_server_stream.cc2
-rw-r--r--net/quic/quic_data_stream_test.cc2
-rw-r--r--net/quic/quic_framer.cc126
-rw-r--r--net/quic/quic_framer.h4
-rw-r--r--net/quic/quic_framer_test.cc621
-rw-r--r--net/quic/quic_http_stream_test.cc17
-rw-r--r--net/quic/quic_packet_creator.cc16
-rw-r--r--net/quic/quic_packet_creator.h12
-rw-r--r--net/quic/quic_packet_creator_test.cc12
-rw-r--r--net/quic/quic_packet_generator_test.cc2
-rw-r--r--net/quic/quic_protocol.cc47
-rw-r--r--net/quic/quic_protocol.h47
-rw-r--r--net/quic/quic_reliable_client_stream_test.cc2
-rw-r--r--net/quic/quic_sent_packet_manager.cc33
-rw-r--r--net/quic/quic_sent_packet_manager.h8
-rw-r--r--net/quic/quic_sent_packet_manager_test.cc36
-rw-r--r--net/quic/quic_session.h4
-rw-r--r--net/quic/quic_session_test.cc4
-rw-r--r--net/quic/quic_stream_factory.cc5
-rw-r--r--net/quic/quic_unacked_packet_map.cc15
-rw-r--r--net/quic/reliable_quic_stream_test.cc6
-rw-r--r--net/quic/test_tools/quic_framer_peer.cc5
-rw-r--r--net/quic/test_tools/quic_framer_peer.h3
-rw-r--r--net/quic/test_tools/quic_sent_packet_manager_peer.cc8
-rw-r--r--net/quic/test_tools/quic_sent_packet_manager_peer.h3
-rw-r--r--net/quic/test_tools/quic_test_packet_maker.cc15
-rw-r--r--net/quic/test_tools/quic_test_packet_maker.h4
-rw-r--r--net/quic/test_tools/quic_test_utils.cc32
-rw-r--r--net/quic/test_tools/quic_test_utils.h28
-rw-r--r--net/tools/quic/end_to_end_test.cc2
-rw-r--r--net/tools/quic/quic_client.cc4
-rw-r--r--net/tools/quic/quic_client.h2
-rw-r--r--net/tools/quic/quic_dispatcher.cc58
-rw-r--r--net/tools/quic/quic_dispatcher.h13
-rw-r--r--net/tools/quic/quic_dispatcher_test.cc61
-rw-r--r--net/tools/quic/quic_in_memory_cache.cc12
-rw-r--r--net/tools/quic/quic_in_memory_cache.h16
-rw-r--r--net/tools/quic/quic_server.h6
-rw-r--r--net/tools/quic/quic_server_session.cc2
-rw-r--r--net/tools/quic/quic_server_session.h3
-rw-r--r--net/tools/quic/quic_server_test.cc4
-rw-r--r--net/tools/quic/quic_spdy_server_stream.cc11
-rw-r--r--net/tools/quic/quic_time_wait_list_manager.cc117
-rw-r--r--net/tools/quic/quic_time_wait_list_manager.h119
-rw-r--r--net/tools/quic/quic_time_wait_list_manager_test.cc222
-rw-r--r--net/tools/quic/test_tools/http_message.cc (renamed from net/tools/quic/test_tools/http_message_test_utils.cc)4
-rw-r--r--net/tools/quic/test_tools/http_message.h (renamed from net/tools/quic/test_tools/http_message_test_utils.h)8
-rw-r--r--net/tools/quic/test_tools/quic_test_client.cc21
-rw-r--r--net/tools/quic/test_tools/quic_test_client.h6
-rw-r--r--net/tools/quic/test_tools/quic_test_utils.cc10
-rw-r--r--net/tools/quic/test_tools/quic_test_utils.h16
82 files changed, 1695 insertions, 967 deletions
diff --git a/net/net.gyp b/net/net.gyp
index 9067910..6442ab0 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -793,6 +793,8 @@
'quic/congestion_control/tcp_loss_algorithm.h',
'quic/congestion_control/tcp_receiver.cc',
'quic/congestion_control/tcp_receiver.h',
+ 'quic/congestion_control/time_loss_algorithm.cc',
+ 'quic/congestion_control/time_loss_algorithm.h',
'quic/crypto/aes_128_gcm_12_decrypter.h',
'quic/crypto/aes_128_gcm_12_decrypter_nss.cc',
'quic/crypto/aes_128_gcm_12_decrypter_openssl.cc',
@@ -1870,6 +1872,7 @@
'quic/congestion_control/tcp_cubic_sender_test.cc',
'quic/congestion_control/tcp_loss_algorithm_test.cc',
'quic/congestion_control/tcp_receiver_test.cc',
+ 'quic/congestion_control/time_loss_algorithm_test.cc',
'quic/crypto/aes_128_gcm_12_decrypter_test.cc',
'quic/crypto/aes_128_gcm_12_encrypter_test.cc',
'quic/crypto/cert_compressor_test.cc',
@@ -2125,8 +2128,8 @@
'tools/quic/quic_spdy_client_stream_test.cc',
'tools/quic/quic_spdy_server_stream_test.cc',
'tools/quic/quic_time_wait_list_manager_test.cc',
- 'tools/quic/test_tools/http_message_test_utils.cc',
- 'tools/quic/test_tools/http_message_test_utils.h',
+ 'tools/quic/test_tools/http_message.cc',
+ 'tools/quic/test_tools/http_message.h',
'tools/quic/test_tools/mock_epoll_server.cc',
'tools/quic/test_tools/mock_epoll_server.h',
'tools/quic/test_tools/mock_quic_dispatcher.cc',
diff --git a/net/quic/congestion_control/cubic.cc b/net/quic/congestion_control/cubic.cc
index bb21e3c..301512c 100644
--- a/net/quic/congestion_control/cubic.cc
+++ b/net/quic/congestion_control/cubic.cc
@@ -17,6 +17,7 @@ using std::max;
namespace net {
namespace {
+
// Constants based on TCP defaults.
// The following constants are in 2^10 fractions of a second instead of ms to
// allow a 10 shift right to divide.
@@ -46,12 +47,14 @@ const float kNConnectionAlpha = 3 * kNumConnections * kNumConnections *
(1 - kNConnectionBeta) / (1 + kNConnectionBeta);
// TODO(jri): Compute kNConnectionBeta and kNConnectionAlpha from
// number of active streams.
+
} // namespace
-Cubic::Cubic(const QuicClock* clock)
+Cubic::Cubic(const QuicClock* clock, QuicConnectionStats* stats)
: clock_(clock),
epoch_(QuicTime::Zero()),
- last_update_time_(QuicTime::Zero()) {
+ last_update_time_(QuicTime::Zero()),
+ stats_(stats) {
Reset();
}
@@ -67,6 +70,26 @@ void Cubic::Reset() {
last_target_congestion_window_ = 0;
}
+void Cubic::UpdateCongestionControlStats(
+ QuicTcpCongestionWindow new_cubic_mode_cwnd,
+ QuicTcpCongestionWindow new_reno_mode_cwnd) {
+ if (last_congestion_window_ < new_cubic_mode_cwnd) {
+ // Congestion window will increase in cubic mode.
+ stats_->cwnd_increase_cubic_mode += new_cubic_mode_cwnd -
+ last_congestion_window_;
+ if (new_cubic_mode_cwnd <= new_reno_mode_cwnd) {
+ // Congestion window increase in reno mode is higher or equal to cubic
+ // mode's increase.
+ stats_->cwnd_increase_reno_mode += new_reno_mode_cwnd -
+ last_congestion_window_;
+ }
+ } else if (last_congestion_window_ < new_reno_mode_cwnd) {
+ // No cwnd increase in cubic mode, but cwnd will increase in reno mode.
+ stats_->cwnd_increase_reno_mode += new_reno_mode_cwnd -
+ last_congestion_window_;
+ }
+}
+
QuicTcpCongestionWindow Cubic::CongestionWindowAfterPacketLoss(
QuicTcpCongestionWindow current_congestion_window) {
if (current_congestion_window < last_max_congestion_window_) {
@@ -127,9 +150,6 @@ QuicTcpCongestionWindow Cubic::CongestionWindowAfterAck(
QuicTcpCongestionWindow target_congestion_window =
origin_point_congestion_window_ - delta_congestion_window;
- // We have a new cubic congestion window.
- last_target_congestion_window_ = target_congestion_window;
-
DCHECK_LT(0u, estimated_tcp_congestion_window_);
// With dynamic beta/alpha based on number of active streams, it is possible
// for the required_ack_count to become much lower than acked_packets_count_
@@ -145,12 +165,20 @@ QuicTcpCongestionWindow Cubic::CongestionWindowAfterAck(
estimated_tcp_congestion_window_++;
}
+ // Update cubic mode and reno mode stats in QuicConnectionStats.
+ UpdateCongestionControlStats(target_congestion_window,
+ estimated_tcp_congestion_window_);
+
+ // We have a new cubic congestion window.
+ last_target_congestion_window_ = target_congestion_window;
+
// Compute target congestion_window based on cubic target and estimated TCP
// congestion_window, use highest (fastest).
if (target_congestion_window < estimated_tcp_congestion_window_) {
target_congestion_window = estimated_tcp_congestion_window_;
}
- DVLOG(1) << "Target congestion_window:" << target_congestion_window;
+
+ DVLOG(1) << "Target congestion_window: " << target_congestion_window;
return target_congestion_window;
}
diff --git a/net/quic/congestion_control/cubic.h b/net/quic/congestion_control/cubic.h
index a701596..da41ddf 100644
--- a/net/quic/congestion_control/cubic.h
+++ b/net/quic/congestion_control/cubic.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "net/base/net_export.h"
#include "net/quic/quic_clock.h"
+#include "net/quic/quic_connection_stats.h"
#include "net/quic/quic_time.h"
namespace net {
@@ -20,7 +21,7 @@ typedef uint32 QuicTcpCongestionWindow;
class NET_EXPORT_PRIVATE Cubic {
public:
- explicit Cubic(const QuicClock* clock);
+ Cubic(const QuicClock* clock, QuicConnectionStats* stats);
// Call after a timeout to reset the cubic state.
void Reset();
@@ -44,6 +45,9 @@ class NET_EXPORT_PRIVATE Cubic {
return QuicTime::Delta::FromMilliseconds(30);
}
+ // Update congestion control variables in QuicConnectionStats.
+ void UpdateCongestionControlStats(QuicTcpCongestionWindow new_cubic_mode_cwnd,
+ QuicTcpCongestionWindow new_reno_mode_cwnd);
const QuicClock* clock_;
// Time when this cycle started, after last loss event.
@@ -75,6 +79,9 @@ class NET_EXPORT_PRIVATE Cubic {
// Last congestion window in packets computed by cubic function.
QuicTcpCongestionWindow last_target_congestion_window_;
+ // QuicConnectionStats includes congestion control related stats.
+ QuicConnectionStats* stats_;
+
DISALLOW_COPY_AND_ASSIGN(Cubic);
};
diff --git a/net/quic/congestion_control/cubic_test.cc b/net/quic/congestion_control/cubic_test.cc
index bb5e93d..7844c26 100644
--- a/net/quic/congestion_control/cubic_test.cc
+++ b/net/quic/congestion_control/cubic_test.cc
@@ -5,6 +5,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "net/quic/congestion_control/cubic.h"
+#include "net/quic/quic_connection_stats.h"
#include "net/quic/test_tools/mock_clock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,11 +23,12 @@ class CubicTest : public ::testing::Test {
CubicTest()
: one_ms_(QuicTime::Delta::FromMilliseconds(1)),
hundred_ms_(QuicTime::Delta::FromMilliseconds(100)),
- cubic_(&clock_) {
+ cubic_(&clock_, &stats_) {
}
const QuicTime::Delta one_ms_;
const QuicTime::Delta hundred_ms_;
MockClock clock_;
+ QuicConnectionStats stats_;
Cubic cubic_;
};
@@ -53,7 +55,7 @@ TEST_F(CubicTest, AboveOrigin) {
expected_cwnd++;
}
// Cubic phase.
- for (int j = 48; j < 100; ++j) {
+ for (int i = 0; i < 52; ++i) {
for (uint32 n = 1; n < current_cwnd; ++n) {
// Call once per ACK.
EXPECT_EQ(current_cwnd,
@@ -62,12 +64,58 @@ TEST_F(CubicTest, AboveOrigin) {
clock_.AdvanceTime(hundred_ms_);
current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
}
- float elapsed_time_s = 10.0f + 0.1f; // We need to add the RTT here.
+ // Total time elapsed so far; add min_rtt (0.1s) here as well.
+ float elapsed_time_s = 10.0f + 0.1f;
+ // expected_cwnd is initial value of cwnd + K * t^3, where K = 0.4.
expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410)
/ 1024;
EXPECT_EQ(expected_cwnd, current_cwnd);
}
+TEST_F(CubicTest, CwndIncreaseStatsDuringConvexRegion) {
+ const QuicTime::Delta rtt_min = hundred_ms_;
+ uint32 current_cwnd = 10;
+ uint32 expected_cwnd = current_cwnd + 1;
+ // Initialize controller state.
+ clock_.AdvanceTime(one_ms_);
+ expected_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
+ current_cwnd = expected_cwnd;
+ // Testing Reno mode increase.
+ for (int i = 0; i < 48; ++i) {
+ for (uint32 n = 1; n < current_cwnd / kNConnectionAlpha; ++n) {
+ // Call once per ACK, causing cwnd growth in Reno mode.
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
+ }
+ // Advance current time so that cwnd update is allowed to happen by Cubic.
+ clock_.AdvanceTime(hundred_ms_);
+ current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
+ EXPECT_NEAR(expected_cwnd - 10, stats_.cwnd_increase_reno_mode, 1);
+ EXPECT_NEAR(1u, stats_.cwnd_increase_cubic_mode, 1);
+ expected_cwnd++;
+ }
+ uint32 old_cwnd = current_cwnd;
+ stats_.cwnd_increase_cubic_mode = 0;
+ stats_.cwnd_increase_reno_mode = 0;
+
+ // Testing Cubic mode increase.
+ for (int i = 0; i < 52; ++i) {
+ for (uint32 n = 1; n < current_cwnd; ++n) {
+ // Call once per ACK.
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
+ }
+ clock_.AdvanceTime(hundred_ms_);
+ current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
+ }
+ // Total time elapsed so far; add min_rtt (0.1s) here as well.
+ float elapsed_time_s = 10.0f + 0.1f;
+ // expected_cwnd is initial value of cwnd + K * t^3, where K = 0.4.
+ expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410)
+ / 1024;
+ EXPECT_EQ(expected_cwnd - old_cwnd, stats_.cwnd_increase_cubic_mode);
+ EXPECT_EQ(0u, stats_.cwnd_increase_reno_mode);
+}
+
+
TEST_F(CubicTest, LossEvents) {
const QuicTime::Delta rtt_min = hundred_ms_;
uint32 current_cwnd = 422;
@@ -99,13 +147,18 @@ TEST_F(CubicTest, BelowOrigin) {
current_cwnd = expected_cwnd;
// First update after loss to initialize the epoch.
current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
+ uint32 old_cwnd = current_cwnd;
// Cubic phase.
+ stats_.cwnd_increase_cubic_mode = 0;
+ stats_.cwnd_increase_reno_mode = 0;
for (int i = 0; i < 40 ; ++i) {
clock_.AdvanceTime(hundred_ms_);
current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
}
expected_cwnd = 422;
EXPECT_EQ(expected_cwnd, current_cwnd);
+ EXPECT_EQ(expected_cwnd - old_cwnd, stats_.cwnd_increase_cubic_mode);
+ EXPECT_EQ(0u, stats_.cwnd_increase_reno_mode);
}
} // namespace test
diff --git a/net/quic/congestion_control/fix_rate_sender.h b/net/quic/congestion_control/fix_rate_sender.h
index 8c5a172..a3c1bde 100644
--- a/net/quic/congestion_control/fix_rate_sender.h
+++ b/net/quic/congestion_control/fix_rate_sender.h
@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "net/base/net_export.h"
#include "net/quic/quic_clock.h"
+#include "net/quic/quic_connection_stats.h"
#include "net/quic/quic_time.h"
#include "net/quic/congestion_control/leaky_bucket.h"
#include "net/quic/congestion_control/paced_sender.h"
diff --git a/net/quic/congestion_control/loss_detection_interface.h b/net/quic/congestion_control/loss_detection_interface.h
index 65240a2..bb1f86d 100644
--- a/net/quic/congestion_control/loss_detection_interface.h
+++ b/net/quic/congestion_control/loss_detection_interface.h
@@ -27,7 +27,12 @@ class NET_EXPORT_PRIVATE LossDetectionInterface {
const QuicUnackedPacketMap& unacked_packets,
const QuicTime& time,
QuicPacketSequenceNumber largest_observed,
- QuicTime::Delta srtt) = 0;
+ QuicTime::Delta srtt,
+ QuicTime::Delta latest_rtt) = 0;
+
+ // Get the time the LossDetectionAlgorithm wants to re-evaluate losses.
+ // Returns QuicTime::Zero if no alarm needs to be set.
+ virtual QuicTime GetLossTimeout() const = 0;
};
} // namespace net
diff --git a/net/quic/congestion_control/send_algorithm_interface.cc b/net/quic/congestion_control/send_algorithm_interface.cc
index e3452c4..c884c02 100644
--- a/net/quic/congestion_control/send_algorithm_interface.cc
+++ b/net/quic/congestion_control/send_algorithm_interface.cc
@@ -16,10 +16,12 @@ const bool kUseReno = false;
// Factory for send side congestion control algorithm.
SendAlgorithmInterface* SendAlgorithmInterface::Create(
const QuicClock* clock,
- CongestionFeedbackType type) {
+ CongestionFeedbackType type,
+ QuicConnectionStats* stats) {
switch (type) {
case kTCP:
- return new TcpCubicSender(clock, kUseReno, kMaxTcpCongestionWindow);
+ return new TcpCubicSender(clock, kUseReno, kMaxTcpCongestionWindow,
+ stats);
case kInterArrival:
return new InterArrivalSender(clock);
case kFixRate:
diff --git a/net/quic/congestion_control/send_algorithm_interface.h b/net/quic/congestion_control/send_algorithm_interface.h
index 2850961..359c65c 100644
--- a/net/quic/congestion_control/send_algorithm_interface.h
+++ b/net/quic/congestion_control/send_algorithm_interface.h
@@ -15,6 +15,7 @@
#include "net/quic/quic_bandwidth.h"
#include "net/quic/quic_clock.h"
#include "net/quic/quic_config.h"
+#include "net/quic/quic_connection_stats.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_time.h"
@@ -23,7 +24,8 @@ namespace net {
class NET_EXPORT_PRIVATE SendAlgorithmInterface {
public:
static SendAlgorithmInterface* Create(const QuicClock* clock,
- CongestionFeedbackType type);
+ CongestionFeedbackType type,
+ QuicConnectionStats* stats);
virtual ~SendAlgorithmInterface() {}
diff --git a/net/quic/congestion_control/tcp_cubic_sender.cc b/net/quic/congestion_control/tcp_cubic_sender.cc
index 0366650..7f6678d 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender.cc
@@ -34,9 +34,10 @@ const float kOneMinusBeta = (1 - kBeta);
TcpCubicSender::TcpCubicSender(
const QuicClock* clock,
bool reno,
- QuicTcpCongestionWindow max_tcp_congestion_window)
+ QuicTcpCongestionWindow max_tcp_congestion_window,
+ QuicConnectionStats* stats)
: hybrid_slow_start_(clock),
- cubic_(clock),
+ cubic_(clock, stats),
reno_(reno),
congestion_window_count_(0),
receive_window_(kDefaultReceiveWindow),
diff --git a/net/quic/congestion_control/tcp_cubic_sender.h b/net/quic/congestion_control/tcp_cubic_sender.h
index 74feeef..21a0256 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.h
+++ b/net/quic/congestion_control/tcp_cubic_sender.h
@@ -15,6 +15,7 @@
#include "net/quic/congestion_control/hybrid_slow_start.h"
#include "net/quic/congestion_control/send_algorithm_interface.h"
#include "net/quic/quic_bandwidth.h"
+#include "net/quic/quic_connection_stats.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_time.h"
@@ -32,7 +33,8 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
// Reno option and max_tcp_congestion_window are provided for testing.
TcpCubicSender(const QuicClock* clock,
bool reno,
- QuicTcpCongestionWindow max_tcp_congestion_window);
+ QuicTcpCongestionWindow max_tcp_congestion_window,
+ QuicConnectionStats* stats);
virtual ~TcpCubicSender();
// Start implementation of SendAlgorithmInterface.
diff --git a/net/quic/congestion_control/tcp_cubic_sender_test.cc b/net/quic/congestion_control/tcp_cubic_sender_test.cc
index 29a764c..bc586c7 100644
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender_test.cc
@@ -26,13 +26,15 @@ class TcpCubicSenderPeer : public TcpCubicSender {
TcpCubicSenderPeer(const QuicClock* clock,
bool reno,
QuicTcpCongestionWindow max_tcp_congestion_window)
- : TcpCubicSender(clock, reno, max_tcp_congestion_window) {
+ : TcpCubicSender(clock, reno, max_tcp_congestion_window, &stats_) {
}
QuicTcpCongestionWindow congestion_window() {
return congestion_window_;
}
+ QuicConnectionStats stats_;
+
using TcpCubicSender::AvailableSendWindow;
using TcpCubicSender::SendWindow;
};
diff --git a/net/quic/congestion_control/tcp_loss_algorithm.cc b/net/quic/congestion_control/tcp_loss_algorithm.cc
index d4f2cf1..3fe662c 100644
--- a/net/quic/congestion_control/tcp_loss_algorithm.cc
+++ b/net/quic/congestion_control/tcp_loss_algorithm.cc
@@ -9,43 +9,67 @@
namespace net {
namespace {
+
// TCP retransmits after 3 nacks.
static const size_t kNumberOfNacksBeforeRetransmission = 3;
+
+// How many RTTs the algorithm waits before determining a packet is lost due
+// to early retransmission.
+static const double kEarlyRetransmitLossDelayMultiplier = 1.25;
+
}
-TCPLossAlgorithm::TCPLossAlgorithm() { }
+TCPLossAlgorithm::TCPLossAlgorithm()
+ : loss_detection_timeout_(QuicTime::Zero()) { }
// Uses nack counts to decide when packets are lost.
SequenceNumberSet TCPLossAlgorithm::DetectLostPackets(
const QuicUnackedPacketMap& unacked_packets,
const QuicTime& time,
QuicPacketSequenceNumber largest_observed,
- QuicTime::Delta srtt) {
+ QuicTime::Delta srtt,
+ QuicTime::Delta latest_rtt) {
SequenceNumberSet lost_packets;
+ loss_detection_timeout_ = QuicTime::Zero();
+ QuicTime::Delta loss_delay =
+ srtt.Multiply(kEarlyRetransmitLossDelayMultiplier);
for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
it != unacked_packets.end() && it->first <= largest_observed; ++it) {
if (!it->second.pending) {
continue;
}
- size_t num_nacks_needed = kNumberOfNacksBeforeRetransmission;
- // Check for early retransmit(RFC5827) when the last packet gets acked and
- // the there are fewer than 4 pending packets.
- // TODO(ianswett): Set a retransmission timer instead of losing the packet
- // and retransmitting immediately.
- if (it->second.retransmittable_frames &&
- unacked_packets.largest_sent_packet() == largest_observed) {
- num_nacks_needed = largest_observed - it->first;
- }
- if (it->second.nack_count < num_nacks_needed) {
+ LOG_IF(DFATAL, it->second.nack_count == 0)
+ << "All packets less than largest observed should have been nacked.";
+ if (it->second.nack_count >= kNumberOfNacksBeforeRetransmission) {
+ lost_packets.insert(it->first);
continue;
}
- lost_packets.insert(it->first);
+ // Only early retransmit(RFC5827) when the last packet gets acked and
+ // there are pending retransmittable packets.
+ // This also implements a timer-protected variant of FACK.
+ if (it->second.retransmittable_frames &&
+ unacked_packets.largest_sent_packet() == largest_observed) {
+ // Early retransmit marks the packet as lost once 1.25RTTs have passed
+ // since the packet was sent and otherwise sets an alarm.
+ if (time >= it->second.sent_time.Add(loss_delay)) {
+ lost_packets.insert(it->first);
+ } else {
+ // Set the timeout for the earliest retransmittable packet where early
+ // retransmit applies.
+ loss_detection_timeout_ = it->second.sent_time.Add(loss_delay);
+ break;
+ }
+ }
}
return lost_packets;
}
+QuicTime TCPLossAlgorithm::GetLossTimeout() const {
+ return loss_detection_timeout_;
+}
+
} // namespace net
diff --git a/net/quic/congestion_control/tcp_loss_algorithm.h b/net/quic/congestion_control/tcp_loss_algorithm.h
index a7599aa..df6bc47 100644
--- a/net/quic/congestion_control/tcp_loss_algorithm.h
+++ b/net/quic/congestion_control/tcp_loss_algorithm.h
@@ -28,7 +28,14 @@ class NET_EXPORT_PRIVATE TCPLossAlgorithm : public LossDetectionInterface {
const QuicUnackedPacketMap& unacked_packets,
const QuicTime& time,
QuicPacketSequenceNumber largest_observed,
- QuicTime::Delta srtt) OVERRIDE;
+ QuicTime::Delta srtt,
+ QuicTime::Delta latest_rtt) OVERRIDE;
+
+ // Returns a non-zero value when the early retransmit timer is active.
+ virtual QuicTime GetLossTimeout() const OVERRIDE;
+
+ private:
+ QuicTime loss_detection_timeout_;
};
} // namespace net
diff --git a/net/quic/congestion_control/tcp_loss_algorithm_test.cc b/net/quic/congestion_control/tcp_loss_algorithm_test.cc
index d2737df..b8cf12b 100644
--- a/net/quic/congestion_control/tcp_loss_algorithm_test.cc
+++ b/net/quic/congestion_control/tcp_loss_algorithm_test.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
#include "net/quic/quic_unacked_packet_map.h"
+#include "net/quic/test_tools/mock_clock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -19,13 +20,13 @@ class TcpLossAlgorithmTest : public ::testing::Test {
protected:
TcpLossAlgorithmTest()
: unacked_packets_(true),
- srtt_(QuicTime::Delta::FromMilliseconds(10)) { }
+ srtt_(QuicTime::Delta::FromMilliseconds(100)) { }
void SendDataPacket(QuicPacketSequenceNumber sequence_number) {
SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER,
NULL, 0, new RetransmittableFrames());
unacked_packets_.AddPacket(packet);
- unacked_packets_.SetPending(sequence_number, QuicTime::Zero(), 1000);
+ unacked_packets_.SetPending(sequence_number, clock_.Now(), 1000);
}
void VerifyLosses(QuicPacketSequenceNumber largest_observed,
@@ -33,7 +34,7 @@ class TcpLossAlgorithmTest : public ::testing::Test {
size_t num_losses) {
SequenceNumberSet lost_packets =
loss_algorithm_.DetectLostPackets(
- unacked_packets_, QuicTime::Zero(), largest_observed, srtt_);
+ unacked_packets_, clock_.Now(), largest_observed, srtt_, srtt_);
EXPECT_EQ(num_losses, lost_packets.size());
for (size_t i = 0; i < num_losses; ++i) {
EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i]));
@@ -43,6 +44,7 @@ class TcpLossAlgorithmTest : public ::testing::Test {
QuicUnackedPacketMap unacked_packets_;
TCPLossAlgorithm loss_algorithm_;
QuicTime::Delta srtt_;
+ MockClock clock_;
};
TEST_F(TcpLossAlgorithmTest, NackRetransmit1Packet) {
@@ -64,6 +66,7 @@ TEST_F(TcpLossAlgorithmTest, NackRetransmit1Packet) {
unacked_packets_.NackPacket(1, 3);
QuicPacketSequenceNumber lost[] = { 1 };
VerifyLosses(4, lost, arraysize(lost));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
}
// A stretch ack is an ack that covers more than 1 packet of previously
@@ -82,6 +85,7 @@ TEST_F(TcpLossAlgorithmTest, NackRetransmit1PacketWith1StretchAck) {
unacked_packets_.SetNotPending(4);
QuicPacketSequenceNumber lost[] = { 1 };
VerifyLosses(4, lost, arraysize(lost));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
}
// Ack a packet 3 packets ahead, causing a retransmit.
@@ -99,6 +103,7 @@ TEST_F(TcpLossAlgorithmTest, NackRetransmit1PacketSingleAck) {
unacked_packets_.SetNotPending(4);
QuicPacketSequenceNumber lost[] = { 1 };
VerifyLosses(4, lost, arraysize(lost));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
}
TEST_F(TcpLossAlgorithmTest, EarlyRetransmit1Packet) {
@@ -110,8 +115,14 @@ TEST_F(TcpLossAlgorithmTest, EarlyRetransmit1Packet) {
// Early retransmit when the final packet gets acked and the first is nacked.
unacked_packets_.SetNotPending(2);
unacked_packets_.NackPacket(1, 1);
+ VerifyLosses(2, NULL, 0);
+ EXPECT_EQ(clock_.Now().Add(srtt_.Multiply(1.25)),
+ loss_algorithm_.GetLossTimeout());
+
+ clock_.AdvanceTime(srtt_.Multiply(1.25));
QuicPacketSequenceNumber lost[] = { 1 };
VerifyLosses(2, lost, arraysize(lost));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
}
TEST_F(TcpLossAlgorithmTest, EarlyRetransmitAllPackets) {
@@ -125,8 +136,15 @@ TEST_F(TcpLossAlgorithmTest, EarlyRetransmitAllPackets) {
for (size_t i = 1; i < kNumSentPackets; ++i) {
unacked_packets_.NackPacket(i, kNumSentPackets - i);
}
- QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4 };
+ QuicPacketSequenceNumber lost[] = { 1, 2 };
VerifyLosses(kNumSentPackets, lost, arraysize(lost));
+ EXPECT_EQ(clock_.Now().Add(srtt_.Multiply(1.25)),
+ loss_algorithm_.GetLossTimeout());
+
+ clock_.AdvanceTime(srtt_.Multiply(1.25));
+ QuicPacketSequenceNumber lost2[] = { 1, 2, 3, 4 };
+ VerifyLosses(kNumSentPackets, lost2, arraysize(lost2));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
}
TEST_F(TcpLossAlgorithmTest, DontEarlyRetransmitNeuteredPacket) {
@@ -140,6 +158,7 @@ TEST_F(TcpLossAlgorithmTest, DontEarlyRetransmitNeuteredPacket) {
unacked_packets_.NackPacket(1, 1);
unacked_packets_.NeuterPacket(1);
VerifyLosses(2, NULL, 0);
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
}
} // namespace
diff --git a/net/quic/congestion_control/time_loss_algorithm.cc b/net/quic/congestion_control/time_loss_algorithm.cc
new file mode 100644
index 0000000..c11f1ad
--- /dev/null
+++ b/net/quic/congestion_control/time_loss_algorithm.cc
@@ -0,0 +1,64 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/congestion_control/time_loss_algorithm.h"
+
+#include "net/quic/quic_protocol.h"
+
+namespace net {
+namespace {
+
+// The minimum delay before a packet will be considered lost,
+// regardless of SRTT. Half of the minimum TLP, since the loss algorithm only
+// triggers when a nack has been receieved for the packet.
+static const size_t kMinLossDelayMs = 5;
+
+// How many RTTs the algorithm waits before determining a packet is lost.
+static const double kLossDelayMultiplier = 1.25;
+
+} // namespace
+
+TimeLossAlgorithm::TimeLossAlgorithm()
+ : loss_detection_timeout_(QuicTime::Zero()) { }
+
+SequenceNumberSet TimeLossAlgorithm::DetectLostPackets(
+ const QuicUnackedPacketMap& unacked_packets,
+ const QuicTime& time,
+ QuicPacketSequenceNumber largest_observed,
+ QuicTime::Delta srtt,
+ QuicTime::Delta latest_rtt) {
+ SequenceNumberSet lost_packets;
+ loss_detection_timeout_ = QuicTime::Zero();
+ QuicTime::Delta loss_delay = QuicTime::Delta::Max(
+ QuicTime::Delta::FromMilliseconds(kMinLossDelayMs),
+ QuicTime::Delta::Max(srtt, latest_rtt).Multiply(kLossDelayMultiplier));
+
+ for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
+ it != unacked_packets.end() && it->first <= largest_observed; ++it) {
+ if (!it->second.pending) {
+ continue;
+ }
+ LOG_IF(DFATAL, it->second.nack_count == 0)
+ << "All packets less than largest observed should have been nacked.";
+
+ // Packets are sent in order, so break when we haven't waited long enough
+ // to lose any more packets and leave the loss_time_ set for the timeout.
+ QuicTime when_lost = it->second.sent_time.Add(loss_delay);
+ if (time < when_lost) {
+ loss_detection_timeout_ = when_lost;
+ break;
+ }
+ lost_packets.insert(it->first);
+ }
+
+ return lost_packets;
+}
+
+// loss_time_ is updated in DetectLostPackets, which must be called every time
+// an ack is received or the timeout expires.
+QuicTime TimeLossAlgorithm::GetLossTimeout() const {
+ return loss_detection_timeout_;
+}
+
+} // namespace net
diff --git a/net/quic/congestion_control/time_loss_algorithm.h b/net/quic/congestion_control/time_loss_algorithm.h
new file mode 100644
index 0000000..eaa949e
--- /dev/null
+++ b/net/quic/congestion_control/time_loss_algorithm.h
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_QUIC_CONGESTION_CONTROL_TIME_LOSS_ALGORITHM_H_
+#define NET_QUIC_CONGESTION_CONTROL_TIME_LOSS_ALGORITHM_H_
+
+#include <algorithm>
+#include <map>
+
+#include "base/basictypes.h"
+#include "net/quic/congestion_control/loss_detection_interface.h"
+#include "net/quic/quic_protocol.h"
+#include "net/quic/quic_time.h"
+#include "net/quic/quic_unacked_packet_map.h"
+
+namespace net {
+
+// A loss detection algorithm which avoids spurious losses and retransmissions
+// by waiting 1.25 RTTs after a packet was sent instead of nack count.
+class NET_EXPORT_PRIVATE TimeLossAlgorithm : public LossDetectionInterface {
+ public:
+ TimeLossAlgorithm();
+ virtual ~TimeLossAlgorithm() {}
+
+ // Declares pending packets less than the largest observed lost when it has
+ // been 1.25 RTT since they were sent. Packets larger than the largest
+ // observed are retransmitted via TLP.
+ virtual SequenceNumberSet DetectLostPackets(
+ const QuicUnackedPacketMap& unacked_packets,
+ const QuicTime& time,
+ QuicPacketSequenceNumber largest_observed,
+ QuicTime::Delta srtt,
+ QuicTime::Delta latest_rtt) OVERRIDE;
+
+ // Returns the time the next packet will be lost, or zero if there
+ // are no nacked pending packets outstanding.
+ // TODO(ianswett): Ideally the RTT variance and the RTT would be used to
+ // determine the time a packet is considered lost.
+ // TODO(ianswett): Consider using Max(1.25 * srtt, 1.125 * last_rtt).
+ virtual QuicTime GetLossTimeout() const OVERRIDE;
+
+ private:
+ QuicTime loss_detection_timeout_;
+};
+
+} // namespace net
+
+#endif // NET_QUIC_CONGESTION_CONTROL_TIME_LOSS_ALGORITHM_H_
diff --git a/net/quic/congestion_control/time_loss_algorithm_test.cc b/net/quic/congestion_control/time_loss_algorithm_test.cc
new file mode 100644
index 0000000..0ccd305
--- /dev/null
+++ b/net/quic/congestion_control/time_loss_algorithm_test.cc
@@ -0,0 +1,136 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <algorithm>
+
+#include "base/logging.h"
+#include "base/stl_util.h"
+#include "net/quic/congestion_control/time_loss_algorithm.h"
+#include "net/quic/quic_unacked_packet_map.h"
+#include "net/quic/test_tools/mock_clock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+namespace {
+
+class TimeLossAlgorithmTest : public ::testing::Test {
+ protected:
+ TimeLossAlgorithmTest()
+ : unacked_packets_(true),
+ srtt_(QuicTime::Delta::FromMilliseconds(100)) { }
+
+ void SendDataPacket(QuicPacketSequenceNumber sequence_number) {
+ SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER,
+ NULL, 0, new RetransmittableFrames());
+ unacked_packets_.AddPacket(packet);
+ unacked_packets_.SetPending(sequence_number, clock_.Now(), 1000);
+ }
+
+ void VerifyLosses(QuicPacketSequenceNumber largest_observed,
+ QuicPacketSequenceNumber* losses_expected,
+ size_t num_losses) {
+ SequenceNumberSet lost_packets =
+ loss_algorithm_.DetectLostPackets(
+ unacked_packets_, clock_.Now(), largest_observed, srtt_, srtt_);
+ EXPECT_EQ(num_losses, lost_packets.size());
+ for (size_t i = 0; i < num_losses; ++i) {
+ EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i]));
+ }
+ }
+
+ QuicUnackedPacketMap unacked_packets_;
+ TimeLossAlgorithm loss_algorithm_;
+ QuicTime::Delta srtt_;
+ MockClock clock_;
+};
+
+TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) {
+ const size_t kNumSentPackets = 5;
+ // Transmit 5 packets.
+ for (size_t i = 1; i <= kNumSentPackets; ++i) {
+ SendDataPacket(i);
+ }
+ unacked_packets_.SetNotPending(2);
+ for (size_t i = 0; i < 500; ++i) {
+ unacked_packets_.NackPacket(1, i);
+ VerifyLosses(2, NULL, 0);
+ }
+ EXPECT_EQ(srtt_.Multiply(1.25),
+ loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
+}
+
+TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) {
+ const size_t kNumSentPackets = 10;
+ // Transmit 10 packets at 1/10th an RTT interval.
+ for (size_t i = 1; i <= kNumSentPackets; ++i) {
+ SendDataPacket(i);
+ clock_.AdvanceTime(srtt_.Multiply(0.1));
+ }
+ // Expect the timer to not be set.
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+ // The packet should not be lost until 1.25 RTTs pass.
+ unacked_packets_.NackPacket(1, 1);
+ unacked_packets_.SetNotPending(2);
+ VerifyLosses(2, NULL, 0);
+ // Expect the timer to be set to 0.25 RTT's in the future.
+ EXPECT_EQ(srtt_.Multiply(0.25),
+ loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
+ unacked_packets_.NackPacket(1, 5);
+ VerifyLosses(2, NULL, 0);
+ clock_.AdvanceTime(srtt_.Multiply(0.25));
+ QuicPacketSequenceNumber lost[] = { 1 };
+ VerifyLosses(2, lost, arraysize(lost));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+}
+
+TEST_F(TimeLossAlgorithmTest, NoLossWithoutNack) {
+ const size_t kNumSentPackets = 10;
+ // Transmit 10 packets at 1/10th an RTT interval.
+ for (size_t i = 1; i <= kNumSentPackets; ++i) {
+ SendDataPacket(i);
+ clock_.AdvanceTime(srtt_.Multiply(0.1));
+ }
+ // Expect the timer to not be set.
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+ // The packet should not be lost without a nack.
+ unacked_packets_.SetNotPending(1);
+ VerifyLosses(1, NULL, 0);
+ // The timer should still not be set.
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+ clock_.AdvanceTime(srtt_.Multiply(0.25));
+ VerifyLosses(1, NULL, 0);
+ clock_.AdvanceTime(srtt_);
+ VerifyLosses(1, NULL, 0);
+
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+}
+
+TEST_F(TimeLossAlgorithmTest, MultipleLossesAtOnce) {
+ const size_t kNumSentPackets = 10;
+ // Transmit 10 packets at once and then go forward an RTT.
+ for (size_t i = 1; i <= kNumSentPackets; ++i) {
+ SendDataPacket(i);
+ }
+ clock_.AdvanceTime(srtt_);
+ // Expect the timer to not be set.
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+ // The packet should not be lost until 1.25 RTTs pass.
+ for (size_t i = 1; i < kNumSentPackets; ++i) {
+ unacked_packets_.NackPacket(i, 1);
+ }
+ unacked_packets_.SetNotPending(10);
+ VerifyLosses(10, NULL, 0);
+ // Expect the timer to be set to 0.25 RTT's in the future.
+ EXPECT_EQ(srtt_.Multiply(0.25),
+ loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
+ clock_.AdvanceTime(srtt_.Multiply(0.25));
+ QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ VerifyLosses(10, lost, arraysize(lost));
+ EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+}
+
+} // namespace
+} // namespace test
+} // namespace net
diff --git a/net/quic/crypto/crypto_handshake.h b/net/quic/crypto/crypto_handshake.h
index fe0afed..fec5393 100644
--- a/net/quic/crypto/crypto_handshake.h
+++ b/net/quic/crypto/crypto_handshake.h
@@ -43,10 +43,10 @@ struct NET_EXPORT_PRIVATE QuicCryptoNegotiatedParameters {
std::string sni;
std::string client_nonce;
std::string server_nonce;
- // hkdf_input_suffix contains the HKDF input following the label: the GUID,
- // client hello and server config. This is only populated in the client
- // because only the client needs to derive the forward secure keys at a later
- // time from the initial keys.
+ // hkdf_input_suffix contains the HKDF input following the label: the
+ // ConnectionId, client hello and server config. This is only populated in the
+ // client because only the client needs to derive the forward secure keys at a
+ // later time from the initial keys.
std::string hkdf_input_suffix;
// cached_certs contains the cached certificates that a client used when
// sending a client hello.
diff --git a/net/quic/crypto/crypto_server_test.cc b/net/quic/crypto/crypto_server_test.cc
index 0174ae5..0cce264 100644
--- a/net/quic/crypto/crypto_server_test.cc
+++ b/net/quic/crypto/crypto_server_test.cc
@@ -178,7 +178,7 @@ class CryptoServerTest : public ::testing::Test {
const char* error_substr) {
string error_details;
QuicErrorCode error = config_.ProcessClientHello(
- result, 1 /* GUID */, client_address_,
+ result, 1 /* ConnectionId */, client_address_,
supported_versions_.front(), supported_versions_, &clock_, rand_,
&params_, &out_, &error_details);
diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc
index 12e61b7..95d1726 100644
--- a/net/quic/crypto/quic_crypto_client_config.cc
+++ b/net/quic/crypto/quic_crypto_client_config.cc
@@ -381,7 +381,7 @@ void QuicCryptoClientConfig::FillInchoateClientHello(
QuicErrorCode QuicCryptoClientConfig::FillClientHello(
const string& server_hostname,
- QuicGuid guid,
+ QuicConnectionId connection_id,
const QuicVersion preferred_version,
const CachedState* cached,
QuicWallTime now,
@@ -504,7 +504,8 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello(
const QuicData& client_hello_serialized = out->GetSerialized();
hkdf_input.append(QuicCryptoConfig::kCETVLabel,
strlen(QuicCryptoConfig::kCETVLabel) + 1);
- hkdf_input.append(reinterpret_cast<char*>(&guid), sizeof(guid));
+ hkdf_input.append(reinterpret_cast<char*>(&connection_id),
+ sizeof(connection_id));
hkdf_input.append(client_hello_serialized.data(),
client_hello_serialized.length());
hkdf_input.append(cached->server_config());
@@ -545,8 +546,8 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello(
}
out_params->hkdf_input_suffix.clear();
- out_params->hkdf_input_suffix.append(reinterpret_cast<char*>(&guid),
- sizeof(guid));
+ out_params->hkdf_input_suffix.append(reinterpret_cast<char*>(&connection_id),
+ sizeof(connection_id));
const QuicData& client_hello_serialized = out->GetSerialized();
out_params->hkdf_input_suffix.append(client_hello_serialized.data(),
client_hello_serialized.length());
@@ -633,7 +634,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessRejection(
QuicErrorCode QuicCryptoClientConfig::ProcessServerHello(
const CryptoHandshakeMessage& server_hello,
- QuicGuid guid,
+ QuicConnectionId connection_id,
const QuicVersionVector& negotiated_versions,
CachedState* cached,
QuicCryptoNegotiatedParameters* out_params,
diff --git a/net/quic/crypto/quic_crypto_client_config.h b/net/quic/crypto/quic_crypto_client_config.h
index fc99be5..4221ada9 100644
--- a/net/quic/crypto/quic_crypto_client_config.h
+++ b/net/quic/crypto/quic_crypto_client_config.h
@@ -180,7 +180,7 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
// client chose to use initially. This allows the server to detect downgrade
// attacks.
QuicErrorCode FillClientHello(const std::string& server_hostname,
- QuicGuid guid,
+ QuicConnectionId connection_id,
const QuicVersion preferred_version,
const CachedState* cached,
QuicWallTime now,
@@ -210,7 +210,7 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
// server. The contents of this list will be compared against the list of
// versions provided in the VER tag of the server hello.
QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
- QuicGuid guid,
+ QuicConnectionId connection_id,
const QuicVersionVector& negotiated_versions,
CachedState* cached,
QuicCryptoNegotiatedParameters* out_params,
diff --git a/net/quic/crypto/quic_crypto_server_config.cc b/net/quic/crypto/quic_crypto_server_config.cc
index e2b0583..58c901f 100644
--- a/net/quic/crypto/quic_crypto_server_config.cc
+++ b/net/quic/crypto/quic_crypto_server_config.cc
@@ -468,7 +468,7 @@ void QuicCryptoServerConfig::ValidateClientHello(
QuicErrorCode QuicCryptoServerConfig::ProcessClientHello(
const ValidateClientHelloResultCallback::Result& validate_chlo_result,
- QuicGuid guid,
+ QuicConnectionId connection_id,
IPEndPoint client_address,
QuicVersion version,
const QuicVersionVector& supported_versions,
@@ -601,9 +601,10 @@ QuicErrorCode QuicCryptoServerConfig::ProcessClientHello(
string hkdf_suffix;
const QuicData& client_hello_serialized = client_hello.GetSerialized();
- hkdf_suffix.reserve(sizeof(guid) + client_hello_serialized.length() +
+ hkdf_suffix.reserve(sizeof(connection_id) + client_hello_serialized.length() +
requested_config->serialized.size());
- hkdf_suffix.append(reinterpret_cast<char*>(&guid), sizeof(guid));
+ hkdf_suffix.append(reinterpret_cast<char*>(&connection_id),
+ sizeof(connection_id));
hkdf_suffix.append(client_hello_serialized.data(),
client_hello_serialized.length());
hkdf_suffix.append(requested_config->serialized);
@@ -619,7 +620,8 @@ QuicErrorCode QuicCryptoServerConfig::ProcessClientHello(
string hkdf_input;
hkdf_input.append(QuicCryptoConfig::kCETVLabel,
strlen(QuicCryptoConfig::kCETVLabel) + 1);
- hkdf_input.append(reinterpret_cast<char*>(&guid), sizeof(guid));
+ hkdf_input.append(reinterpret_cast<char*>(&connection_id),
+ sizeof(connection_id));
hkdf_input.append(client_hello_serialized.data(),
client_hello_serialized.length());
hkdf_input.append(requested_config->serialized);
diff --git a/net/quic/crypto/quic_crypto_server_config.h b/net/quic/crypto/quic_crypto_server_config.h
index 0310972..7c9ed42 100644
--- a/net/quic/crypto/quic_crypto_server_config.h
+++ b/net/quic/crypto/quic_crypto_server_config.h
@@ -179,7 +179,8 @@ class NET_EXPORT_PRIVATE QuicCryptoServerConfig {
// validate_chlo_result: Output from the asynchronous call to
// ValidateClientHello. Contains the client hello message and
// information about it.
- // guid: the GUID for the connection, which is used in key derivation.
+ // connection_id: the ConnectionId for the connection, which is used in key
+ // derivation.
// client_address: the IP address and port of the client. The IP address is
// used to generate and validate source-address tokens.
// version: version of the QUIC protocol in use for this connection
@@ -194,7 +195,7 @@ class NET_EXPORT_PRIVATE QuicCryptoServerConfig {
// error_details: used to store a string describing any error.
QuicErrorCode ProcessClientHello(
const ValidateClientHelloResultCallback::Result& validate_chlo_result,
- QuicGuid guid,
+ QuicConnectionId connection_id,
IPEndPoint client_address,
QuicVersion version,
const QuicVersionVector& supported_versions,
diff --git a/net/quic/quic_client_session.cc b/net/quic/quic_client_session.cc
index e373366..c083ffa 100644
--- a/net/quic/quic_client_session.cc
+++ b/net/quic/quic_client_session.cc
@@ -501,7 +501,7 @@ base::Value* QuicClientSession::GetInfoAsValue(
dict->SetInteger("open_streams", GetNumOpenStreams());
dict->SetInteger("total_streams", num_total_streams_);
dict->SetString("peer_address", peer_address().ToString());
- dict->SetString("guid", base::Uint64ToString(guid()));
+ dict->SetString("connection_id", base::Uint64ToString(connection_id()));
dict->SetBoolean("connected", connection()->connected());
base::ListValue* alias_list = new base::ListValue();
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index e5bcbb9..273f4f5 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -13,6 +13,7 @@
#include <set>
#include <utility>
+#include "base/debug/stack_trace.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "net/base/net_errors.h"
@@ -162,7 +163,7 @@ QuicConnection::QueuedPacket::QueuedPacket(SerializedPacket packet,
#define ENDPOINT (is_server_ ? "Server: " : " Client: ")
-QuicConnection::QuicConnection(QuicGuid guid,
+QuicConnection::QuicConnection(QuicConnectionId connection_id,
IPEndPoint address,
QuicConnectionHelperInterface* helper,
QuicPacketWriter* writer,
@@ -176,7 +177,7 @@ QuicConnection::QuicConnection(QuicGuid guid,
encryption_level_(ENCRYPTION_NONE),
clock_(helper->GetClock()),
random_generator_(helper->GetRandomGenerator()),
- guid_(guid),
+ connection_id_(connection_id),
peer_address_(address),
largest_seen_packet_with_ack_(0),
largest_seen_packet_with_stop_waiting_(0),
@@ -190,7 +191,7 @@ QuicConnection::QuicConnection(QuicGuid guid,
resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))),
timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
debug_visitor_(NULL),
- packet_creator_(guid_, &framer_, random_generator_, is_server),
+ packet_creator_(connection_id_, &framer_, random_generator_, is_server),
packet_generator_(this, NULL, &packet_creator_),
idle_network_timeout_(
QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)),
@@ -208,7 +209,8 @@ QuicConnection::QuicConnection(QuicGuid guid,
// Pacing will be enabled if the client negotiates it.
sent_packet_manager_.MaybeEnablePacing();
}
- DVLOG(1) << ENDPOINT << "Created connection with guid: " << guid;
+ DVLOG(1) << ENDPOINT << "Created connection with connection_id: "
+ << connection_id;
timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_));
framer_.set_visitor(this);
framer_.set_received_entropy_calculator(&received_packet_manager_);
@@ -399,9 +401,10 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
// Will be decrement below if we fall through to return true;
++stats_.packets_dropped;
- if (header.public_header.guid != guid_) {
- DVLOG(1) << ENDPOINT << "Ignoring packet from unexpected GUID: "
- << header.public_header.guid << " instead of " << guid_;
+ if (header.public_header.connection_id != connection_id_) {
+ DVLOG(1) << ENDPOINT << "Ignoring packet from unexpected ConnectionId: "
+ << header.public_header.connection_id << " instead of "
+ << connection_id_;
return false;
}
@@ -677,7 +680,8 @@ bool QuicConnection::OnConnectionCloseFrame(
if (debug_visitor_) {
debug_visitor_->OnConnectionCloseFrame(frame);
}
- DVLOG(1) << ENDPOINT << "Connection " << guid() << " closed with error "
+ DVLOG(1) << ENDPOINT << "Connection " << connection_id()
+ << " closed with error "
<< QuicUtils::ErrorToString(frame.error_code)
<< " " << frame.error_details;
last_close_frames_.push_back(frame);
@@ -727,7 +731,8 @@ void QuicConnection::OnPacketComplete() {
<< last_rst_frames_.size() << " rsts, "
<< last_close_frames_.size() << " closes, "
<< last_stream_frames_.size()
- << " stream frames for " << last_header_.public_header.guid;
+ << " stream frames for "
+ << last_header_.public_header.connection_id;
MaybeQueueAck();
@@ -969,6 +974,20 @@ void QuicConnection::SendRstStream(QuicStreamId id,
QuicFrame(new QuicRstStreamFrame(id, error, bytes_written)));
}
+void QuicConnection::SendWindowUpdate(QuicStreamId id,
+ QuicStreamOffset byte_offset) {
+ // Opportunistically bundle an ack with this outgoing packet.
+ ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK);
+ packet_generator_.AddControlFrame(
+ QuicFrame(new QuicWindowUpdateFrame(id, byte_offset)));
+}
+
+void QuicConnection::SendBlocked(QuicStreamId id) {
+ // Opportunistically bundle an ack with this outgoing packet.
+ ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK);
+ packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id)));
+}
+
const QuicConnectionStats& QuicConnection::GetStats() {
// Update rtt and estimated bandwidth.
stats_.rtt = sent_packet_manager_.SmoothedRtt().ToMicroseconds();
@@ -1549,7 +1568,7 @@ void QuicConnection::MaybeProcessRevivedPacket() {
QuicPacketHeader revived_header;
char revived_payload[kMaxPacketSize];
size_t len = group->Revive(&revived_header, revived_payload, kMaxPacketSize);
- revived_header.public_header.guid = guid_;
+ revived_header.public_header.connection_id = connection_id_;
revived_header.public_header.version_flag = false;
revived_header.public_header.reset_flag = false;
revived_header.fec_flag = false;
@@ -1604,9 +1623,9 @@ void QuicConnection::SendConnectionCloseWithDetails(QuicErrorCode error,
void QuicConnection::SendConnectionClosePacket(QuicErrorCode error,
const string& details) {
- DVLOG(1) << ENDPOINT << "Force closing " << guid() << " with error "
- << QuicUtils::ErrorToString(error) << " (" << error << ") "
- << details;
+ DVLOG(1) << ENDPOINT << "Force closing " << connection_id()
+ << " with error " << QuicUtils::ErrorToString(error)
+ << " (" << error << ") " << details;
ScopedPacketBundler ack_bundler(this, SEND_ACK);
QuicConnectionCloseFrame* frame = new QuicConnectionCloseFrame();
frame->error_code = error;
@@ -1616,8 +1635,9 @@ void QuicConnection::SendConnectionClosePacket(QuicErrorCode error,
}
void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) {
- DCHECK(connected_);
if (!connected_) {
+ DLOG(DFATAL) << "Error: attempt to close an already closed connection"
+ << base::debug::StackTrace().ToString();
return;
}
connected_ = false;
diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h
index 481f426..7d42cb7 100644
--- a/net/quic/quic_connection.h
+++ b/net/quic/quic_connection.h
@@ -204,9 +204,9 @@ class NET_EXPORT_PRIVATE QuicConnection
BUNDLE_PENDING_ACK = 2,
};
- // Constructs a new QuicConnection for the specified |guid| and |address|.
+ // Constructs a new QuicConnection for |connection_id| and |address|.
// |helper| and |writer| must outlive this connection.
- QuicConnection(QuicGuid guid,
+ QuicConnection(QuicConnectionId connection_id,
IPEndPoint address,
QuicConnectionHelperInterface* helper,
QuicPacketWriter* writer,
@@ -231,11 +231,18 @@ class NET_EXPORT_PRIVATE QuicConnection
bool fin,
QuicAckNotifier::DelegateInterface* delegate);
- // Send a stream reset frame to the peer.
+ // Send a RST_STREAM frame to the peer.
virtual void SendRstStream(QuicStreamId id,
QuicRstStreamErrorCode error,
QuicStreamOffset bytes_written);
+ // Send a BLOCKED frame to the peer.
+ virtual void SendBlocked(QuicStreamId id);
+
+ // Send a WINDOW_UPDATE frame to the peer.
+ virtual void SendWindowUpdate(QuicStreamId id,
+ QuicStreamOffset byte_offset);
+
// Sends the connection close packet without affecting the state of the
// connection. This should only be called if the session is actively being
// destroyed: otherwise call SendConnectionCloseWithDetails instead.
@@ -334,7 +341,7 @@ class NET_EXPORT_PRIVATE QuicConnection
}
const IPEndPoint& self_address() const { return self_address_; }
const IPEndPoint& peer_address() const { return peer_address_; }
- QuicGuid guid() const { return guid_; }
+ QuicConnectionId connection_id() const { return connection_id_; }
const QuicClock* clock() const { return clock_; }
QuicRandom* random_generator() const { return random_generator_; }
@@ -595,7 +602,7 @@ class NET_EXPORT_PRIVATE QuicConnection
const QuicClock* clock_;
QuicRandom* random_generator_;
- const QuicGuid guid_;
+ const QuicConnectionId connection_id_;
// Address on the last successfully processed packet received from the
// client.
IPEndPoint self_address_;
diff --git a/net/quic/quic_connection_logger.cc b/net/quic/quic_connection_logger.cc
index 9a775182..f47e1d0 100644
--- a/net/quic/quic_connection_logger.cc
+++ b/net/quic/quic_connection_logger.cc
@@ -66,8 +66,8 @@ base::Value* NetLogQuicPacketRetransmittedCallback(
base::Value* NetLogQuicPacketHeaderCallback(const QuicPacketHeader* header,
NetLog::LogLevel /* log_level */) {
base::DictionaryValue* dict = new base::DictionaryValue();
- dict->SetString("guid",
- base::Uint64ToString(header->public_header.guid));
+ dict->SetString("connection_id",
+ base::Uint64ToString(header->public_header.connection_id));
dict->SetInteger("reset_flag", header->public_header.reset_flag);
dict->SetInteger("version_flag", header->public_header.version_flag);
dict->SetString("packet_sequence_number",
diff --git a/net/quic/quic_connection_stats.cc b/net/quic/quic_connection_stats.cc
index a62f730..324ea42 100644
--- a/net/quic/quic_connection_stats.cc
+++ b/net/quic/quic_connection_stats.cc
@@ -22,10 +22,13 @@ QuicConnectionStats::QuicConnectionStats()
packets_revived(0),
packets_dropped(0),
crypto_retransmit_count(0),
+ loss_timeout_count(0),
tlp_count(0),
rto_count(0),
rtt(0),
- estimated_bandwidth(0) {
+ estimated_bandwidth(0),
+ cwnd_increase_cubic_mode(0),
+ cwnd_increase_reno_mode(0) {
}
QuicConnectionStats::~QuicConnectionStats() {}
@@ -49,6 +52,10 @@ ostream& operator<<(ostream& os, const QuicConnectionStats& s) {
<< ", tlp count: " << s.tlp_count
<< ", rtt(us): " << s.rtt
<< ", estimated_bandwidth: " << s.estimated_bandwidth
+ << ", amount of cwnd increase in TCPCubic, in cubic mode: "
+ << s.cwnd_increase_cubic_mode
+ << ", amount of cwnd increase in TCPCubic, matched by or in reno mode: "
+ << s.cwnd_increase_reno_mode
<< "}\n";
return os;
}
diff --git a/net/quic/quic_connection_stats.h b/net/quic/quic_connection_stats.h
index 7f59042..d2ff52a 100644
--- a/net/quic/quic_connection_stats.h
+++ b/net/quic/quic_connection_stats.h
@@ -47,11 +47,20 @@ struct NET_EXPORT_PRIVATE QuicConnectionStats {
uint32 packets_revived;
uint32 packets_dropped; // duplicate or less than least unacked.
uint32 crypto_retransmit_count;
+ uint32 loss_timeout_count; // Count of times the loss detection alarm fired.
uint32 tlp_count;
uint32 rto_count;
uint32 rtt; // In microseconds
uint64 estimated_bandwidth;
+
+ // The following stats are used only in TcpCubicSender.
+ // Total amount of cwnd increase by TCPCubic in cubic mode.
+ uint32 cwnd_increase_cubic_mode;
+ // Total amount of cwnd increase by TCPCubic in reno mode. This includes
+ // cwnd increases that actually happened in cubic mode, but where reno mode
+ // would have yielded the same increase.
+ uint32 cwnd_increase_reno_mode;
// TODO(satyamshekhar): Add window_size, mss and mtu.
};
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 7feb87a..0eaad97 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/stl_util.h"
#include "net/base/net_errors.h"
+#include "net/quic/congestion_control/loss_detection_interface.h"
#include "net/quic/congestion_control/receive_algorithm_interface.h"
#include "net/quic/congestion_control/send_algorithm_interface.h"
#include "net/quic/crypto/null_encrypter.h"
@@ -398,13 +399,13 @@ class TestPacketWriter : public QuicPacketWriter {
class TestConnection : public QuicConnection {
public:
- TestConnection(QuicGuid guid,
+ TestConnection(QuicConnectionId connection_id,
IPEndPoint address,
TestConnectionHelper* helper,
TestPacketWriter* writer,
bool is_server,
QuicVersion version)
- : QuicConnection(guid, address, helper, writer, is_server,
+ : QuicConnection(connection_id, address, helper, writer, is_server,
SupportedVersions(version)),
helper_(helper),
writer_(writer) {
@@ -426,6 +427,11 @@ class TestConnection : public QuicConnection {
QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
}
+ void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) {
+ QuicSentPacketManagerPeer::SetLossAlgorithm(
+ QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm);
+ }
+
void SendPacket(EncryptionLevel level,
QuicPacketSequenceNumber sequence_number,
QuicPacket* packet,
@@ -535,19 +541,21 @@ class TestConnection : public QuicConnection {
class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
protected:
QuicConnectionTest()
- : guid_(42),
+ : connection_id_(42),
framer_(SupportedVersions(version()), QuicTime::Zero(), false),
- creator_(guid_, &framer_, &random_generator_, false),
+ creator_(connection_id_, &framer_, &random_generator_, false),
send_algorithm_(new StrictMock<MockSendAlgorithm>),
+ loss_algorithm_(new MockLossAlgorithm()),
helper_(new TestConnectionHelper(&clock_, &random_generator_)),
writer_(new TestPacketWriter(version())),
- connection_(guid_, IPEndPoint(), helper_.get(), writer_.get(),
- false, version()),
+ connection_(connection_id_, IPEndPoint(), helper_.get(),
+ writer_.get(), false, version()),
frame1_(1, false, 0, MakeIOVector(data1)),
frame2_(1, false, 3, MakeIOVector(data2)),
accept_packet_(true) {
connection_.set_visitor(&visitor_);
connection_.SetSendAlgorithm(send_algorithm_);
+ connection_.SetLossAlgorithm(loss_algorithm_);
framer_.set_received_entropy_calculator(&entropy_calculator_);
// Simplify tests by not sending feedback unless specifically configured.
SetFeedback(NULL);
@@ -569,6 +577,11 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber());
EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber());
+
+ EXPECT_CALL(*loss_algorithm_, GetLossTimeout())
+ .WillRepeatedly(Return(QuicTime::Zero()));
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillRepeatedly(Return(SequenceNumberSet()));
}
QuicVersion version() {
@@ -708,7 +721,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
data_packet.reset(ConstructDataPacket(number, 1, !kEntropyFlag));
}
- header_.public_header.guid = guid_;
+ header_.public_header.connection_id = connection_id_;
header_.public_header.reset_flag = false;
header_.public_header.version_flag = false;
header_.entropy_flag = entropy_flag;
@@ -724,7 +737,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
// with itself, depending on the number of packets.
if (((number - min_protected_packet) % 2) == 0) {
for (size_t i = GetStartOfFecProtectedData(
- header_.public_header.guid_length,
+ header_.public_header.connection_id_length,
header_.public_header.version_flag,
header_.public_header.sequence_number_length);
i < data_packet->length(); ++i) {
@@ -786,7 +799,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number,
QuicFecGroupNumber fec_group,
bool entropy_flag) {
- header_.public_header.guid = guid_;
+ header_.public_header.connection_id = connection_id_;
header_.public_header.reset_flag = false;
header_.public_header.version_flag = false;
header_.entropy_flag = entropy_flag;
@@ -806,7 +819,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number,
QuicFecGroupNumber fec_group) {
- header_.public_header.guid = guid_;
+ header_.public_header.connection_id = connection_id_;
header_.packet_sequence_number = number;
header_.public_header.reset_flag = false;
header_.public_header.version_flag = false;
@@ -896,12 +909,13 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1));
}
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
QuicFramer framer_;
QuicPacketCreator creator_;
MockEntropyCalculator entropy_calculator_;
MockSendAlgorithm* send_algorithm_;
+ MockLossAlgorithm* loss_algorithm_;
TestReceiveAlgorithm* receive_algorithm_;
MockClock clock_;
MockRandom random_generator_;
@@ -1038,10 +1052,16 @@ TEST_P(QuicConnectionTest, TruncatedAck) {
}
QuicAckFrame frame = InitAckFrame(num_packets, 1);
+ SequenceNumberSet lost_packets;
// Create an ack with 256 nacks, none adjacent to one another.
for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) {
NackPacket(i * 2, &frame);
+ if (i < 256) { // Last packet is nacked, but not lost.
+ lost_packets.insert(i * 2);
+ }
}
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(entropy_calculator_,
EntropyHash(511)).WillOnce(testing::Return(0));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
@@ -1060,6 +1080,8 @@ TEST_P(QuicConnectionTest, TruncatedAck) {
// Removing one missing packet allows us to ack 192 and one more range, but
// 192 has already been declared lost, so it doesn't register as an ack.
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
ProcessAckPacket(&frame);
@@ -1110,18 +1132,23 @@ TEST_P(QuicConnectionTest, OutOfOrderReceiptCausesAckSend) {
TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
+
QuicPacketSequenceNumber original;
QuicByteCount packet_size;
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _))
.WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size),
Return(true)));
- EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
QuicAckFrame frame = InitAckFrame(original, 1);
NackPacket(original, &frame);
// First nack triggers early retransmit.
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(1);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
QuicPacketSequenceNumber retransmission;
EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, _, packet_size - kQuicVersionSize,
@@ -1134,6 +1161,8 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
NackPacket(original, &frame2);
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
ProcessAckPacket(&frame2);
// Now if the peer sends an ack which still reports the retransmitted packet
@@ -1147,6 +1176,9 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
EXPECT_EQ(1u, writer_->stream_frames()->size());
writer_->Reset();
+ // No more packet loss for the rest of the test.
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillRepeatedly(Return(SequenceNumberSet()));
ProcessAckPacket(&frame2);
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION,
HAS_RETRANSMITTABLE_DATA));
@@ -1523,6 +1555,10 @@ TEST_P(QuicConnectionTest, AbandonAllFEC) {
NackPacket(4, &ack_fec);
// Lose the first FEC packet and ack the three data packets.
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(2);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3);
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
@@ -1788,10 +1824,6 @@ TEST_P(QuicConnectionTest, OnCanWrite) {
}
TEST_P(QuicConnectionTest, RetransmitOnNack) {
- EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
- EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
QuicPacketSequenceNumber last_packet;
QuicByteCount second_packet_size;
SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1
@@ -1801,20 +1833,23 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- // Peer acks one but not two or three. Right now we only retransmit on
- // explicit nack, so it should not trigger a retransmission.
+ // Don't lose a packet on an ack, and nothing is retransmitted.
+ EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _));
QuicAckFrame ack_one = InitAckFrame(1, 0);
ProcessAckPacket(&ack_one);
- ProcessAckPacket(&ack_one);
- ProcessAckPacket(&ack_one);
- // Peer acks up to 3 with two explicitly missing.
- // Early retransmit causes 2 to be retransmitted on the first ack.
+ // Lose a packet and ensure it triggers retransmission.
QuicAckFrame nack_two = InitAckFrame(3, 0);
NackPacket(2, &nack_two);
- // The third nack should trigger a retransmission.
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(2);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, _, second_packet_size - kQuicVersionSize,
NACK_RETRANSMISSION, _)).Times(1);
@@ -1822,10 +1857,6 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) {
}
TEST_P(QuicConnectionTest, DiscardRetransmit) {
- EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
- EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
QuicPacketSequenceNumber last_packet;
SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
@@ -1833,26 +1864,26 @@ TEST_P(QuicConnectionTest, DiscardRetransmit) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- // Peer acks one but not two or three. Right now we only retransmit on
- // explicit nack, so it should not trigger a retransmission.
- QuicAckFrame ack_one = InitAckFrame(1, 0);
- ProcessAckPacket(&ack_one);
- ProcessAckPacket(&ack_one);
- ProcessAckPacket(&ack_one);
-
- // Peer acks up to 3 with two explicitly missing. Two nacks should cause no
- // change.
+ // Instigate a loss with an ack.
QuicAckFrame nack_two = InitAckFrame(3, 0);
NackPacket(2, &nack_two);
// The first nack should trigger a fast retransmission, but we'll be
// write blocked, so the packet will be queued.
BlockOnNextWrite();
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(2);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2);
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
ProcessAckPacket(&nack_two);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
// Now, ack the previous transmission.
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
QuicAckFrame ack_all = InitAckFrame(3, 0);
ProcessAckPacket(&ack_all);
@@ -1870,18 +1901,23 @@ TEST_P(QuicConnectionTest, DiscardRetransmit) {
TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
QuicPacketSequenceNumber largest_observed;
QuicByteCount packet_size;
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _))
.WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size),
Return(true)));
- EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
+
QuicAckFrame frame = InitAckFrame(1, largest_observed);
NackPacket(largest_observed, &frame);
// The first nack should retransmit the largest observed packet.
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(1);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, _, packet_size - kQuicVersionSize,
NACK_RETRANSMISSION, _));
@@ -1992,13 +2028,17 @@ TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) {
}
// Ack 15, nack 1-14.
+ SequenceNumberSet lost_packets;
QuicAckFrame nack = InitAckFrame(15, 0);
for (int i = 1; i < 15; ++i) {
NackPacket(i, &nack);
+ lost_packets.insert(i);
}
// 14 packets have been NACK'd and lost. In TCP cubic, PRR limits
// the retransmission rate in the case of burst losses.
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1);
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14);
@@ -2359,8 +2399,12 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
EXPECT_TRUE(QuicConnectionPeer::IsRetransmission(
&connection_, rto_sequence_number));
// Once by explicit nack.
- EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(3);
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(rto_sequence_number);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
+ EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(rto_sequence_number, _)).Times(1);
EXPECT_CALL(*send_algorithm_,
OnPacketAbandoned(rto_sequence_number, _)).Times(1);
QuicPacketSequenceNumber nack_sequence_number = 0;
@@ -2371,12 +2415,11 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NACK_RETRANSMISSION, _))
.WillOnce(DoAll(SaveArg<1>(&nack_sequence_number), Return(true)));
QuicAckFrame ack = InitAckFrame(rto_sequence_number, 0);
- // Ack the retransmitted packet.
+ // Nack the retransmitted packet.
NackPacket(original_sequence_number, &ack);
NackPacket(rto_sequence_number, &ack);
- for (int i = 0; i < 3; i++) {
- ProcessAckPacket(&ack);
- }
+ ProcessAckPacket(&ack);
+
ASSERT_NE(0u, nack_sequence_number);
EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission(
&connection_, rto_sequence_number));
@@ -2873,6 +2916,10 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
// Ack the second packet, which will retransmit the first packet.
QuicAckFrame ack = InitAckFrame(2, 0);
NackPacket(1, &ack);
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(1);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1);
EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
@@ -2886,6 +2933,8 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
// and see if there is more data to send.
ack = InitAckFrame(3, 0);
NackPacket(1, &ack);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1);
ProcessAckPacket(&ack);
@@ -2898,6 +2947,8 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
// Send the same ack, but send both data and an ack together.
ack = InitAckFrame(3, 0);
NackPacket(1, &ack);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(
IgnoreResult(InvokeWithoutArgs(
&connection_,
@@ -2939,7 +2990,7 @@ TEST_P(QuicConnectionTest, SendWhenDisconnected) {
TEST_P(QuicConnectionTest, PublicReset) {
QuicPublicResetPacket header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = true;
header.public_header.version_flag = false;
header.rejected_sequence_number = 10101;
@@ -3149,7 +3200,7 @@ TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacket) {
framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED);
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.entropy_flag = false;
@@ -3187,7 +3238,7 @@ TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacketSocketBlocked) {
framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED);
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.entropy_flag = false;
@@ -3232,7 +3283,7 @@ TEST_P(QuicConnectionTest,
framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED);
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.entropy_flag = false;
@@ -3263,7 +3314,7 @@ TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) {
QUIC_VERSION_UNSUPPORTED);
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.entropy_flag = false;
@@ -3301,7 +3352,7 @@ TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) {
TEST_P(QuicConnectionTest, BadVersionNegotiation) {
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.entropy_flag = false;
@@ -3352,16 +3403,17 @@ TEST_P(QuicConnectionTest, CheckSendStats) {
QuicAckFrame nack_three = InitAckFrame(4, 0);
NackPacket(3, &nack_three);
NackPacket(1, &nack_three);
- QuicFrame frame(&nack_three);
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(1);
+ lost_packets.insert(3);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
- EXPECT_CALL(visitor_, OnCanWrite()).Times(4);
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2);
+ EXPECT_CALL(visitor_, OnCanWrite()).Times(2);
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
-
- ProcessFramePacket(frame);
- ProcessFramePacket(frame);
- ProcessFramePacket(frame);
+ ProcessAckPacket(&nack_three);
EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce(
Return(QuicTime::Delta::Zero()));
@@ -3428,7 +3480,7 @@ TEST_P(QuicConnectionTest, TestFecGroupLimits) {
TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) {
// Construct a packet with stream frame and connection close frame.
- header_.public_header.guid = guid_;
+ header_.public_header.connection_id = connection_id_;
header_.packet_sequence_number = 1;
header_.public_header.reset_flag = false;
header_.public_header.version_flag = false;
@@ -3460,7 +3512,7 @@ TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) {
TEST_P(QuicConnectionTest, DontProcessStreamFrameAndIgnoreCloseFrame) {
// Construct a packet with stream frame, ack frame,
// and connection close frame.
- header_.public_header.guid = guid_;
+ header_.public_header.connection_id = connection_id_;
header_.packet_sequence_number = 1;
header_.public_header.reset_flag = false;
header_.public_header.version_flag = false;
@@ -3586,8 +3638,12 @@ TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
// which we registered to be notified about.
QuicAckFrame frame = InitAckFrame(3, 0);
NackPacket(1, &frame);
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _));
- EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _));
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(1);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _));
ProcessAckPacket(&frame);
}
@@ -3598,19 +3654,21 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
EXPECT_CALL(*delegate, OnAckNotification()).Times(1);
- // In total expect ACKs for all 4 packets.
- EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(2);
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(4);
-
// Send four packets, and register to be notified on ACK of packet 2.
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get());
connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL);
connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL);
- // Now we receive ACK for packets 1, 3, and 4, which invokes fast retransmit.
+ // Now we receive ACK for packets 1, 3, and 4 and lose 2.
QuicAckFrame frame = InitAckFrame(4, 0);
NackPacket(2, &frame);
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(2);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(lost_packets));
+ EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3);
EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
@@ -3618,6 +3676,10 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
// Now we get an ACK for packet 5 (retransmitted packet 2), which should
// trigger the callback.
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _))
+ .WillRepeatedly(Return(SequenceNumberSet()));
+ EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _));
QuicAckFrame second_ack_frame = InitAckFrame(5, 0);
ProcessAckPacket(&second_ack_frame);
}
@@ -3653,7 +3715,7 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
frames.push_back(QuicFrame(&frame1_));
QuicPacketHeader ack_header;
- ack_header.public_header.guid = guid_;
+ ack_header.public_header.connection_id = connection_id_;
ack_header.public_header.reset_flag = false;
ack_header.public_header.version_flag = false;
ack_header.entropy_flag = !kEntropyFlag;
@@ -3738,10 +3800,10 @@ TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) {
TEST_P(QuicConnectionTest, Pacing) {
ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
- TestConnection server(guid_, IPEndPoint(), helper_.get(), writer_.get(),
- true, version());
- TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(),
- false, version());
+ TestConnection server(connection_id_, IPEndPoint(), helper_.get(),
+ writer_.get(), true, version());
+ TestConnection client(connection_id_, IPEndPoint(), helper_.get(),
+ writer_.get(), false, version());
EXPECT_TRUE(client.sent_packet_manager().using_pacing());
EXPECT_FALSE(server.sent_packet_manager().using_pacing());
}
diff --git a/net/quic/quic_crypto_client_stream.cc b/net/quic/quic_crypto_client_stream.cc
index 7f0712c..689b5d6 100644
--- a/net/quic/quic_crypto_client_stream.cc
+++ b/net/quic/quic_crypto_client_stream.cc
@@ -209,7 +209,7 @@ void QuicCryptoClientStream::DoHandshakeLoop(
session()->config()->ToHandshakeMessage(&out);
error = crypto_config_->FillClientHello(
server_hostname_,
- session()->connection()->guid(),
+ session()->connection()->connection_id(),
session()->connection()->supported_versions().front(),
cached,
session()->connection()->clock()->WallNow(),
@@ -364,7 +364,7 @@ void QuicCryptoClientStream::DoHandshakeLoop(
return;
}
error = crypto_config_->ProcessServerHello(
- *in, session()->connection()->guid(),
+ *in, session()->connection()->connection_id(),
session()->connection()->server_supported_versions(),
cached, &crypto_negotiated_params_, &error_details);
diff --git a/net/quic/quic_crypto_server_stream.cc b/net/quic/quic_crypto_server_stream.cc
index e317465..879bca8 100644
--- a/net/quic/quic_crypto_server_stream.cc
+++ b/net/quic/quic_crypto_server_stream.cc
@@ -165,7 +165,7 @@ QuicErrorCode QuicCryptoServerStream::ProcessClientHello(
string* error_details) {
return crypto_config_.ProcessClientHello(
result,
- session()->connection()->guid(),
+ session()->connection()->connection_id(),
session()->connection()->peer_address(),
session()->connection()->version(),
session()->connection()->supported_versions(),
diff --git a/net/quic/quic_data_stream_test.cc b/net/quic/quic_data_stream_test.cc
index e767a46..2f7ef5c 100644
--- a/net/quic/quic_data_stream_test.cc
+++ b/net/quic/quic_data_stream_test.cc
@@ -28,7 +28,7 @@ namespace net {
namespace test {
namespace {
-const QuicGuid kStreamId = 3;
+const QuicConnectionId kStreamId = 3;
const bool kIsServer = true;
const bool kShouldProcessData = true;
diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
index 28491db..8dddbf4 100644
--- a/net/quic/quic_framer.cc
+++ b/net/quic/quic_framer.cc
@@ -38,8 +38,8 @@ const QuicPacketSequenceNumber k2ByteSequenceNumberMask =
const QuicPacketSequenceNumber k1ByteSequenceNumberMask =
GG_UINT64_C(0x00000000000000FF);
-const QuicGuid k1ByteGuidMask = GG_UINT64_C(0x00000000000000FF);
-const QuicGuid k4ByteGuidMask = GG_UINT64_C(0x00000000FFFFFFFF);
+const QuicConnectionId k1ByteConnectionIdMask = GG_UINT64_C(0x00000000000000FF);
+const QuicConnectionId k4ByteConnectionIdMask = GG_UINT64_C(0x00000000FFFFFFFF);
// Number of bits the sequence number length bits are shifted from the right
// edge of the public header.
@@ -163,7 +163,7 @@ QuicFramer::QuicFramer(const QuicVersionVector& supported_versions,
entropy_calculator_(NULL),
error_(QUIC_NO_ERROR),
last_sequence_number_(0),
- last_serialized_guid_(0),
+ last_serialized_connection_id_(0),
supported_versions_(supported_versions),
alternative_decrypter_latch_(false),
is_server_(is_server),
@@ -270,7 +270,7 @@ size_t QuicFramer::GetStreamOffsetSize(QuicStreamOffset offset) {
// static
size_t QuicFramer::GetVersionNegotiationPacketSize(size_t number_versions) {
- return kPublicFlagsSize + PACKET_8BYTE_GUID +
+ return kPublicFlagsSize + PACKET_8BYTE_CONNECTION_ID +
number_versions * kQuicVersionSize;
}
@@ -455,7 +455,7 @@ SerializedPacket QuicFramer::BuildDataPacket(
// length, even though they're typically slightly shorter.
DCHECK_LE(len, packet_size);
QuicPacket* packet = QuicPacket::NewDataPacket(
- writer.take(), len, true, header.public_header.guid_length,
+ writer.take(), len, true, header.public_header.connection_id_length,
header.public_header.version_flag,
header.public_header.sequence_number_length);
@@ -493,7 +493,7 @@ SerializedPacket QuicFramer::BuildFecPacket(const QuicPacketHeader& header,
header.packet_sequence_number,
header.public_header.sequence_number_length,
QuicPacket::NewFecPacket(writer.take(), len, true,
- header.public_header.guid_length,
+ header.public_header.connection_id_length,
header.public_header.version_flag,
header.public_header.sequence_number_length),
GetPacketEntropyHash(header), NULL);
@@ -519,16 +519,17 @@ QuicEncryptedPacket* QuicFramer::BuildPublicResetPacket(
}
const QuicData& reset_serialized = reset.GetSerialized();
- size_t len = kPublicFlagsSize + PACKET_8BYTE_GUID + reset_serialized.length();
+ size_t len =
+ kPublicFlagsSize + PACKET_8BYTE_CONNECTION_ID + reset_serialized.length();
QuicDataWriter writer(len);
uint8 flags = static_cast<uint8>(PACKET_PUBLIC_FLAGS_RST |
- PACKET_PUBLIC_FLAGS_8BYTE_GUID);
+ PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID);
if (!writer.WriteUInt8(flags)) {
return NULL;
}
- if (!writer.WriteUInt64(packet.public_header.guid)) {
+ if (!writer.WriteUInt64(packet.public_header.connection_id)) {
return NULL;
}
@@ -547,12 +548,12 @@ QuicEncryptedPacket* QuicFramer::BuildVersionNegotiationPacket(
QuicDataWriter writer(len);
uint8 flags = static_cast<uint8>(PACKET_PUBLIC_FLAGS_VERSION |
- PACKET_PUBLIC_FLAGS_8BYTE_GUID);
+ PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID);
if (!writer.WriteUInt8(flags)) {
return NULL;
}
- if (!writer.WriteUInt64(header.guid)) {
+ if (!writer.WriteUInt64(header.connection_id)) {
return NULL;
}
@@ -767,38 +768,44 @@ bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header,
GetSequenceNumberFlags(header.public_header.sequence_number_length)
<< kPublicHeaderSequenceNumberShift;
- switch (header.public_header.guid_length) {
- case PACKET_0BYTE_GUID:
- if (!writer->WriteUInt8(public_flags | PACKET_PUBLIC_FLAGS_0BYTE_GUID)) {
+ switch (header.public_header.connection_id_length) {
+ case PACKET_0BYTE_CONNECTION_ID:
+ if (!writer->WriteUInt8(
+ public_flags | PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID)) {
return false;
}
break;
- case PACKET_1BYTE_GUID:
- if (!writer->WriteUInt8(public_flags | PACKET_PUBLIC_FLAGS_1BYTE_GUID)) {
+ case PACKET_1BYTE_CONNECTION_ID:
+ if (!writer->WriteUInt8(
+ public_flags | PACKET_PUBLIC_FLAGS_1BYTE_CONNECTION_ID)) {
return false;
}
- if (!writer->WriteUInt8(header.public_header.guid & k1ByteGuidMask)) {
+ if (!writer->WriteUInt8(
+ header.public_header.connection_id & k1ByteConnectionIdMask)) {
return false;
}
break;
- case PACKET_4BYTE_GUID:
- if (!writer->WriteUInt8(public_flags | PACKET_PUBLIC_FLAGS_4BYTE_GUID)) {
+ case PACKET_4BYTE_CONNECTION_ID:
+ if (!writer->WriteUInt8(
+ public_flags | PACKET_PUBLIC_FLAGS_4BYTE_CONNECTION_ID)) {
return false;
}
- if (!writer->WriteUInt32(header.public_header.guid & k4ByteGuidMask)) {
+ if (!writer->WriteUInt32(
+ header.public_header.connection_id & k4ByteConnectionIdMask)) {
return false;
}
break;
- case PACKET_8BYTE_GUID:
- if (!writer->WriteUInt8(public_flags | PACKET_PUBLIC_FLAGS_8BYTE_GUID)) {
+ case PACKET_8BYTE_CONNECTION_ID:
+ if (!writer->WriteUInt8(
+ public_flags | PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID)) {
return false;
}
- if (!writer->WriteUInt64(header.public_header.guid)) {
+ if (!writer->WriteUInt64(header.public_header.connection_id)) {
return false;
}
break;
}
- last_serialized_guid_ = header.public_header.guid;
+ last_serialized_connection_id_ = header.public_header.connection_id;
if (header.public_header.version_flag) {
DCHECK(!is_server_);
@@ -888,46 +895,49 @@ bool QuicFramer::ProcessPublicHeader(
return false;
}
- switch (public_flags & PACKET_PUBLIC_FLAGS_8BYTE_GUID) {
- case PACKET_PUBLIC_FLAGS_8BYTE_GUID:
- if (!reader_->ReadUInt64(&public_header->guid)) {
- set_detailed_error("Unable to read GUID.");
+ switch (public_flags & PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID) {
+ case PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID:
+ if (!reader_->ReadUInt64(&public_header->connection_id)) {
+ set_detailed_error("Unable to read ConnectionId.");
return false;
}
- public_header->guid_length = PACKET_8BYTE_GUID;
+ public_header->connection_id_length = PACKET_8BYTE_CONNECTION_ID;
break;
- case PACKET_PUBLIC_FLAGS_4BYTE_GUID:
- // If the guid is truncated, expect to read the last serialized guid.
- if (!reader_->ReadBytes(&public_header->guid, PACKET_4BYTE_GUID)) {
- set_detailed_error("Unable to read GUID.");
+ case PACKET_PUBLIC_FLAGS_4BYTE_CONNECTION_ID:
+ // If the connection_id is truncated, expect to read the last serialized
+ // connection_id.
+ if (!reader_->ReadBytes(&public_header->connection_id,
+ PACKET_4BYTE_CONNECTION_ID)) {
+ set_detailed_error("Unable to read ConnectionId.");
return false;
}
- if ((public_header->guid & k4ByteGuidMask) !=
- (last_serialized_guid_ & k4ByteGuidMask)) {
- set_detailed_error(
- "Truncated 4 byte GUID does not match previous guid.");
+ if ((public_header->connection_id & k4ByteConnectionIdMask) !=
+ (last_serialized_connection_id_ & k4ByteConnectionIdMask)) {
+ set_detailed_error("Truncated 4 byte ConnectionId does not match "
+ "previous connection_id.");
return false;
}
- public_header->guid_length = PACKET_4BYTE_GUID;
- public_header->guid = last_serialized_guid_;
+ public_header->connection_id_length = PACKET_4BYTE_CONNECTION_ID;
+ public_header->connection_id = last_serialized_connection_id_;
break;
- case PACKET_PUBLIC_FLAGS_1BYTE_GUID:
- if (!reader_->ReadBytes(&public_header->guid, PACKET_1BYTE_GUID)) {
- set_detailed_error("Unable to read GUID.");
+ case PACKET_PUBLIC_FLAGS_1BYTE_CONNECTION_ID:
+ if (!reader_->ReadBytes(&public_header->connection_id,
+ PACKET_1BYTE_CONNECTION_ID)) {
+ set_detailed_error("Unable to read ConnectionId.");
return false;
}
- if ((public_header->guid & k1ByteGuidMask) !=
- (last_serialized_guid_ & k1ByteGuidMask)) {
- set_detailed_error(
- "Truncated 1 byte GUID does not match previous guid.");
+ if ((public_header->connection_id & k1ByteConnectionIdMask) !=
+ (last_serialized_connection_id_ & k1ByteConnectionIdMask)) {
+ set_detailed_error("Truncated 1 byte ConnectionId does not match "
+ "previous connection_id.");
return false;
}
- public_header->guid_length = PACKET_1BYTE_GUID;
- public_header->guid = last_serialized_guid_;
+ public_header->connection_id_length = PACKET_1BYTE_CONNECTION_ID;
+ public_header->connection_id = last_serialized_connection_id_;
break;
- case PACKET_PUBLIC_FLAGS_0BYTE_GUID:
- public_header->guid_length = PACKET_0BYTE_GUID;
- public_header->guid = last_serialized_guid_;
+ case PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID:
+ public_header->connection_id_length = PACKET_0BYTE_CONNECTION_ID;
+ public_header->connection_id = last_serialized_connection_id_;
break;
}
@@ -1688,13 +1698,13 @@ bool QuicFramer::ProcessBlockedFrame(QuicBlockedFrame* frame) {
// static
StringPiece QuicFramer::GetAssociatedDataFromEncryptedPacket(
const QuicEncryptedPacket& encrypted,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool includes_version,
QuicSequenceNumberLength sequence_number_length) {
- return StringPiece(encrypted.data() + kStartOfHashData,
- GetStartOfEncryptedData(
- guid_length, includes_version, sequence_number_length)
- - kStartOfHashData);
+ return StringPiece(
+ encrypted.data() + kStartOfHashData, GetStartOfEncryptedData(
+ connection_id_length, includes_version, sequence_number_length)
+ - kStartOfHashData);
}
void QuicFramer::SetDecrypter(QuicDecrypter* decrypter) {
@@ -1791,7 +1801,7 @@ bool QuicFramer::DecryptPayload(const QuicPacketHeader& header,
header.packet_sequence_number,
GetAssociatedDataFromEncryptedPacket(
packet,
- header.public_header.guid_length,
+ header.public_header.connection_id_length,
header.public_header.version_flag,
header.public_header.sequence_number_length),
encrypted));
@@ -1800,7 +1810,7 @@ bool QuicFramer::DecryptPayload(const QuicPacketHeader& header,
header.packet_sequence_number,
GetAssociatedDataFromEncryptedPacket(
packet,
- header.public_header.guid_length,
+ header.public_header.connection_id_length,
header.public_header.version_flag,
header.public_header.sequence_number_length),
encrypted));
diff --git a/net/quic/quic_framer.h b/net/quic/quic_framer.h
index 6704602..d75bb2a 100644
--- a/net/quic/quic_framer.h
+++ b/net/quic/quic_framer.h
@@ -289,7 +289,7 @@ class NET_EXPORT_PRIVATE QuicFramer {
// stringpiece.
static base::StringPiece GetAssociatedDataFromEncryptedPacket(
const QuicEncryptedPacket& encrypted,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool includes_version,
QuicSequenceNumberLength sequence_number_length);
@@ -492,7 +492,7 @@ class NET_EXPORT_PRIVATE QuicFramer {
// Updated by ProcessPacketHeader when it succeeds.
QuicPacketSequenceNumber last_sequence_number_;
// Updated by WritePacketHeader.
- QuicGuid last_serialized_guid_;
+ QuicConnectionId last_serialized_connection_id_;
// Buffer containing decrypted payload data during parsing.
scoped_ptr<QuicData> decrypted_;
// Version of the protocol being used.
diff --git a/net/quic/quic_framer_test.cc b/net/quic/quic_framer_test.cc
index 870eda0..7d3fd18 100644
--- a/net/quic/quic_framer_test.cc
+++ b/net/quic/quic_framer_test.cc
@@ -39,10 +39,10 @@ namespace test {
const QuicPacketSequenceNumber kEpoch = GG_UINT64_C(1) << 48;
const QuicPacketSequenceNumber kMask = kEpoch - 1;
-// Index into the guid offset in the header.
-const size_t kGuidOffset = kPublicFlagsSize;
+// Index into the connection_id offset in the header.
+const size_t kConnectionIdOffset = kPublicFlagsSize;
// Index into the version string in the header. (if present).
-const size_t kVersionOffset = kGuidOffset + PACKET_8BYTE_GUID;
+const size_t kVersionOffset = kConnectionIdOffset + PACKET_8BYTE_CONNECTION_ID;
// Size in bytes of the stream frame fields for an arbitrary StreamID and
// offset and the last frame in a packet.
@@ -51,40 +51,42 @@ size_t GetMinStreamFrameSize(QuicVersion version) {
}
// Index into the sequence number offset in the header.
-size_t GetSequenceNumberOffset(QuicGuidLength guid_length,
+size_t GetSequenceNumberOffset(QuicConnectionIdLength connection_id_length,
bool include_version) {
- return kGuidOffset + guid_length +
+ return kConnectionIdOffset + connection_id_length +
(include_version ? kQuicVersionSize : 0);
}
size_t GetSequenceNumberOffset(bool include_version) {
- return GetSequenceNumberOffset(PACKET_8BYTE_GUID, include_version);
+ return GetSequenceNumberOffset(PACKET_8BYTE_CONNECTION_ID, include_version);
}
// Index into the private flags offset in the data packet header.
-size_t GetPrivateFlagsOffset(QuicGuidLength guid_length, bool include_version) {
- return GetSequenceNumberOffset(guid_length, include_version) +
+size_t GetPrivateFlagsOffset(QuicConnectionIdLength connection_id_length,
+ bool include_version) {
+ return GetSequenceNumberOffset(connection_id_length, include_version) +
PACKET_6BYTE_SEQUENCE_NUMBER;
}
size_t GetPrivateFlagsOffset(bool include_version) {
- return GetPrivateFlagsOffset(PACKET_8BYTE_GUID, include_version);
+ return GetPrivateFlagsOffset(PACKET_8BYTE_CONNECTION_ID, include_version);
}
size_t GetPrivateFlagsOffset(bool include_version,
QuicSequenceNumberLength sequence_number_length) {
- return GetSequenceNumberOffset(PACKET_8BYTE_GUID, include_version) +
+ return GetSequenceNumberOffset(PACKET_8BYTE_CONNECTION_ID, include_version) +
sequence_number_length;
}
// Index into the fec group offset in the header.
-size_t GetFecGroupOffset(QuicGuidLength guid_length, bool include_version) {
- return GetPrivateFlagsOffset(guid_length, include_version) +
+size_t GetFecGroupOffset(QuicConnectionIdLength connection_id_length,
+ bool include_version) {
+ return GetPrivateFlagsOffset(connection_id_length, include_version) +
kPrivateFlagsSize;
}
size_t GetFecGroupOffset(bool include_version) {
- return GetPrivateFlagsOffset(PACKET_8BYTE_GUID, include_version) +
+ return GetPrivateFlagsOffset(PACKET_8BYTE_CONNECTION_ID, include_version) +
kPrivateFlagsSize;
}
@@ -95,15 +97,15 @@ size_t GetFecGroupOffset(bool include_version,
}
// Index into the message tag of the public reset packet.
-// Public resets always have full guids.
+// Public resets always have full connection_ids.
const size_t kPublicResetPacketMessageTagOffset =
- kGuidOffset + PACKET_8BYTE_GUID;
+ kConnectionIdOffset + PACKET_8BYTE_CONNECTION_ID;
// TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
// Index into the nonce proof of the public reset packet.
-// Public resets always have full guids.
+// Public resets always have full connection_ids.
const size_t kPublicResetPacketNonceProofOffset =
- kGuidOffset + PACKET_8BYTE_GUID;
+ kConnectionIdOffset + PACKET_8BYTE_CONNECTION_ID;
// TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
// Index into the rejected sequence number of the public reset packet.
@@ -414,18 +416,18 @@ class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> {
return false;
}
if (QuicFramer::GetAssociatedDataFromEncryptedPacket(
- encrypted, PACKET_8BYTE_GUID,
+ encrypted, PACKET_8BYTE_CONNECTION_ID,
includes_version, PACKET_6BYTE_SEQUENCE_NUMBER) !=
decrypter_->associated_data_) {
LOG(ERROR) << "Decrypted incorrect associated data. expected "
<< QuicFramer::GetAssociatedDataFromEncryptedPacket(
- encrypted, PACKET_8BYTE_GUID,
- includes_version, PACKET_6BYTE_SEQUENCE_NUMBER)
+ encrypted, PACKET_8BYTE_CONNECTION_ID,
+ includes_version, PACKET_6BYTE_SEQUENCE_NUMBER)
<< " actual: " << decrypter_->associated_data_;
return false;
}
StringPiece ciphertext(encrypted.AsStringPiece().substr(
- GetStartOfEncryptedData(PACKET_8BYTE_GUID, includes_version,
+ GetStartOfEncryptedData(PACKET_8BYTE_CONNECTION_ID, includes_version,
PACKET_6BYTE_SEQUENCE_NUMBER)));
if (ciphertext != decrypter_->ciphertext_) {
LOG(ERROR) << "Decrypted incorrect ciphertext data. expected "
@@ -473,7 +475,7 @@ class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, include_version,
PACKET_6BYTE_SEQUENCE_NUMBER,
NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_STREAM_DATA);
@@ -617,9 +619,9 @@ TEST_P(QuicFramerTest, EmptyPacket) {
TEST_P(QuicFramerTest, LargePacket) {
unsigned char packet[kMaxPacketSize + 1] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -630,10 +632,10 @@ TEST_P(QuicFramerTest, LargePacket) {
};
memset(packet + GetPacketHeaderSize(
- PACKET_8BYTE_GUID, !kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 0,
kMaxPacketSize - GetPacketHeaderSize(
- PACKET_8BYTE_GUID, !kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + 1);
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
@@ -642,16 +644,16 @@ TEST_P(QuicFramerTest, LargePacket) {
ASSERT_TRUE(visitor_.header_.get());
// Make sure we've parsed the packet header, so we can send an error.
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
// Make sure the correct error is propagated.
EXPECT_EQ(QUIC_PACKET_TOO_LARGE, framer_.error());
}
TEST_P(QuicFramerTest, PacketHeader) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -666,7 +668,7 @@ TEST_P(QuicFramerTest, PacketHeader) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -679,14 +681,14 @@ TEST_P(QuicFramerTest, PacketHeader) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
} else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
} else if (i < GetPrivateFlagsOffset(!kIncludeVersion)) {
expected_error = "Unable to read sequence number.";
} else if (i < GetFecGroupOffset(!kIncludeVersion)) {
@@ -698,14 +700,14 @@ TEST_P(QuicFramerTest, PacketHeader) {
}
}
-TEST_P(QuicFramerTest, PacketHeaderWith4ByteGuid) {
- QuicFramerPeer::SetLastSerializedGuid(&framer_,
- GG_UINT64_C(0xFEDCBA9876543210));
+TEST_P(QuicFramerTest, PacketHeaderWith4ByteConnectionId) {
+ QuicFramerPeer::SetLastSerializedConnectionId(
+ &framer_, GG_UINT64_C(0xFEDCBA9876543210));
unsigned char packet[] = {
- // public flags (4 byte guid)
+ // public flags (4 byte connection_id)
0x38,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
// packet sequence number
0xBC, 0x9A, 0x78, 0x56,
@@ -719,7 +721,7 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteGuid) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -732,19 +734,20 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteGuid) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_4BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_4BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
- } else if (i < GetSequenceNumberOffset(PACKET_4BYTE_GUID,
+ } else if (i < GetSequenceNumberOffset(PACKET_4BYTE_CONNECTION_ID,
!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
- } else if (i < GetPrivateFlagsOffset(PACKET_4BYTE_GUID,
+ expected_error = "Unable to read ConnectionId.";
+ } else if (i < GetPrivateFlagsOffset(PACKET_4BYTE_CONNECTION_ID,
!kIncludeVersion)) {
expected_error = "Unable to read sequence number.";
- } else if (i < GetFecGroupOffset(PACKET_4BYTE_GUID, !kIncludeVersion)) {
+ } else if (i < GetFecGroupOffset(PACKET_4BYTE_CONNECTION_ID,
+ !kIncludeVersion)) {
expected_error = "Unable to read private flags.";
} else {
expected_error = "Unable to read first fec protected packet offset.";
@@ -753,14 +756,14 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteGuid) {
}
}
-TEST_P(QuicFramerTest, PacketHeader1ByteGuid) {
- QuicFramerPeer::SetLastSerializedGuid(&framer_,
- GG_UINT64_C(0xFEDCBA9876543210));
+TEST_P(QuicFramerTest, PacketHeader1ByteConnectionId) {
+ QuicFramerPeer::SetLastSerializedConnectionId(
+ &framer_, GG_UINT64_C(0xFEDCBA9876543210));
unsigned char packet[] = {
- // public flags (1 byte guid)
+ // public flags (1 byte connection_id)
0x34,
- // guid
+ // connection_id
0x10,
// packet sequence number
0xBC, 0x9A, 0x78, 0x56,
@@ -774,7 +777,7 @@ TEST_P(QuicFramerTest, PacketHeader1ByteGuid) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -787,18 +790,20 @@ TEST_P(QuicFramerTest, PacketHeader1ByteGuid) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_1BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_1BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
- } else if (i < GetSequenceNumberOffset(PACKET_1BYTE_GUID,
+ } else if (i < GetSequenceNumberOffset(PACKET_1BYTE_CONNECTION_ID,
!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
- } else if (i < GetPrivateFlagsOffset(PACKET_1BYTE_GUID, !kIncludeVersion)) {
+ expected_error = "Unable to read ConnectionId.";
+ } else if (i < GetPrivateFlagsOffset(PACKET_1BYTE_CONNECTION_ID,
+ !kIncludeVersion)) {
expected_error = "Unable to read sequence number.";
- } else if (i < GetFecGroupOffset(PACKET_1BYTE_GUID, !kIncludeVersion)) {
+ } else if (i < GetFecGroupOffset(PACKET_1BYTE_CONNECTION_ID,
+ !kIncludeVersion)) {
expected_error = "Unable to read private flags.";
} else {
expected_error = "Unable to read first fec protected packet offset.";
@@ -807,14 +812,14 @@ TEST_P(QuicFramerTest, PacketHeader1ByteGuid) {
}
}
-TEST_P(QuicFramerTest, PacketHeaderWith0ByteGuid) {
- QuicFramerPeer::SetLastSerializedGuid(&framer_,
- GG_UINT64_C(0xFEDCBA9876543210));
+TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) {
+ QuicFramerPeer::SetLastSerializedConnectionId(
+ &framer_, GG_UINT64_C(0xFEDCBA9876543210));
unsigned char packet[] = {
- // public flags (0 byte guid)
+ // public flags (0 byte connection_id)
0x30,
- // guid
+ // connection_id
// packet sequence number
0xBC, 0x9A, 0x78, 0x56,
0x34, 0x12,
@@ -827,7 +832,7 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteGuid) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -840,18 +845,20 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteGuid) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_0BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_0BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
- } else if (i < GetSequenceNumberOffset(PACKET_0BYTE_GUID,
+ } else if (i < GetSequenceNumberOffset(PACKET_0BYTE_CONNECTION_ID,
!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
- } else if (i < GetPrivateFlagsOffset(PACKET_0BYTE_GUID, !kIncludeVersion)) {
+ expected_error = "Unable to read ConnectionId.";
+ } else if (i < GetPrivateFlagsOffset(PACKET_0BYTE_CONNECTION_ID,
+ !kIncludeVersion)) {
expected_error = "Unable to read sequence number.";
- } else if (i < GetFecGroupOffset(PACKET_0BYTE_GUID, !kIncludeVersion)) {
+ } else if (i < GetFecGroupOffset(PACKET_0BYTE_CONNECTION_ID,
+ !kIncludeVersion)) {
expected_error = "Unable to read private flags.";
} else {
expected_error = "Unable to read first fec protected packet offset.";
@@ -864,7 +871,7 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) {
unsigned char packet[] = {
// public flags (version)
0x3D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -881,7 +888,7 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_TRUE(visitor_.header_->public_header.version_flag);
EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]);
@@ -895,14 +902,14 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_8BYTE_GUID, kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
} else if (i < kVersionOffset) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
} else if (i < GetSequenceNumberOffset(kIncludeVersion)) {
expected_error = "Unable to read protocol version.";
} else if (i < GetPrivateFlagsOffset(kIncludeVersion)) {
@@ -921,9 +928,9 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) {
GG_UINT64_C(0x123456789ABA));
unsigned char packet[] = {
- // public flags (8 byte guid and 4 byte sequence number)
+ // public flags (8 byte connection_id and 4 byte sequence number)
0x2C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -937,7 +944,7 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -950,14 +957,14 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
} else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
} else if (i < GetPrivateFlagsOffset(!kIncludeVersion,
PACKET_4BYTE_SEQUENCE_NUMBER)) {
expected_error = "Unable to read sequence number.";
@@ -976,9 +983,9 @@ TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) {
GG_UINT64_C(0x123456789ABA));
unsigned char packet[] = {
- // public flags (8 byte guid and 2 byte sequence number)
+ // public flags (8 byte connection_id and 2 byte sequence number)
0x1C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -992,7 +999,7 @@ TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -1005,14 +1012,14 @@ TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
} else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
} else if (i < GetPrivateFlagsOffset(!kIncludeVersion,
PACKET_2BYTE_SEQUENCE_NUMBER)) {
expected_error = "Unable to read sequence number.";
@@ -1031,9 +1038,9 @@ TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) {
GG_UINT64_C(0x123456789ABA));
unsigned char packet[] = {
- // public flags (8 byte guid and 1 byte sequence number)
+ // public flags (8 byte connection_id and 1 byte sequence number)
0x0C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1047,7 +1054,7 @@ TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) {
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_FALSE(visitor_.header_->fec_flag);
@@ -1060,14 +1067,14 @@ TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) {
// Now test framing boundaries
for (size_t i = 0;
- i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
++i) {
string expected_error;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
} else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
} else if (i < GetPrivateFlagsOffset(!kIncludeVersion,
PACKET_1BYTE_SEQUENCE_NUMBER)) {
expected_error = "Unable to read sequence number.";
@@ -1085,7 +1092,7 @@ TEST_P(QuicFramerTest, InvalidPublicFlag) {
unsigned char packet[] = {
// public flags, unknown flag at bit 6
0x40,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1106,9 +1113,9 @@ TEST_P(QuicFramerTest, InvalidPublicFlag) {
TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) {
unsigned char packet[] = {
- // public flags (8 byte guid and version flag and an unknown flag)
+ // public flags (8 byte connection_id and version flag and an unknown flag)
0x4D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -1131,9 +1138,9 @@ TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) {
TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) {
unsigned char packet[] = {
- // public flags (8 byte guid, version flag and an unknown flag)
+ // public flags (8 byte connection_id, version flag and an unknown flag)
0x7D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -1158,9 +1165,9 @@ TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) {
TEST_P(QuicFramerTest, InvalidPrivateFlag) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1181,9 +1188,9 @@ TEST_P(QuicFramerTest, InvalidPrivateFlag) {
TEST_P(QuicFramerTest, InvalidFECGroupOffset) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1203,9 +1210,9 @@ TEST_P(QuicFramerTest, InvalidFECGroupOffset) {
TEST_P(QuicFramerTest, PaddingFrame) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1243,16 +1250,16 @@ TEST_P(QuicFramerTest, PaddingFrame) {
// A packet with no frames is not acceptable.
CheckProcessingFails(
packet,
- GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
"Packet has no frames.", QUIC_MISSING_PAYLOAD);
}
TEST_P(QuicFramerTest, StreamFrame) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1298,9 +1305,9 @@ TEST_P(QuicFramerTest, StreamFrame) {
TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1347,9 +1354,9 @@ TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) {
TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1396,9 +1403,9 @@ TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) {
TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1445,9 +1452,9 @@ TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) {
TEST_P(QuicFramerTest, StreamFrameWithVersion) {
unsigned char packet[] = {
- // public flags (version, 8 byte guid)
+ // public flags (version, 8 byte connection_id)
0x3D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -1499,9 +1506,9 @@ TEST_P(QuicFramerTest, RejectPacket) {
visitor_.accept_packet_ = false;
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1540,9 +1547,9 @@ TEST_P(QuicFramerTest, RejectPublicHeader) {
visitor_.accept_public_header_ = false;
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
};
@@ -1573,7 +1580,7 @@ TEST_P(QuicFramerTest, RevivedStreamFrame) {
};
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = true;
@@ -1590,7 +1597,7 @@ TEST_P(QuicFramerTest, RevivedStreamFrame) {
ASSERT_EQ(1, visitor_.revived_packets_);
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.header_->public_header.guid);
+ visitor_.header_->public_header.connection_id);
EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
EXPECT_FALSE(visitor_.header_->public_header.version_flag);
EXPECT_TRUE(visitor_.header_->fec_flag);
@@ -1613,9 +1620,9 @@ TEST_P(QuicFramerTest, RevivedStreamFrame) {
TEST_P(QuicFramerTest, StreamFrameInFecGroup) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1650,8 +1657,10 @@ TEST_P(QuicFramerTest, StreamFrameInFecGroup) {
EXPECT_EQ(IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
EXPECT_EQ(GG_UINT64_C(0x341256789ABA),
visitor_.header_->fec_group);
- const size_t fec_offset = GetStartOfFecProtectedData(
- PACKET_8BYTE_GUID, !kIncludeVersion, PACKET_6BYTE_SEQUENCE_NUMBER);
+ const size_t fec_offset =
+ GetStartOfFecProtectedData(PACKET_8BYTE_CONNECTION_ID,
+ !kIncludeVersion,
+ PACKET_6BYTE_SEQUENCE_NUMBER);
EXPECT_EQ(
string(AsChars(packet) + fec_offset, arraysize(packet) - fec_offset),
visitor_.fec_protected_payload_);
@@ -1671,9 +1680,9 @@ TEST_P(QuicFramerTest, AckFrameV14) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1762,7 +1771,7 @@ TEST_P(QuicFramerTest, AckFrameV14) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_ACK_DATA);
}
@@ -1774,9 +1783,9 @@ TEST_P(QuicFramerTest, AckFrame15) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1871,7 +1880,7 @@ TEST_P(QuicFramerTest, AckFrame15) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_ACK_DATA);
}
@@ -1883,9 +1892,9 @@ TEST_P(QuicFramerTest, AckFrame) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -1966,7 +1975,7 @@ TEST_P(QuicFramerTest, AckFrame) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_ACK_DATA);
}
@@ -1978,9 +1987,9 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2070,7 +2079,7 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_ACK_DATA);
}
@@ -2082,9 +2091,9 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets15) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2186,7 +2195,7 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets15) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_ACK_DATA);
}
@@ -2197,9 +2206,9 @@ TEST_P(QuicFramerTest, AckFrameNoNacks) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2252,9 +2261,9 @@ TEST_P(QuicFramerTest, AckFrameNoNacks15) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2314,9 +2323,9 @@ TEST_P(QuicFramerTest, AckFrame500Nacks) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2389,9 +2398,9 @@ TEST_P(QuicFramerTest, AckFrame500Nacks15) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2471,9 +2480,9 @@ TEST_P(QuicFramerTest, AckFrame500NacksV14) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2550,9 +2559,9 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2593,7 +2602,7 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
}
@@ -2604,9 +2613,9 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameTCPV14) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2651,7 +2660,7 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameTCPV14) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
}
@@ -2662,9 +2671,9 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrival) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2744,7 +2753,7 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrival) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
}
@@ -2755,9 +2764,9 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrivalV14) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2841,7 +2850,7 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrivalV14) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
}
@@ -2849,9 +2858,9 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrivalV14) {
TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2893,7 +2902,7 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
}
@@ -2901,9 +2910,9 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) {
TEST_P(QuicFramerTest, CongestionFeedbackFrameInvalidFeedback) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2929,9 +2938,9 @@ TEST_P(QuicFramerTest, StopWaitingFrame) {
return;
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -2975,7 +2984,7 @@ TEST_P(QuicFramerTest, StopWaitingFrame) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_STOP_WAITING_DATA);
}
@@ -2987,9 +2996,9 @@ TEST_P(QuicFramerTest, RstStreamFrameVersion13) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3039,7 +3048,7 @@ TEST_P(QuicFramerTest, RstStreamFrameVersion13) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_RST_STREAM_DATA);
}
@@ -3051,9 +3060,9 @@ TEST_P(QuicFramerTest, RstStreamFrameQuic) {
}
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3113,7 +3122,7 @@ TEST_P(QuicFramerTest, RstStreamFrameQuic) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_RST_STREAM_DATA);
}
@@ -3121,9 +3130,9 @@ TEST_P(QuicFramerTest, RstStreamFrameQuic) {
TEST_P(QuicFramerTest, ConnectionCloseFrame) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3171,7 +3180,7 @@ TEST_P(QuicFramerTest, ConnectionCloseFrame) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_CONNECTION_CLOSE_DATA);
}
@@ -3179,9 +3188,9 @@ TEST_P(QuicFramerTest, ConnectionCloseFrame) {
TEST_P(QuicFramerTest, GoAwayFrame) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3232,7 +3241,7 @@ TEST_P(QuicFramerTest, GoAwayFrame) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_GOAWAY_DATA);
}
@@ -3240,9 +3249,9 @@ TEST_P(QuicFramerTest, GoAwayFrame) {
TEST_P(QuicFramerTest, WindowUpdateFrame) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3292,7 +3301,7 @@ TEST_P(QuicFramerTest, WindowUpdateFrame) {
}
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_WINDOW_UPDATE_DATA);
}
@@ -3300,9 +3309,9 @@ TEST_P(QuicFramerTest, WindowUpdateFrame) {
TEST_P(QuicFramerTest, BlockedFrame) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3342,7 +3351,7 @@ TEST_P(QuicFramerTest, BlockedFrame) {
string expected_error = "Unable to read stream_id.";
CheckProcessingFails(
packet,
- i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
expected_error, QUIC_INVALID_BLOCKED_DATA);
}
@@ -3350,9 +3359,9 @@ TEST_P(QuicFramerTest, BlockedFrame) {
TEST_P(QuicFramerTest, PublicResetPacket) {
unsigned char packet[] = {
- // public flags (public reset, 8 byte guid)
+ // public flags (public reset, 8 byte connection_id)
0x0E,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// message tag (kPRST)
@@ -3380,7 +3389,7 @@ TEST_P(QuicFramerTest, PublicResetPacket) {
ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
ASSERT_TRUE(visitor_.public_reset_packet_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.public_reset_packet_->public_header.guid);
+ visitor_.public_reset_packet_->public_header.connection_id);
EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag);
EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag);
EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789),
@@ -3394,12 +3403,12 @@ TEST_P(QuicFramerTest, PublicResetPacket) {
for (size_t i = 0; i < arraysize(packet); ++i) {
string expected_error;
DVLOG(1) << "iteration: " << i;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
} else if (i < kPublicResetPacketMessageTagOffset) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
} else {
@@ -3412,9 +3421,9 @@ TEST_P(QuicFramerTest, PublicResetPacket) {
TEST_P(QuicFramerTest, PublicResetPacketWithTrailingJunk) {
unsigned char packet[] = {
- // public flags (public reset, 8 byte guid)
+ // public flags (public reset, 8 byte connection_id)
0x0E,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// message tag (kPRST)
@@ -3446,9 +3455,9 @@ TEST_P(QuicFramerTest, PublicResetPacketWithTrailingJunk) {
TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
unsigned char packet[] = {
- // public flags (public reset, 8 byte guid)
+ // public flags (public reset, 8 byte connection_id)
0x0E,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// message tag (kPRST)
@@ -3484,7 +3493,7 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
ASSERT_TRUE(visitor_.public_reset_packet_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.public_reset_packet_->public_header.guid);
+ visitor_.public_reset_packet_->public_header.connection_id);
EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag);
EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag);
EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789),
@@ -3500,12 +3509,12 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
for (size_t i = 0; i < arraysize(packet); ++i) {
string expected_error;
DVLOG(1) << "iteration: " << i;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
} else if (i < kPublicResetPacketMessageTagOffset) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
} else {
@@ -3519,9 +3528,9 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
// TODO(wtc): remove this test when we drop support for QUIC_VERSION_13.
TEST_P(QuicFramerTest, PublicResetPacketOld) {
unsigned char packet[] = {
- // public flags (public reset, 8 byte guid)
+ // public flags (public reset, 8 byte connection_id)
0x3E,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// nonce proof
@@ -3537,7 +3546,7 @@ TEST_P(QuicFramerTest, PublicResetPacketOld) {
ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
ASSERT_TRUE(visitor_.public_reset_packet_.get());
EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
- visitor_.public_reset_packet_->public_header.guid);
+ visitor_.public_reset_packet_->public_header.connection_id);
EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag);
EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag);
EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789),
@@ -3551,12 +3560,12 @@ TEST_P(QuicFramerTest, PublicResetPacketOld) {
for (size_t i = 0; i < arraysize(packet); ++i) {
string expected_error;
DVLOG(1) << "iteration: " << i;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
} else if (i < kPublicResetPacketNonceProofOffset) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
CheckProcessingFails(packet, i, expected_error,
QUIC_INVALID_PACKET_HEADER);
} else if (i < kPublicResetPacketRejectedSequenceNumberOffset) {
@@ -3573,9 +3582,9 @@ TEST_P(QuicFramerTest, PublicResetPacketOld) {
TEST_P(QuicFramerTest, VersionNegotiationPacket) {
unsigned char packet[] = {
- // public flags (version, 8 byte guid)
+ // public flags (version, 8 byte connection_id)
0x3D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -3592,13 +3601,13 @@ TEST_P(QuicFramerTest, VersionNegotiationPacket) {
EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size());
EXPECT_EQ(GetParam(), visitor_.version_negotiation_packet_->versions[0]);
- for (size_t i = 0; i <= kPublicFlagsSize + PACKET_8BYTE_GUID; ++i) {
+ for (size_t i = 0; i <= kPublicFlagsSize + PACKET_8BYTE_CONNECTION_ID; ++i) {
string expected_error;
QuicErrorCode error_code = QUIC_INVALID_PACKET_HEADER;
- if (i < kGuidOffset) {
+ if (i < kConnectionIdOffset) {
expected_error = "Unable to read public flags.";
} else if (i < kVersionOffset) {
- expected_error = "Unable to read GUID.";
+ expected_error = "Unable to read ConnectionId.";
} else {
expected_error = "Unable to read supported version in negotiation.";
error_code = QUIC_INVALID_VERSION_NEGOTIATION_PACKET;
@@ -3609,9 +3618,9 @@ TEST_P(QuicFramerTest, VersionNegotiationPacket) {
TEST_P(QuicFramerTest, FecPacket) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3646,7 +3655,7 @@ TEST_P(QuicFramerTest, FecPacket) {
TEST_P(QuicFramerTest, BuildPaddingFramePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -3660,9 +3669,9 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) {
frames.push_back(QuicFrame(&padding_frame));
unsigned char packet[kMaxPacketSize] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3677,7 +3686,7 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) {
};
uint64 header_size =
- GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
@@ -3693,7 +3702,7 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) {
TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -3708,9 +3717,9 @@ TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
frames.push_back(QuicFrame(&padding_frame));
unsigned char packet[kMaxPacketSize] = {
- // public flags (8 byte guid and 4 byte sequence number)
+ // public flags (8 byte connection_id and 4 byte sequence number)
0x2C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3724,7 +3733,7 @@ TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
};
uint64 header_size =
- GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
@@ -3740,7 +3749,7 @@ TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -3755,9 +3764,9 @@ TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
frames.push_back(QuicFrame(&padding_frame));
unsigned char packet[kMaxPacketSize] = {
- // public flags (8 byte guid and 2 byte sequence number)
+ // public flags (8 byte connection_id and 2 byte sequence number)
0x1C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3771,7 +3780,7 @@ TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
};
uint64 header_size =
- GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
@@ -3787,7 +3796,7 @@ TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -3802,9 +3811,9 @@ TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
frames.push_back(QuicFrame(&padding_frame));
unsigned char packet[kMaxPacketSize] = {
- // public flags (8 byte guid and 1 byte sequence number)
+ // public flags (8 byte connection_id and 1 byte sequence number)
0x0C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3818,7 +3827,7 @@ TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
};
uint64 header_size =
- GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
@@ -3834,7 +3843,7 @@ TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
TEST_P(QuicFramerTest, BuildStreamFramePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -3852,9 +3861,9 @@ TEST_P(QuicFramerTest, BuildStreamFramePacket) {
frames.push_back(QuicFrame(&stream_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -3887,7 +3896,7 @@ TEST_P(QuicFramerTest, BuildStreamFramePacket) {
TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.fec_flag = false;
@@ -3905,9 +3914,9 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) {
frames.push_back(QuicFrame(&stream_frame));
unsigned char packet[] = {
- // public flags (version, 8 byte guid)
+ // public flags (version, 8 byte connection_id)
0x3D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -3943,14 +3952,14 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) {
TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) {
QuicPacketPublicHeader header;
- header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.reset_flag = false;
header.version_flag = true;
unsigned char packet[] = {
- // public flags (version, 8 byte guid)
+ // public flags (version, 8 byte connection_id)
0x0D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -3972,7 +3981,7 @@ TEST_P(QuicFramerTest, BuildAckFramePacket) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -3991,9 +4000,9 @@ TEST_P(QuicFramerTest, BuildAckFramePacket) {
frames.push_back(QuicFrame(&ack_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4036,7 +4045,7 @@ TEST_P(QuicFramerTest, BuildAckFramePacket15) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4057,9 +4066,9 @@ TEST_P(QuicFramerTest, BuildAckFramePacket15) {
frames.push_back(QuicFrame(&ack_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4107,7 +4116,7 @@ TEST_P(QuicFramerTest, BuildAckFramePacketV14) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4128,9 +4137,9 @@ TEST_P(QuicFramerTest, BuildAckFramePacketV14) {
frames.push_back(QuicFrame(&ack_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4176,7 +4185,7 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4192,9 +4201,9 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) {
frames.push_back(QuicFrame(&congestion_feedback_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4225,7 +4234,7 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCPV14) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4241,9 +4250,9 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCPV14) {
frames.push_back(QuicFrame(&congestion_feedback_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4276,7 +4285,7 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4302,9 +4311,9 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) {
frames.push_back(QuicFrame(&frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4349,7 +4358,7 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrivalV14) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4375,9 +4384,9 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrivalV14) {
frames.push_back(QuicFrame(&frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4424,7 +4433,7 @@ TEST_P(QuicFramerTest, BuildStopWaitingPacket) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4440,9 +4449,9 @@ TEST_P(QuicFramerTest, BuildStopWaitingPacket) {
frames.push_back(QuicFrame(&stop_waiting_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4471,7 +4480,7 @@ TEST_P(QuicFramerTest, BuildStopWaitingPacket) {
TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4488,9 +4497,9 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) {
frames.push_back(QuicFrame(&congestion_feedback_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4518,7 +4527,7 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) {
TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4546,7 +4555,7 @@ TEST_P(QuicFramerTest, BuildRstFramePacketVersion13) {
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4560,9 +4569,9 @@ TEST_P(QuicFramerTest, BuildRstFramePacketVersion13) {
rst_frame.error_details = "because I can";
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4604,7 +4613,7 @@ TEST_P(QuicFramerTest, BuildRstFramePacketQuic) {
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4619,9 +4628,9 @@ TEST_P(QuicFramerTest, BuildRstFramePacketQuic) {
rst_frame.byte_offset = 0x0807060504030201;
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4662,7 +4671,7 @@ TEST_P(QuicFramerTest, BuildRstFramePacketQuic) {
TEST_P(QuicFramerTest, BuildCloseFramePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4678,9 +4687,9 @@ TEST_P(QuicFramerTest, BuildCloseFramePacket) {
frames.push_back(QuicFrame(&close_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4713,7 +4722,7 @@ TEST_P(QuicFramerTest, BuildCloseFramePacket) {
TEST_P(QuicFramerTest, BuildGoAwayPacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4730,9 +4739,9 @@ TEST_P(QuicFramerTest, BuildGoAwayPacket) {
frames.push_back(QuicFrame(&goaway_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4767,7 +4776,7 @@ TEST_P(QuicFramerTest, BuildGoAwayPacket) {
TEST_P(QuicFramerTest, BuildWindowUpdatePacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4783,9 +4792,9 @@ TEST_P(QuicFramerTest, BuildWindowUpdatePacket) {
frames.push_back(QuicFrame(&window_update_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4822,7 +4831,7 @@ TEST_P(QuicFramerTest, BuildWindowUpdatePacket) {
TEST_P(QuicFramerTest, BuildBlockedPacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -4837,9 +4846,9 @@ TEST_P(QuicFramerTest, BuildBlockedPacket) {
frames.push_back(QuicFrame(&blocked_frame));
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -4873,16 +4882,16 @@ TEST_P(QuicFramerTest, BuildBlockedPacket) {
TEST_P(QuicFramerTest, BuildPublicResetPacket) {
QuicPublicResetPacket reset_packet;
- reset_packet.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
reset_packet.public_header.reset_flag = true;
reset_packet.public_header.version_flag = false;
reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC);
reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789);
unsigned char packet[] = {
- // public flags (public reset, 8 byte GUID)
+ // public flags (public reset, 8 byte ConnectionId)
0x0E,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// message tag (kPRST)
@@ -4916,7 +4925,7 @@ TEST_P(QuicFramerTest, BuildPublicResetPacket) {
TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
QuicPublicResetPacket reset_packet;
- reset_packet.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
reset_packet.public_header.reset_flag = true;
reset_packet.public_header.version_flag = false;
reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC);
@@ -4924,9 +4933,9 @@ TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
reset_packet.client_address = IPEndPoint(Loopback4(), 0x1234);
unsigned char packet[] = {
- // public flags (public reset, 8 byte GUID)
+ // public flags (public reset, 8 byte ConnectionId)
0x0E,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// message tag (kPRST)
@@ -4968,7 +4977,7 @@ TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
TEST_P(QuicFramerTest, BuildFecPacket) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = true;
@@ -4982,9 +4991,9 @@ TEST_P(QuicFramerTest, BuildFecPacket) {
fec_data.redundancy = "abcdefghijklmnop";
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -5014,9 +5023,9 @@ TEST_P(QuicFramerTest, BuildFecPacket) {
TEST_P(QuicFramerTest, EncryptPacket) {
QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -5036,7 +5045,7 @@ TEST_P(QuicFramerTest, EncryptPacket) {
scoped_ptr<QuicPacket> raw(
QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false,
- PACKET_8BYTE_GUID, !kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER));
scoped_ptr<QuicEncryptedPacket> encrypted(
framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
@@ -5048,9 +5057,9 @@ TEST_P(QuicFramerTest, EncryptPacket) {
TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) {
QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
unsigned char packet[] = {
- // public flags (version, 8 byte guid)
+ // public flags (version, 8 byte connection_id)
0x3D,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// version tag
@@ -5072,7 +5081,7 @@ TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) {
scoped_ptr<QuicPacket> raw(
QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false,
- PACKET_8BYTE_GUID, kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER));
scoped_ptr<QuicEncryptedPacket> encrypted(
framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
@@ -5086,7 +5095,7 @@ TEST_P(QuicFramerTest, Truncation) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -5135,7 +5144,7 @@ TEST_P(QuicFramerTest, Truncation15) {
return;
}
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -5184,7 +5193,7 @@ TEST_P(QuicFramerTest, Truncation15) {
TEST_P(QuicFramerTest, CleanTruncation) {
QuicPacketHeader header;
- header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
+ header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.fec_flag = false;
@@ -5234,9 +5243,9 @@ TEST_P(QuicFramerTest, CleanTruncation) {
TEST_P(QuicFramerTest, EntropyFlagTest) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -5269,9 +5278,9 @@ TEST_P(QuicFramerTest, EntropyFlagTest) {
TEST_P(QuicFramerTest, FecEntropyTest) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
@@ -5306,9 +5315,9 @@ TEST_P(QuicFramerTest, FecEntropyTest) {
TEST_P(QuicFramerTest, StopPacketProcessing) {
unsigned char packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index 2695c8f..ff09164 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -52,11 +52,12 @@ const char kUploadData[] = "hello world!";
class TestQuicConnection : public QuicConnection {
public:
TestQuicConnection(const QuicVersionVector& versions,
- QuicGuid guid,
+ QuicConnectionId connection_id,
IPEndPoint address,
QuicConnectionHelper* helper,
QuicPacketWriter* writer)
- : QuicConnection(guid, address, helper, writer, false, versions) {
+ : QuicConnection(connection_id, address, helper, writer, false,
+ versions) {
}
void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
@@ -124,9 +125,9 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> {
: net_log_(BoundNetLog()),
use_closing_stream_(false),
read_buffer_(new IOBufferWithSize(4096)),
- guid_(2),
+ connection_id_(2),
stream_id_(GetParam() > QUIC_VERSION_12 ? 5 : 3),
- maker_(GetParam(), guid_),
+ maker_(GetParam(), connection_id_),
random_generator_(0) {
IPAddressNumber ip;
CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip));
@@ -193,9 +194,9 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> {
helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_,
&random_generator_));
writer_.reset(new QuicDefaultPacketWriter(socket));
- connection_ = new TestQuicConnection(SupportedVersions(GetParam()), guid_,
- peer_addr_, helper_.get(),
- writer_.get());
+ connection_ = new TestQuicConnection(SupportedVersions(GetParam()),
+ connection_id_, peer_addr_,
+ helper_.get(), writer_.get());
connection_->set_visitor(&visitor_);
connection_->SetSendAlgorithm(send_algorithm_);
connection_->SetReceiveAlgorithm(receive_algorithm_);
@@ -314,7 +315,7 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> {
return compressor.CompressHeaders(headers);
}
- const QuicGuid guid_;
+ const QuicConnectionId connection_id_;
const QuicStreamId stream_id_;
QuicTestPacketMaker maker_;
IPEndPoint self_addr_;
diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
index f0e5c2b..dda625d 100644
--- a/net/quic/quic_packet_creator.cc
+++ b/net/quic/quic_packet_creator.cc
@@ -55,11 +55,11 @@ class QuicRandomBoolSource {
DISALLOW_COPY_AND_ASSIGN(QuicRandomBoolSource);
};
-QuicPacketCreator::QuicPacketCreator(QuicGuid guid,
+QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id,
QuicFramer* framer,
QuicRandom* random_generator,
bool is_server)
- : guid_(guid),
+ : connection_id_(connection_id),
framer_(framer),
random_bool_source_(new QuicRandomBoolSource(random_generator)),
sequence_number_(0),
@@ -137,11 +137,11 @@ bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id,
// static
size_t QuicPacketCreator::StreamFramePacketOverhead(
QuicVersion version,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length,
InFecGroup is_in_fec_group) {
- return GetPacketHeaderSize(guid_length, include_version,
+ return GetPacketHeaderSize(connection_id_length, include_version,
sequence_number_length, is_in_fec_group) +
// Assumes this is a stream with a single lone packet.
QuicFramer::GetMinStreamFrameSize(version, 1u, 0u, true);
@@ -154,7 +154,7 @@ size_t QuicPacketCreator::CreateStreamFrame(QuicStreamId id,
QuicFrame* frame) {
DCHECK_GT(options_.max_packet_length,
StreamFramePacketOverhead(
- framer_->version(), PACKET_8BYTE_GUID, kIncludeVersion,
+ framer_->version(), PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, IN_FEC_GROUP));
if (!HasRoomForStreamFrame(id, offset)) {
LOG(DFATAL) << "No room for Stream frame, BytesFree: " << BytesFree()
@@ -299,7 +299,7 @@ size_t QuicPacketCreator::PacketSize() const {
fec_group_->NumReceivedPackets() == 0) {
sequence_number_length_ = options_.send_sequence_number_length;
}
- packet_size_ = GetPacketHeaderSize(options_.send_guid_length,
+ packet_size_ = GetPacketHeaderSize(options_.send_connection_id_length,
send_version_in_packet_,
sequence_number_length_,
options_.max_packets_per_fec_group == 0 ?
@@ -380,7 +380,7 @@ QuicEncryptedPacket* QuicPacketCreator::SerializeVersionNegotiationPacket(
const QuicVersionVector& supported_versions) {
DCHECK(is_server_);
QuicPacketPublicHeader header;
- header.guid = guid_;
+ header.connection_id = connection_id_;
header.reset_flag = false;
header.version_flag = true;
header.versions = supported_versions;
@@ -394,7 +394,7 @@ QuicEncryptedPacket* QuicPacketCreator::SerializeVersionNegotiationPacket(
void QuicPacketCreator::FillPacketHeader(QuicFecGroupNumber fec_group,
bool fec_flag,
QuicPacketHeader* header) {
- header->public_header.guid = guid_;
+ header->public_header.connection_id = connection_id_;
header->public_header.reset_flag = false;
header->public_header.version_flag = send_version_in_packet_;
header->fec_flag = fec_flag;
diff --git a/net/quic/quic_packet_creator.h b/net/quic/quic_packet_creator.h
index 152085e..5b01319 100644
--- a/net/quic/quic_packet_creator.h
+++ b/net/quic/quic_packet_creator.h
@@ -34,19 +34,19 @@ class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface {
Options()
: max_packet_length(kDefaultMaxPacketSize),
max_packets_per_fec_group(0),
- send_guid_length(PACKET_8BYTE_GUID),
+ send_connection_id_length(PACKET_8BYTE_CONNECTION_ID),
send_sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER) {}
size_t max_packet_length;
// 0 indicates fec is disabled.
size_t max_packets_per_fec_group;
- // Length of guid to send over the wire.
- QuicGuidLength send_guid_length;
+ // Length of connection_id to send over the wire.
+ QuicConnectionIdLength send_connection_id_length;
QuicSequenceNumberLength send_sequence_number_length;
};
// QuicRandom* required for packet entropy.
- QuicPacketCreator(QuicGuid guid,
+ QuicPacketCreator(QuicConnectionId connection_id,
QuicFramer* framer,
QuicRandom* random_generator,
bool is_server);
@@ -73,7 +73,7 @@ class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface {
// The overhead the framing will add for a packet with one frame.
static size_t StreamFramePacketOverhead(
QuicVersion version,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length,
InFecGroup is_in_fec_group);
@@ -198,7 +198,7 @@ class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface {
void MaybeAddPadding();
Options options_;
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
QuicFramer* framer_;
scoped_ptr<QuicRandomBoolSource> random_bool_source_;
QuicPacketSequenceNumber sequence_number_;
diff --git a/net/quic/quic_packet_creator_test.cc b/net/quic/quic_packet_creator_test.cc
index 6eb849f..3730e14 100644
--- a/net/quic/quic_packet_creator_test.cc
+++ b/net/quic/quic_packet_creator_test.cc
@@ -33,9 +33,9 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<bool> {
: server_framer_(QuicSupportedVersions(), QuicTime::Zero(), true),
client_framer_(QuicSupportedVersions(), QuicTime::Zero(), false),
sequence_number_(0),
- guid_(2),
+ connection_id_(2),
data_("foo"),
- creator_(guid_, &client_framer_, &mock_random_, false) {
+ creator_(connection_id_, &client_framer_, &mock_random_, false) {
client_framer_.set_visitor(&framer_visitor_);
server_framer_.set_visitor(&framer_visitor_);
}
@@ -66,7 +66,7 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<bool> {
// Returns the number of bytes consumed by the header of packet, including
// the version, that is not in an FEC group.
size_t GetPacketHeaderOverhead() {
- return GetPacketHeaderSize(creator_.options()->send_guid_length,
+ return GetPacketHeaderSize(creator_.options()->send_connection_id_length,
kIncludeVersion,
creator_.options()->send_sequence_number_length,
NOT_IN_FEC_GROUP);
@@ -95,7 +95,7 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<bool> {
QuicFramer client_framer_;
testing::StrictMock<MockFramerVisitor> framer_visitor_;
QuicPacketSequenceNumber sequence_number_;
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
string data_;
MockRandom mock_random_;
QuicPacketCreator creator_;
@@ -581,7 +581,7 @@ TEST_P(QuicPacketCreatorTest, AddFrameAndSerialize) {
EXPECT_FALSE(creator_.HasPendingFrames());
EXPECT_EQ(max_plaintext_size -
GetPacketHeaderSize(
- creator_.options()->send_guid_length,
+ creator_.options()->send_connection_id_length,
QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
creator_.BytesFree());
@@ -625,7 +625,7 @@ TEST_P(QuicPacketCreatorTest, AddFrameAndSerialize) {
EXPECT_FALSE(creator_.HasPendingFrames());
EXPECT_EQ(max_plaintext_size -
GetPacketHeaderSize(
- creator_.options()->send_guid_length,
+ creator_.options()->send_connection_id_length,
QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
PACKET_1BYTE_SEQUENCE_NUMBER,
NOT_IN_FEC_GROUP),
diff --git a/net/quic/quic_packet_generator_test.cc b/net/quic/quic_packet_generator_test.cc
index f6e9b85..6593a3e 100644
--- a/net/quic/quic_packet_generator_test.cc
+++ b/net/quic/quic_packet_generator_test.cc
@@ -505,7 +505,7 @@ TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) {
// but not enough for a stream frame of 0 offset and one with non-zero offset.
creator_.options()->max_packet_length =
NullEncrypter().GetCiphertextSize(0) +
- GetPacketHeaderSize(creator_.options()->send_guid_length,
+ GetPacketHeaderSize(creator_.options()->send_connection_id_length,
true,
creator_.options()->send_sequence_number_length,
NOT_IN_FEC_GROUP) +
diff --git a/net/quic/quic_protocol.cc b/net/quic/quic_protocol.cc
index e56522d..a23e4ee 100644
--- a/net/quic/quic_protocol.cc
+++ b/net/quic/quic_protocol.cc
@@ -16,42 +16,45 @@ using std::string;
namespace net {
size_t GetPacketHeaderSize(const QuicPacketHeader& header) {
- return GetPacketHeaderSize(header.public_header.guid_length,
+ return GetPacketHeaderSize(header.public_header.connection_id_length,
header.public_header.version_flag,
header.public_header.sequence_number_length,
header.is_in_fec_group);
}
-size_t GetPacketHeaderSize(QuicGuidLength guid_length,
+size_t GetPacketHeaderSize(QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length,
InFecGroup is_in_fec_group) {
- return kPublicFlagsSize + guid_length +
+ return kPublicFlagsSize + connection_id_length +
(include_version ? kQuicVersionSize : 0) + sequence_number_length +
kPrivateFlagsSize + (is_in_fec_group == IN_FEC_GROUP ? kFecGroupSize : 0);
}
size_t GetStartOfFecProtectedData(
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length) {
- return GetPacketHeaderSize(
- guid_length, include_version, sequence_number_length, IN_FEC_GROUP);
+ return GetPacketHeaderSize(connection_id_length,
+ include_version,
+ sequence_number_length,
+ IN_FEC_GROUP);
}
size_t GetStartOfEncryptedData(
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length) {
// Don't include the fec size, since encryption starts before private flags.
- return GetPacketHeaderSize(
- guid_length, include_version, sequence_number_length, NOT_IN_FEC_GROUP) -
- kPrivateFlagsSize;
+ return GetPacketHeaderSize(connection_id_length,
+ include_version,
+ sequence_number_length,
+ NOT_IN_FEC_GROUP) - kPrivateFlagsSize;
}
QuicPacketPublicHeader::QuicPacketPublicHeader()
- : guid(0),
- guid_length(PACKET_8BYTE_GUID),
+ : connection_id(0),
+ connection_id_length(PACKET_8BYTE_CONNECTION_ID),
reset_flag(false),
version_flag(false),
sequence_number_length(PACKET_6BYTE_SEQUENCE_NUMBER) {
@@ -59,8 +62,8 @@ QuicPacketPublicHeader::QuicPacketPublicHeader()
QuicPacketPublicHeader::QuicPacketPublicHeader(
const QuicPacketPublicHeader& other)
- : guid(other.guid),
- guid_length(other.guid_length),
+ : connection_id(other.connection_id),
+ connection_id_length(other.connection_id_length),
reset_flag(other.reset_flag),
version_flag(other.version_flag),
sequence_number_length(other.sequence_number_length),
@@ -209,8 +212,8 @@ string QuicVersionVectorToString(const QuicVersionVector& versions) {
}
ostream& operator<<(ostream& os, const QuicPacketHeader& header) {
- os << "{ guid: " << header.public_header.guid
- << ", guid_length:" << header.public_header.guid_length
+ os << "{ connection_id: " << header.public_header.connection_id
+ << ", connection_id_length:" << header.public_header.connection_id_length
<< ", sequence_number_length:"
<< header.public_header.sequence_number_length
<< ", reset_flag: " << header.public_header.reset_flag
@@ -563,14 +566,14 @@ QuicBlockedFrame::QuicBlockedFrame(QuicStreamId stream_id)
QuicPacket::QuicPacket(char* buffer,
size_t length,
bool owns_buffer,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool includes_version,
QuicSequenceNumberLength sequence_number_length,
bool is_fec_packet)
: QuicData(buffer, length, owns_buffer),
buffer_(buffer),
is_fec_packet_(is_fec_packet),
- guid_length_(guid_length),
+ connection_id_length_(connection_id_length),
includes_version_(includes_version),
sequence_number_length_(sequence_number_length) {
}
@@ -588,7 +591,7 @@ QuicEncryptedPacket::QuicEncryptedPacket(char* buffer,
StringPiece QuicPacket::FecProtectedData() const {
const size_t start_of_fec = GetStartOfFecProtectedData(
- guid_length_, includes_version_, sequence_number_length_);
+ connection_id_length_, includes_version_, sequence_number_length_);
return StringPiece(data() + start_of_fec, length() - start_of_fec);
}
@@ -596,12 +599,12 @@ StringPiece QuicPacket::AssociatedData() const {
return StringPiece(
data() + kStartOfHashData,
GetStartOfEncryptedData(
- guid_length_, includes_version_, sequence_number_length_) -
+ connection_id_length_, includes_version_, sequence_number_length_) -
kStartOfHashData);
}
StringPiece QuicPacket::BeforePlaintext() const {
- return StringPiece(data(), GetStartOfEncryptedData(guid_length_,
+ return StringPiece(data(), GetStartOfEncryptedData(connection_id_length_,
includes_version_,
sequence_number_length_));
}
@@ -609,7 +612,7 @@ StringPiece QuicPacket::BeforePlaintext() const {
StringPiece QuicPacket::Plaintext() const {
const size_t start_of_encrypted_data =
GetStartOfEncryptedData(
- guid_length_, includes_version_, sequence_number_length_);
+ connection_id_length_, includes_version_, sequence_number_length_);
return StringPiece(data() + start_of_encrypted_data,
length() - start_of_encrypted_data);
}
diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h
index 23b6038..6bf38e2 100644
--- a/net/quic/quic_protocol.h
+++ b/net/quic/quic_protocol.h
@@ -33,7 +33,7 @@ class QuicAckNotifier;
class QuicPacket;
struct QuicPacketHeader;
-typedef uint64 QuicGuid;
+typedef uint64 QuicConnectionId;
typedef uint32 QuicStreamId;
typedef uint64 QuicStreamOffset;
typedef uint64 QuicPacketSequenceNumber;
@@ -165,11 +165,11 @@ enum QuicFrameType {
NUM_FRAME_TYPES
};
-enum QuicGuidLength {
- PACKET_0BYTE_GUID = 0,
- PACKET_1BYTE_GUID = 1,
- PACKET_4BYTE_GUID = 4,
- PACKET_8BYTE_GUID = 8
+enum QuicConnectionIdLength {
+ PACKET_0BYTE_CONNECTION_ID = 0,
+ PACKET_1BYTE_CONNECTION_ID = 1,
+ PACKET_4BYTE_CONNECTION_ID = 4,
+ PACKET_8BYTE_CONNECTION_ID = 8
};
enum InFecGroup {
@@ -202,15 +202,15 @@ enum QuicPacketPublicFlags {
// Bit 1: Is this packet a public reset packet?
PACKET_PUBLIC_FLAGS_RST = 1 << 1,
- // Bits 2 and 3 specify the length of the GUID as follows:
+ // Bits 2 and 3 specify the length of the ConnectionId as follows:
// ----00--: 0 bytes
// ----01--: 1 byte
// ----10--: 4 bytes
// ----11--: 8 bytes
- PACKET_PUBLIC_FLAGS_0BYTE_GUID = 0,
- PACKET_PUBLIC_FLAGS_1BYTE_GUID = 1 << 2,
- PACKET_PUBLIC_FLAGS_4BYTE_GUID = 1 << 3,
- PACKET_PUBLIC_FLAGS_8BYTE_GUID = 1 << 3 | 1 << 2,
+ PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID = 0,
+ PACKET_PUBLIC_FLAGS_1BYTE_CONNECTION_ID = 1 << 2,
+ PACKET_PUBLIC_FLAGS_4BYTE_CONNECTION_ID = 1 << 3,
+ PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID = 1 << 3 | 1 << 2,
// Bits 4 and 5 describe the packet sequence number length as follows:
// --00----: 1 byte
@@ -312,19 +312,19 @@ NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d);
NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header);
NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length,
InFecGroup is_in_fec_group);
// Index of the first byte in a QUIC packet of FEC protected data.
NET_EXPORT_PRIVATE size_t GetStartOfFecProtectedData(
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length);
// Index of the first byte in a QUIC packet of encrypted data.
NET_EXPORT_PRIVATE size_t GetStartOfEncryptedData(
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length);
@@ -494,9 +494,10 @@ struct NET_EXPORT_PRIVATE QuicPacketPublicHeader {
explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other);
~QuicPacketPublicHeader();
- // Universal header. All QuicPacket headers will have a guid and public flags.
- QuicGuid guid;
- QuicGuidLength guid_length;
+ // Universal header. All QuicPacket headers will have a connection_id and
+ // public flags.
+ QuicConnectionId connection_id;
+ QuicConnectionIdLength connection_id_length;
bool reset_flag;
bool version_flag;
QuicSequenceNumberLength sequence_number_length;
@@ -868,10 +869,10 @@ class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
char* buffer,
size_t length,
bool owns_buffer,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool includes_version,
QuicSequenceNumberLength sequence_number_length) {
- return new QuicPacket(buffer, length, owns_buffer, guid_length,
+ return new QuicPacket(buffer, length, owns_buffer, connection_id_length,
includes_version, sequence_number_length, false);
}
@@ -879,10 +880,10 @@ class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
char* buffer,
size_t length,
bool owns_buffer,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool includes_version,
QuicSequenceNumberLength sequence_number_length) {
- return new QuicPacket(buffer, length, owns_buffer, guid_length,
+ return new QuicPacket(buffer, length, owns_buffer, connection_id_length,
includes_version, sequence_number_length, true);
}
@@ -899,14 +900,14 @@ class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
QuicPacket(char* buffer,
size_t length,
bool owns_buffer,
- QuicGuidLength guid_length,
+ QuicConnectionIdLength connection_id_length,
bool includes_version,
QuicSequenceNumberLength sequence_number_length,
bool is_fec_packet);
char* buffer_;
const bool is_fec_packet_;
- const QuicGuidLength guid_length_;
+ const QuicConnectionIdLength connection_id_length_;
const bool includes_version_;
const QuicSequenceNumberLength sequence_number_length_;
diff --git a/net/quic/quic_reliable_client_stream_test.cc b/net/quic/quic_reliable_client_stream_test.cc
index 75e099c..0c4ae56 100644
--- a/net/quic/quic_reliable_client_stream_test.cc
+++ b/net/quic/quic_reliable_client_stream_test.cc
@@ -21,7 +21,7 @@ namespace net {
namespace test {
namespace {
-const QuicGuid kStreamId = 3;
+const QuicConnectionId kStreamId = 3;
class MockDelegate : public QuicReliableClientStream::Delegate {
public:
diff --git a/net/quic/quic_sent_packet_manager.cc b/net/quic/quic_sent_packet_manager.cc
index 5104ec3..389917b 100644
--- a/net/quic/quic_sent_packet_manager.cc
+++ b/net/quic/quic_sent_packet_manager.cc
@@ -71,7 +71,7 @@ QuicSentPacketManager::QuicSentPacketManager(bool is_server,
is_server_(is_server),
clock_(clock),
stats_(stats),
- send_algorithm_(SendAlgorithmInterface::Create(clock, type)),
+ send_algorithm_(SendAlgorithmInterface::Create(clock, type, stats)),
loss_algorithm_(LossDetectionInterface::Create()),
rtt_sample_(QuicTime::Delta::Infinite()),
largest_observed_(0),
@@ -399,15 +399,20 @@ bool QuicSentPacketManager::OnPacketSent(
void QuicSentPacketManager::OnRetransmissionTimeout() {
DCHECK(unacked_packets_.HasPendingPackets());
- // Handshake retransmission, TLP, and RTO are implemented with a single alarm.
- // The handshake alarm is set when the handshake has not completed, and the
- // TLP and RTO alarms are set after that.
+ // Handshake retransmission, timer based loss detection, TLP, and RTO are
+ // implemented with a single alarm. The handshake alarm is set when the
+ // handshake has not completed, the loss alarm is set when the loss detection
+ // algorithm says to, and the TLP and RTO alarms are set after that.
// The TLP alarm is always set to run for under an RTO.
switch (GetRetransmissionMode()) {
case HANDSHAKE_MODE:
++stats_->crypto_retransmit_count;
RetransmitCryptoPackets();
return;
+ case LOSS_MODE:
+ ++stats_->loss_timeout_count;
+ InvokeLossDetection(clock_->Now());
+ return;
case TLP_MODE:
// If no tail loss probe can be sent, because there are no retransmittable
// packets, execute a conventional RTO to abandon old packets.
@@ -497,6 +502,9 @@ QuicSentPacketManager::RetransmissionTimeoutMode
if (pending_crypto_packet_count_ > 0) {
return HANDSHAKE_MODE;
}
+ if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) {
+ return LOSS_MODE;
+ }
if (consecutive_tlp_count_ < max_tail_loss_probes_) {
if (unacked_packets_.HasUnackedRetransmittableFrames()) {
return TLP_MODE;
@@ -507,12 +515,12 @@ QuicSentPacketManager::RetransmissionTimeoutMode
void QuicSentPacketManager::OnPacketAbandoned(
QuicPacketSequenceNumber sequence_number) {
- if (unacked_packets_.IsPending(sequence_number)) {
- LOG_IF(DFATAL, unacked_packets_.GetTransmissionInfo(
- sequence_number).bytes_sent == 0);
- send_algorithm_->OnPacketAbandoned(
- sequence_number,
- unacked_packets_.GetTransmissionInfo(sequence_number).bytes_sent);
+ const QuicUnackedPacketMap::TransmissionInfo& transmission_info =
+ unacked_packets_.GetTransmissionInfo(sequence_number);
+ if (transmission_info.pending) {
+ LOG_IF(DFATAL, transmission_info.bytes_sent == 0);
+ send_algorithm_->OnPacketAbandoned(sequence_number,
+ transmission_info.bytes_sent);
unacked_packets_.SetNotPending(sequence_number);
}
}
@@ -554,7 +562,8 @@ void QuicSentPacketManager::InvokeLossDetection(QuicTime time) {
loss_algorithm_->DetectLostPackets(unacked_packets_,
time,
largest_observed_,
- send_algorithm_->SmoothedRtt());
+ send_algorithm_->SmoothedRtt(),
+ rtt_sample_);
for (SequenceNumberSet::const_iterator it = lost_packets.begin();
it != lost_packets.end(); ++it) {
QuicPacketSequenceNumber sequence_number = *it;
@@ -639,6 +648,8 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const {
switch (GetRetransmissionMode()) {
case HANDSHAKE_MODE:
return clock_->ApproximateNow().Add(GetCryptoRetransmissionDelay());
+ case LOSS_MODE:
+ return loss_algorithm_->GetLossTimeout();
case TLP_MODE: {
// TODO(ianswett): When CWND is available, it would be preferable to
// set the timer based on the earliest retransmittable packet.
diff --git a/net/quic/quic_sent_packet_manager.h b/net/quic/quic_sent_packet_manager.h
index 4690f21..c8d5a90 100644
--- a/net/quic/quic_sent_packet_manager.h
+++ b/net/quic/quic_sent_packet_manager.h
@@ -175,10 +175,18 @@ class NET_EXPORT_PRIVATE QuicSentPacketManager {
NOT_RECEIVED_BY_PEER,
};
+ // The retransmission timer is a single timer which switches modes depending
+ // upon connection state.
enum RetransmissionTimeoutMode {
+ // A conventional TCP style RTO.
RTO_MODE,
+ // A tail loss probe. By default, QUIC sends up to two before RTOing.
TLP_MODE,
+ // Retransmission of handshake packets prior to handshake completion.
HANDSHAKE_MODE,
+ // Re-invoke the loss detection when a packet is not acked before the
+ // loss detection algorithm expects.
+ LOSS_MODE,
};
typedef linked_hash_map<QuicPacketSequenceNumber,
diff --git a/net/quic/quic_sent_packet_manager_test.cc b/net/quic/quic_sent_packet_manager_test.cc
index 3ab3e39..61240af 100644
--- a/net/quic/quic_sent_packet_manager_test.cc
+++ b/net/quic/quic_sent_packet_manager_test.cc
@@ -121,7 +121,7 @@ class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
SerializedPacket CreatePacket(QuicPacketSequenceNumber sequence_number,
bool retransmittable) {
packets_.push_back(QuicPacket::NewDataPacket(
- NULL, 1000, false, PACKET_8BYTE_GUID, false,
+ NULL, 1000, false, PACKET_8BYTE_CONNECTION_ID, false,
PACKET_6BYTE_SEQUENCE_NUMBER));
return SerializedPacket(
sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER,
@@ -131,7 +131,7 @@ class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
SerializedPacket CreateFecPacket(QuicPacketSequenceNumber sequence_number) {
packets_.push_back(QuicPacket::NewFecPacket(
- NULL, 1000, false, PACKET_8BYTE_GUID, false,
+ NULL, 1000, false, PACKET_8BYTE_CONNECTION_ID, false,
PACKET_6BYTE_SEQUENCE_NUMBER));
return SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER,
packets_.back(), 0u, NULL);
@@ -1120,6 +1120,38 @@ TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) {
}
}
+TEST_F(QuicSentPacketManagerTest, GetLossDelay) {
+ MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm();
+ QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm);
+
+ EXPECT_CALL(*loss_algorithm, GetLossTimeout())
+ .WillRepeatedly(Return(QuicTime::Zero()));
+ SendDataPacket(1);
+ SendDataPacket(2);
+
+ // Handle an ack which causes the loss algorithm to be evaluated and
+ // set the loss timeout.
+ EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _));
+ EXPECT_CALL(*loss_algorithm, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
+ ReceivedPacketInfo received_info;
+ received_info.largest_observed = 2;
+ received_info.missing_packets.insert(1);
+ manager_.OnIncomingAck(received_info, clock_.Now());
+
+ QuicTime timeout(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(10)));
+ EXPECT_CALL(*loss_algorithm, GetLossTimeout())
+ .WillRepeatedly(Return(timeout));
+ EXPECT_EQ(timeout, manager_.GetRetransmissionTime());
+
+ // Fire the retransmission timeout and ensure the loss detection algorithm
+ // is invoked.
+ EXPECT_CALL(*loss_algorithm, DetectLostPackets(_, _, _, _, _))
+ .WillOnce(Return(SequenceNumberSet()));
+ manager_.OnRetransmissionTimeout();
+}
+
} // namespace
} // namespace test
} // namespace net
diff --git a/net/quic/quic_session.h b/net/quic/quic_session.h
index fa551bf..7222850 100644
--- a/net/quic/quic_session.h
+++ b/net/quic/quic_session.h
@@ -167,7 +167,9 @@ class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface {
const IPEndPoint& peer_address() const {
return connection_->peer_address();
}
- QuicGuid guid() const { return connection_->guid(); }
+ QuicConnectionId connection_id() const {
+ return connection_->connection_id();
+ }
QuicPacketCreator::Options* options() { return connection()->options(); }
diff --git a/net/quic/quic_session_test.cc b/net/quic/quic_session_test.cc
index 3d04534..7abcc28 100644
--- a/net/quic/quic_session_test.cc
+++ b/net/quic/quic_session_test.cc
@@ -446,7 +446,7 @@ TEST_P(QuicSessionTest, OutOfOrderHeaders) {
QuicSpdyCompressor compressor;
vector<QuicStreamFrame> frames;
QuicPacketHeader header;
- header.public_header.guid = session_.guid();
+ header.public_header.connection_id = session_.connection_id();
TestStream* stream2 = session_.CreateOutgoingDataStream();
TestStream* stream4 = session_.CreateOutgoingDataStream();
@@ -520,7 +520,7 @@ TEST_P(QuicSessionTest, ZombieStream) {
vector<QuicStreamFrame> frames;
QuicPacketHeader header;
- header.public_header.guid = session_.guid();
+ header.public_header.connection_id = session_.connection_id();
// Create frame with headers for stream2.
QuicSpdyCompressor compressor;
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index 78124fb..9e3eea2 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -537,7 +537,7 @@ int QuicStreamFactory::CreateSession(
const AddressList& address_list,
const BoundNetLog& net_log,
QuicClientSession** session) {
- QuicGuid guid = random_generator_->RandUint64();
+ QuicConnectionId connection_id = random_generator_->RandUint64();
IPEndPoint addr = *address_list.begin();
scoped_refptr<PortSuggester> port_suggester =
new PortSuggester(host_port_proxy_pair.first, port_seed_);
@@ -580,7 +580,8 @@ int QuicStreamFactory::CreateSession(
clock_.get(), random_generator_));
}
- QuicConnection* connection = new QuicConnection(guid, addr, helper_.get(),
+ QuicConnection* connection = new QuicConnection(connection_id, addr,
+ helper_.get(),
writer.get(), false,
supported_versions_);
writer->SetConnection(connection);
diff --git a/net/quic/quic_unacked_packet_map.cc b/net/quic/quic_unacked_packet_map.cc
index bcafa56..c222ac9 100644
--- a/net/quic/quic_unacked_packet_map.cc
+++ b/net/quic/quic_unacked_packet_map.cc
@@ -205,11 +205,16 @@ bool QuicUnackedPacketMap::IsPending(
void QuicUnackedPacketMap::SetNotPending(
QuicPacketSequenceNumber sequence_number) {
- if (unacked_packets_[sequence_number].pending) {
- LOG_IF(DFATAL,
- bytes_in_flight_ < unacked_packets_[sequence_number].bytes_sent);
- bytes_in_flight_ -= unacked_packets_[sequence_number].bytes_sent;
- unacked_packets_[sequence_number].pending = false;
+ UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
+ if (it == unacked_packets_.end()) {
+ LOG(DFATAL) << "SetNotPending called for packet that is not unacked: "
+ << sequence_number;
+ return;
+ }
+ if (it->second.pending) {
+ LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent);
+ bytes_in_flight_ -= it->second.bytes_sent;
+ it->second.pending = false;
}
}
diff --git a/net/quic/reliable_quic_stream_test.cc b/net/quic/reliable_quic_stream_test.cc
index 3b47362..f1c310f 100644
--- a/net/quic/reliable_quic_stream_test.cc
+++ b/net/quic/reliable_quic_stream_test.cc
@@ -33,7 +33,7 @@ namespace {
const char kData1[] = "FooAndBar";
const char kData2[] = "EepAndBaz";
const size_t kDataLen = 9;
-const QuicGuid kStreamId = 3;
+const QuicConnectionId kStreamId = 3;
const bool kIsServer = true;
const bool kShouldProcessData = true;
@@ -132,7 +132,7 @@ TEST_F(ReliableQuicStreamTest, WriteAllData) {
connection_->options()->max_packet_length =
1 + QuicPacketCreator::StreamFramePacketOverhead(
- connection_->version(), PACKET_8BYTE_GUID, !kIncludeVersion,
+ connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
EXPECT_CALL(*session_, WritevData(kStreamId, _, _, _, _)).WillOnce(
Return(QuicConsumedData(kDataLen, true)));
@@ -191,7 +191,7 @@ TEST_F(ReliableQuicStreamTest, WriteOrBufferData) {
EXPECT_FALSE(write_blocked_list_->HasWriteBlockedStreams());
connection_->options()->max_packet_length =
1 + QuicPacketCreator::StreamFramePacketOverhead(
- connection_->version(), PACKET_8BYTE_GUID, !kIncludeVersion,
+ connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
EXPECT_CALL(*session_, WritevData(_, _, _, _, _)).WillOnce(
Return(QuicConsumedData(kDataLen - 1, false)));
diff --git a/net/quic/test_tools/quic_framer_peer.cc b/net/quic/test_tools/quic_framer_peer.cc
index e8d43cd..24338fa 100644
--- a/net/quic/test_tools/quic_framer_peer.cc
+++ b/net/quic/test_tools/quic_framer_peer.cc
@@ -20,8 +20,9 @@ QuicPacketSequenceNumber QuicFramerPeer::CalculatePacketSequenceNumberFromWire(
}
// static
-void QuicFramerPeer::SetLastSerializedGuid(QuicFramer* framer, QuicGuid guid) {
- framer->last_serialized_guid_ = guid;
+void QuicFramerPeer::SetLastSerializedConnectionId(
+ QuicFramer* framer, QuicConnectionId connection_id) {
+ framer->last_serialized_connection_id_ = connection_id;
}
void QuicFramerPeer::SetLastSequenceNumber(
diff --git a/net/quic/test_tools/quic_framer_peer.h b/net/quic/test_tools/quic_framer_peer.h
index acb45ec..887e77c 100644
--- a/net/quic/test_tools/quic_framer_peer.h
+++ b/net/quic/test_tools/quic_framer_peer.h
@@ -19,7 +19,8 @@ class QuicFramerPeer {
QuicFramer* framer,
QuicSequenceNumberLength sequence_number_length,
QuicPacketSequenceNumber packet_sequence_number);
- static void SetLastSerializedGuid(QuicFramer* framer, QuicGuid guid);
+ static void SetLastSerializedConnectionId(QuicFramer* framer,
+ QuicConnectionId connection_id);
static void SetLastSequenceNumber(
QuicFramer* framer,
QuicPacketSequenceNumber packet_sequence_number);
diff --git a/net/quic/test_tools/quic_sent_packet_manager_peer.cc b/net/quic/test_tools/quic_sent_packet_manager_peer.cc
index ce25764..be8730f 100644
--- a/net/quic/test_tools/quic_sent_packet_manager_peer.cc
+++ b/net/quic/test_tools/quic_sent_packet_manager_peer.cc
@@ -5,6 +5,7 @@
#include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
#include "base/stl_util.h"
+#include "net/quic/congestion_control/loss_detection_interface.h"
#include "net/quic/congestion_control/send_algorithm_interface.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_sent_packet_manager.h"
@@ -26,6 +27,13 @@ void QuicSentPacketManagerPeer::SetSendAlgorithm(
}
// static
+void QuicSentPacketManagerPeer::SetLossAlgorithm(
+ QuicSentPacketManager* sent_packet_manager,
+ LossDetectionInterface* loss_detector) {
+ sent_packet_manager->loss_algorithm_.reset(loss_detector);
+}
+
+// static
size_t QuicSentPacketManagerPeer::GetNackCount(
const QuicSentPacketManager* sent_packet_manager,
QuicPacketSequenceNumber sequence_number) {
diff --git a/net/quic/test_tools/quic_sent_packet_manager_peer.h b/net/quic/test_tools/quic_sent_packet_manager_peer.h
index 07262aa..163e10c 100644
--- a/net/quic/test_tools/quic_sent_packet_manager_peer.h
+++ b/net/quic/test_tools/quic_sent_packet_manager_peer.h
@@ -22,6 +22,9 @@ class QuicSentPacketManagerPeer {
static void SetSendAlgorithm(QuicSentPacketManager* sent_packet_manager,
SendAlgorithmInterface* send_algorithm);
+ static void SetLossAlgorithm(QuicSentPacketManager* sent_packet_manager,
+ LossDetectionInterface* loss_detector);
+
static size_t GetNackCount(
const QuicSentPacketManager* sent_packet_manager,
QuicPacketSequenceNumber sequence_number);
diff --git a/net/quic/test_tools/quic_test_packet_maker.cc b/net/quic/test_tools/quic_test_packet_maker.cc
index d0fa03c..c8d3471e 100644
--- a/net/quic/test_tools/quic_test_packet_maker.cc
+++ b/net/quic/test_tools/quic_test_packet_maker.cc
@@ -12,9 +12,10 @@
namespace net {
namespace test {
-QuicTestPacketMaker::QuicTestPacketMaker(QuicVersion version, QuicGuid guid)
+QuicTestPacketMaker::QuicTestPacketMaker(QuicVersion version,
+ QuicConnectionId connection_id)
: version_(version),
- guid_(guid),
+ connection_id_(connection_id),
spdy_request_framer_(SPDY3),
spdy_response_framer_(SPDY3) {
}
@@ -28,7 +29,7 @@ scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeRstPacket(
QuicStreamId stream_id,
QuicRstStreamErrorCode error_code) {
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = include_version;
header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER;
@@ -51,7 +52,7 @@ scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeAckAndRstPacket(
bool send_feedback) {
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = include_version;
header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER;
@@ -90,7 +91,7 @@ scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeAckAndRstPacket(
scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeConnectionClosePacket(
QuicPacketSequenceNumber num) {
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER;
@@ -111,7 +112,7 @@ scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeAckPacket(
QuicPacketSequenceNumber least_unacked,
bool send_feedback) {
QuicPacketHeader header;
- header.public_header.guid = guid_;
+ header.public_header.connection_id = connection_id_;
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER;
@@ -248,7 +249,7 @@ scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakePacket(
void QuicTestPacketMaker::InitializeHeader(
QuicPacketSequenceNumber sequence_number,
bool should_include_version) {
- header_.public_header.guid = guid_;
+ header_.public_header.connection_id = connection_id_;
header_.public_header.reset_flag = false;
header_.public_header.version_flag = should_include_version;
header_.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER;
diff --git a/net/quic/test_tools/quic_test_packet_maker.h b/net/quic/test_tools/quic_test_packet_maker.h
index 47d606e..5cd48e5 100644
--- a/net/quic/test_tools/quic_test_packet_maker.h
+++ b/net/quic/test_tools/quic_test_packet_maker.h
@@ -20,7 +20,7 @@ namespace test {
class QuicTestPacketMaker {
public:
- QuicTestPacketMaker(QuicVersion version, QuicGuid guid);
+ QuicTestPacketMaker(QuicVersion version, QuicConnectionId connection_id);
~QuicTestPacketMaker();
scoped_ptr<QuicEncryptedPacket> MakeRstPacket(
@@ -84,7 +84,7 @@ class QuicTestPacketMaker {
std::string SerializeHeaderBlock(const SpdyHeaderBlock& headers);
QuicVersion version_;
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
SpdyFramer spdy_request_framer_;
SpdyFramer spdy_response_framer_;
MockRandom random_generator_;
diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc
index 5268149..904cf76 100644
--- a/net/quic/test_tools/quic_test_utils.cc
+++ b/net/quic/test_tools/quic_test_utils.cc
@@ -265,7 +265,7 @@ void MockHelper::AdvanceTime(QuicTime::Delta delta) {
}
MockConnection::MockConnection(bool is_server)
- : QuicConnection(kTestGuid,
+ : QuicConnection(kTestConnectionId,
IPEndPoint(TestPeerIPAddress(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
@@ -276,7 +276,7 @@ MockConnection::MockConnection(bool is_server)
MockConnection::MockConnection(IPEndPoint address,
bool is_server)
- : QuicConnection(kTestGuid, address,
+ : QuicConnection(kTestConnectionId, address,
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
is_server, QuicSupportedVersions()),
@@ -284,9 +284,10 @@ MockConnection::MockConnection(IPEndPoint address,
helper_(helper()) {
}
-MockConnection::MockConnection(QuicGuid guid,
+MockConnection::MockConnection(QuicConnectionId connection_id,
bool is_server)
- : QuicConnection(guid, IPEndPoint(TestPeerIPAddress(), kTestPort),
+ : QuicConnection(connection_id,
+ IPEndPoint(TestPeerIPAddress(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
is_server, QuicSupportedVersions()),
@@ -296,7 +297,7 @@ MockConnection::MockConnection(QuicGuid guid,
MockConnection::MockConnection(bool is_server,
const QuicVersionVector& supported_versions)
- : QuicConnection(kTestGuid,
+ : QuicConnection(kTestConnectionId,
IPEndPoint(TestPeerIPAddress(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
@@ -375,6 +376,12 @@ MockSendAlgorithm::MockSendAlgorithm() {
MockSendAlgorithm::~MockSendAlgorithm() {
}
+MockLossAlgorithm::MockLossAlgorithm() {
+}
+
+MockLossAlgorithm::~MockLossAlgorithm() {
+}
+
MockAckNotifierDelegate::MockAckNotifierDelegate() {
}
@@ -479,7 +486,7 @@ bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) {
}
static QuicPacket* ConstructPacketFromHandshakeMessage(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const CryptoHandshakeMessage& message,
bool should_include_version) {
CryptoFramer crypto_framer;
@@ -487,7 +494,7 @@ static QuicPacket* ConstructPacketFromHandshakeMessage(
QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(), false);
QuicPacketHeader header;
- header.public_header.guid = guid;
+ header.public_header.connection_id = connection_id;
header.public_header.reset_flag = false;
header.public_header.version_flag = should_include_version;
header.packet_sequence_number = 1;
@@ -505,10 +512,11 @@ static QuicPacket* ConstructPacketFromHandshakeMessage(
return quic_framer.BuildUnsizedDataPacket(header, frames).packet;
}
-QuicPacket* ConstructHandshakePacket(QuicGuid guid, QuicTag tag) {
+QuicPacket* ConstructHandshakePacket(QuicConnectionId connection_id,
+ QuicTag tag) {
CryptoHandshakeMessage message;
message.set_tag(tag);
- return ConstructPacketFromHandshakeMessage(guid, message, false);
+ return ConstructPacketFromHandshakeMessage(connection_id, message, false);
}
size_t GetPacketLengthForOneStream(
@@ -521,12 +529,12 @@ size_t GetPacketLengthForOneStream(
const size_t stream_length =
NullEncrypter().GetCiphertextSize(*payload_length) +
QuicPacketCreator::StreamFramePacketOverhead(
- version, PACKET_8BYTE_GUID, include_version,
+ version, PACKET_8BYTE_CONNECTION_ID, include_version,
sequence_number_length, is_in_fec_group);
const size_t ack_length = NullEncrypter().GetCiphertextSize(
QuicFramer::GetMinAckFrameSize(
version, sequence_number_length, PACKET_1BYTE_SEQUENCE_NUMBER)) +
- GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version,
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, include_version,
sequence_number_length, is_in_fec_group);
if (stream_length < ack_length) {
*payload_length = 1 + ack_length - stream_length;
@@ -534,7 +542,7 @@ size_t GetPacketLengthForOneStream(
return NullEncrypter().GetCiphertextSize(*payload_length) +
QuicPacketCreator::StreamFramePacketOverhead(
- version, PACKET_8BYTE_GUID, include_version,
+ version, PACKET_8BYTE_CONNECTION_ID, include_version,
sequence_number_length, is_in_fec_group);
}
diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h
index ffe3b13..0afc436 100644
--- a/net/quic/test_tools/quic_test_utils.h
+++ b/net/quic/test_tools/quic_test_utils.h
@@ -11,6 +11,7 @@
#include <vector>
#include "base/strings/string_piece.h"
+#include "net/quic/congestion_control/loss_detection_interface.h"
#include "net/quic/congestion_control/send_algorithm_interface.h"
#include "net/quic/quic_ack_notifier.h"
#include "net/quic/quic_connection.h"
@@ -26,7 +27,7 @@ namespace net {
namespace test {
-static const QuicGuid kTestGuid = 42;
+static const QuicConnectionId kTestConnectionId = 42;
static const int kTestPort = 123;
// Returns the test peer IP address.
@@ -272,16 +273,16 @@ class MockHelper : public QuicConnectionHelperInterface {
class MockConnection : public QuicConnection {
public:
- // Uses a MockHelper, GUID of 42, and 127.0.0.1:123.
+ // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
explicit MockConnection(bool is_server);
- // Uses a MockHelper, GUID of 42.
+ // Uses a MockHelper, ConnectionId of 42.
MockConnection(IPEndPoint address, bool is_server);
// Uses a MockHelper, and 127.0.0.1:123
- MockConnection(QuicGuid guid, bool is_server);
+ MockConnection(QuicConnectionId connection_id, bool is_server);
- // Uses a Mock helper, GUID of 42, and 127.0.0.1:123.
+ // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123.
MockConnection(bool is_server, const QuicVersionVector& supported_versions);
virtual ~MockConnection();
@@ -302,6 +303,9 @@ class MockConnection : public QuicConnection {
MOCK_METHOD3(SendGoAway, void(QuicErrorCode error,
QuicStreamId last_good_stream_id,
const string& reason));
+ MOCK_METHOD1(SendBlocked, void(QuicStreamId id));
+ MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id,
+ QuicStreamOffset byte_offset));
MOCK_METHOD0(OnCanWrite, void());
void ProcessUdpPacketInternal(const IPEndPoint& self_address,
@@ -437,6 +441,20 @@ class MockSendAlgorithm : public SendAlgorithmInterface {
DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm);
};
+class MockLossAlgorithm : public LossDetectionInterface {
+ public:
+ MockLossAlgorithm();
+ virtual ~MockLossAlgorithm();
+
+ MOCK_METHOD5(DetectLostPackets,
+ SequenceNumberSet(const QuicUnackedPacketMap& unacked_packets,
+ const QuicTime& time,
+ QuicPacketSequenceNumber largest_observed,
+ QuicTime::Delta srtt,
+ QuicTime::Delta latest_rtt));
+ MOCK_CONST_METHOD0(GetLossTimeout, QuicTime());
+};
+
class TestEntropyCalculator :
public QuicReceivedEntropyHashCalculatorInterface {
public:
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index 2e08a50..6492a59 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -31,7 +31,7 @@
#include "net/tools/quic/quic_server.h"
#include "net/tools/quic/quic_socket_utils.h"
#include "net/tools/quic/quic_spdy_client_stream.h"
-#include "net/tools/quic/test_tools/http_message_test_utils.h"
+#include "net/tools/quic/test_tools/http_message.h"
#include "net/tools/quic/test_tools/packet_dropping_test_writer.h"
#include "net/tools/quic/test_tools/quic_client_peer.h"
#include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc
index cdb15f0..5a6a51e 100644
--- a/net/tools/quic/quic_client.cc
+++ b/net/tools/quic/quic_client.cc
@@ -164,7 +164,7 @@ bool QuicClient::StartConnect() {
session_.reset(new QuicClientSession(
server_hostname_,
config_,
- new QuicConnection(GenerateGuid(), server_address_, helper_.get(),
+ new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(),
writer_.get(), false, supported_versions_),
&crypto_config_));
return session_->CryptoConnect();
@@ -282,7 +282,7 @@ bool QuicClient::connected() const {
session_->connection()->connected();
}
-QuicGuid QuicClient::GenerateGuid() {
+QuicConnectionId QuicClient::GenerateConnectionId() {
return QuicRandom::GetInstance()->RandUint64();
}
diff --git a/net/tools/quic/quic_client.h b/net/tools/quic/quic_client.h
index 0cd78e9..aec6679 100644
--- a/net/tools/quic/quic_client.h
+++ b/net/tools/quic/quic_client.h
@@ -168,7 +168,7 @@ class QuicClient : public EpollCallbackInterface,
}
protected:
- virtual QuicGuid GenerateGuid();
+ virtual QuicConnectionId GenerateConnectionId();
virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper();
virtual QuicPacketWriter* CreateQuicPacketWriter();
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc
index 48c5766..92e5d70 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -183,13 +183,13 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
const QuicPacketPublicHeader& header) {
QuicSession* session = NULL;
- QuicGuid guid = header.guid;
- SessionMap::iterator it = session_map_.find(guid);
+ QuicConnectionId connection_id = header.connection_id;
+ SessionMap::iterator it = session_map_.find(connection_id);
if (it == session_map_.end()) {
if (header.reset_flag) {
return false;
}
- if (time_wait_list_manager_->IsGuidInTimeWait(guid)) {
+ if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) {
return HandlePacketForTimeWait(header);
}
@@ -197,13 +197,14 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
// session for it. All initial packets for a new connection are required to
// have the flag set. Otherwise it may be a stray packet.
if (header.version_flag) {
- session = CreateQuicSession(guid, current_server_address_,
+ session = CreateQuicSession(connection_id, current_server_address_,
current_client_address_);
}
if (session == NULL) {
- DVLOG(1) << "Failed to create session for " << guid;
- // Add this guid fo the time-wait state, to safely reject future packets.
+ DVLOG(1) << "Failed to create session for " << connection_id;
+ // Add this connection_id fo the time-wait state, to safely reject future
+ // packets.
if (header.version_flag &&
!framer_.IsSupportedVersion(header.versions.front())) {
@@ -214,12 +215,13 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
// Use the version in the packet if possible, otherwise assume the latest.
QuicVersion version = header.version_flag ? header.versions.front() :
supported_versions_.front();
- time_wait_list_manager_->AddGuidToTimeWait(guid, version, NULL);
- DCHECK(time_wait_list_manager_->IsGuidInTimeWait(guid));
+ time_wait_list_manager_->AddConnectionIdToTimeWait(
+ connection_id, version, NULL);
+ DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
return HandlePacketForTimeWait(header);
}
- DVLOG(1) << "Created new session for " << guid;
- session_map_.insert(make_pair(guid, session));
+ DVLOG(1) << "Created new session for " << connection_id;
+ session_map_.insert(make_pair(connection_id, session));
} else {
session = it->second;
}
@@ -232,10 +234,11 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
}
void QuicDispatcher::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
- DCHECK(time_wait_list_manager_->IsGuidInTimeWait(header.public_header.guid));
+ DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(
+ header.public_header.connection_id));
time_wait_list_manager_->ProcessPacket(current_server_address_,
current_client_address_,
- header.public_header.guid,
+ header.public_header.connection_id,
header.packet_sequence_number);
}
@@ -244,9 +247,9 @@ void QuicDispatcher::CleanUpSession(SessionMap::iterator it) {
QuicEncryptedPacket* connection_close_packet =
connection->ReleaseConnectionClosePacket();
write_blocked_list_.erase(connection);
- time_wait_list_manager_->AddGuidToTimeWait(it->first,
- connection->version(),
- connection_close_packet);
+ time_wait_list_manager_->AddConnectionIdToTimeWait(it->first,
+ connection->version(),
+ connection_close_packet);
session_map_.erase(it);
}
@@ -290,16 +293,19 @@ void QuicDispatcher::Shutdown() {
DeleteSessions();
}
-void QuicDispatcher::OnConnectionClosed(QuicGuid guid, QuicErrorCode error) {
- SessionMap::iterator it = session_map_.find(guid);
+void QuicDispatcher::OnConnectionClosed(QuicConnectionId connection_id,
+ QuicErrorCode error) {
+ SessionMap::iterator it = session_map_.find(connection_id);
if (it == session_map_.end()) {
- LOG(DFATAL) << "GUID " << guid << " does not exist in the session map. "
+ LOG(DFATAL) << "ConnectionId " << connection_id
+ << " does not exist in the session map. "
<< "Error: " << QuicUtils::ErrorToString(error);
LOG(DFATAL) << base::debug::StackTrace().ToString();
return;
}
- DLOG_IF(INFO, error != QUIC_NO_ERROR) << "Closing connection (" << guid
+ DLOG_IF(INFO, error != QUIC_NO_ERROR) << "Closing connection ("
+ << connection_id
<< ") due to error: "
<< QuicUtils::ErrorToString(error);
@@ -326,23 +332,23 @@ QuicPacketWriterWrapper* QuicDispatcher::CreateWriterWrapper(
}
QuicSession* QuicDispatcher::CreateQuicSession(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address) {
QuicServerSession* session = new QuicServerSession(
config_,
- CreateQuicConnection(guid, server_address, client_address),
+ CreateQuicConnection(connection_id, server_address, client_address),
this);
session->InitializeSession(crypto_config_);
return session;
}
QuicConnection* QuicDispatcher::CreateQuicConnection(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address) {
- return new QuicConnection(guid, client_address, helper_.get(), writer_.get(),
- true, supported_versions_);
+ return new QuicConnection(connection_id, client_address, helper_.get(),
+ writer_.get(), true, supported_versions_);
}
void QuicDispatcher::set_writer(QuicPacketWriter* writer) {
@@ -358,8 +364,8 @@ bool QuicDispatcher::HandlePacketForTimeWait(
// Switch the framer to the correct version, so that the sequence number can
// be parsed correctly.
- framer_.set_version(time_wait_list_manager_->GetQuicVersionFromGuid(
- header.guid));
+ framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId(
+ header.connection_id));
// Continue parsing the packet to extract the sequence number. Then
// send it to the time wait manager in OnUnathenticatedHeader.
diff --git a/net/tools/quic/quic_dispatcher.h b/net/tools/quic/quic_dispatcher.h
index f536ea3..504b27d 100644
--- a/net/tools/quic/quic_dispatcher.h
+++ b/net/tools/quic/quic_dispatcher.h
@@ -86,12 +86,13 @@ class QuicDispatcher : public QuicServerSessionVisitor {
// QuicServerSessionVisitor interface implementation:
// Ensure that the closed connection is cleaned up asynchronously.
- virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) OVERRIDE;
+ virtual void OnConnectionClosed(QuicConnectionId connection_id,
+ QuicErrorCode error) OVERRIDE;
// Queues the blocked writer for later resumption.
virtual void OnWriteBlocked(QuicBlockedWriterInterface* writer) OVERRIDE;
- typedef base::hash_map<QuicGuid, QuicSession*> SessionMap;
+ typedef base::hash_map<QuicConnectionId, QuicSession*> SessionMap;
// Deletes all sessions on the closed session list and clears the list.
void DeleteSessions();
@@ -110,11 +111,11 @@ class QuicDispatcher : public QuicServerSessionVisitor {
virtual QuicPacketWriterWrapper* CreateWriterWrapper(
QuicPacketWriter* writer);
- virtual QuicSession* CreateQuicSession(QuicGuid guid,
+ virtual QuicSession* CreateQuicSession(QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address);
- QuicConnection* CreateQuicConnection(QuicGuid guid,
+ QuicConnection* CreateQuicConnection(QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address);
@@ -160,7 +161,7 @@ class QuicDispatcher : public QuicServerSessionVisitor {
void OnUnauthenticatedHeader(const QuicPacketHeader& header);
// Removes the session from the session map and write blocked list, and
- // adds the GUID to the time-wait list.
+ // adds the ConnectionId to the time-wait list.
void CleanUpSession(SessionMap::iterator it);
bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header);
@@ -174,7 +175,7 @@ class QuicDispatcher : public QuicServerSessionVisitor {
SessionMap session_map_;
- // Entity that manages guids in time wait state.
+ // Entity that manages connection_ids in time wait state.
scoped_ptr<QuicTimeWaitListManager> time_wait_list_manager_;
// An alarm which deletes closed sessions.
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc
index 5ab7b29..e894e1b5 100644
--- a/net/tools/quic/quic_dispatcher_test.cc
+++ b/net/tools/quic/quic_dispatcher_test.cc
@@ -47,7 +47,7 @@ class TestDispatcher : public QuicDispatcher {
}
MOCK_METHOD3(CreateQuicSession, QuicSession*(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address));
using QuicDispatcher::write_blocked_list;
@@ -59,24 +59,25 @@ class TestDispatcher : public QuicDispatcher {
// involve a lot more mocking.
class MockServerConnection : public MockConnection {
public:
- MockServerConnection(QuicGuid guid,
+ MockServerConnection(QuicConnectionId connection_id,
QuicDispatcher* dispatcher)
- : MockConnection(guid, true),
+ : MockConnection(connection_id, true),
dispatcher_(dispatcher) {}
void UnregisterOnConnectionClosed() {
- LOG(ERROR) << "Unregistering " << guid();
- dispatcher_->OnConnectionClosed(guid(), QUIC_NO_ERROR);
+ LOG(ERROR) << "Unregistering " << connection_id();
+ dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR);
}
private:
QuicDispatcher* dispatcher_;
};
QuicSession* CreateSession(QuicDispatcher* dispatcher,
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& addr,
MockSession** session) {
- MockServerConnection* connection = new MockServerConnection(guid, dispatcher);
+ MockServerConnection* connection =
+ new MockServerConnection(connection_id, dispatcher);
*session = new MockSession(connection);
ON_CALL(*connection, SendConnectionClose(_)).WillByDefault(
WithoutArgs(Invoke(
@@ -109,14 +110,14 @@ class QuicDispatcherTest : public ::testing::Test {
}
QuicEncryptedPacket* ConstructEncryptedPacket(
- QuicGuid guid,
+ QuicConnectionId connection_id,
bool version_flag,
bool reset_flag,
QuicPacketSequenceNumber sequence_number,
const string& data) {
QuicPacketHeader header;
- header.public_header.guid = guid;
- header.public_header.guid_length = PACKET_8BYTE_GUID;
+ header.public_header.connection_id = connection_id;
+ header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID;
header.public_header.version_flag = version_flag;
header.public_header.reset_flag = reset_flag;
header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER;
@@ -143,11 +144,11 @@ class QuicDispatcherTest : public ::testing::Test {
}
void ProcessPacket(IPEndPoint addr,
- QuicGuid guid,
+ QuicConnectionId connection_id,
bool has_version_flag,
const string& data) {
- scoped_ptr<QuicEncryptedPacket> packet(
- ConstructEncryptedPacket(guid, has_version_flag, false, 1, data));
+ scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
+ connection_id, has_version_flag, false, 1, data));
dispatcher_.ProcessPacket(IPEndPoint(), addr, *packet.get());
}
@@ -210,7 +211,7 @@ class MockTimeWaitListManager : public QuicTimeWaitListManager {
MOCK_METHOD4(ProcessPacket, void(const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number));
};
@@ -223,15 +224,15 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
time_wait_list_manager);
// Create a new session.
IPEndPoint addr(net::test::Loopback4(), 1);
- QuicGuid guid = 1;
- EXPECT_CALL(dispatcher_, CreateQuicSession(guid, _, addr))
+ QuicConnectionId connection_id = 1;
+ EXPECT_CALL(dispatcher_, CreateQuicSession(connection_id, _, addr))
.WillOnce(testing::Return(CreateSession(
- &dispatcher_, guid, addr, &session1_)));
- ProcessPacket(addr, guid, true, "foo");
+ &dispatcher_, connection_id, addr, &session1_)));
+ ProcessPacket(addr, connection_id, true, "foo");
// Close the connection by sending public reset packet.
QuicPublicResetPacket packet;
- packet.public_header.guid = guid;
+ packet.public_header.connection_id = connection_id;
packet.public_header.reset_flag = true;
packet.public_header.version_flag = false;
packet.rejected_sequence_number = 19191;
@@ -248,12 +249,13 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
reinterpret_cast<MockConnection*>(session1_->connection()),
&MockConnection::ReallyProcessUdpPacket));
dispatcher_.ProcessPacket(IPEndPoint(), addr, *encrypted);
- EXPECT_TRUE(time_wait_list_manager->IsGuidInTimeWait(guid));
+ EXPECT_TRUE(time_wait_list_manager->IsConnectionIdInTimeWait(connection_id));
- // Dispatcher forwards subsequent packets for this guid to the time wait list
- // manager.
- EXPECT_CALL(*time_wait_list_manager, ProcessPacket(_, _, guid, _)).Times(1);
- ProcessPacket(addr, guid, true, "foo");
+ // Dispatcher forwards subsequent packets for this connection_id to the time
+ // wait list manager.
+ EXPECT_CALL(*time_wait_list_manager,
+ ProcessPacket(_, _, connection_id, _)).Times(1);
+ ProcessPacket(addr, connection_id, true, "foo");
}
TEST_F(QuicDispatcherTest, StrayPacketToTimeWaitListManager) {
@@ -265,13 +267,14 @@ TEST_F(QuicDispatcherTest, StrayPacketToTimeWaitListManager) {
time_wait_list_manager);
IPEndPoint addr(net::test::Loopback4(), 1);
- QuicGuid guid = 1;
- // Dispatcher forwards all packets for this guid to the time wait list
- // manager.
+ QuicConnectionId connection_id = 1;
+ // Dispatcher forwards all packets for this connection_id to the time wait
+ // list manager.
EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0);
- EXPECT_CALL(*time_wait_list_manager, ProcessPacket(_, _, guid, _)).Times(1);
+ EXPECT_CALL(*time_wait_list_manager,
+ ProcessPacket(_, _, connection_id, _)).Times(1);
string data = "foo";
- ProcessPacket(addr, guid, false, "foo");
+ ProcessPacket(addr, connection_id, false, "foo");
}
class BlockingWriter : public QuicPacketWriterWrapper {
diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc
index b3e08f8..af46ca3 100644
--- a/net/tools/quic/quic_in_memory_cache.cc
+++ b/net/tools/quic/quic_in_memory_cache.cc
@@ -110,6 +110,18 @@ void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers,
responses_[GetKey(request_headers)] = new_response;
}
+void QuicInMemoryCache::AddSpecialResponse(StringPiece method,
+ StringPiece path,
+ StringPiece version,
+ SpecialResponseType response_type) {
+ BalsaHeaders request_headers, response_headers;
+ request_headers.SetRequestFirstlineFromStringPieces(method,
+ path,
+ version);
+ AddResponse(request_headers, response_headers, "");
+ responses_[GetKey(request_headers)]->response_type_ = response_type;
+}
+
QuicInMemoryCache::QuicInMemoryCache() {
Initialize();
}
diff --git a/net/tools/quic/quic_in_memory_cache.h b/net/tools/quic/quic_in_memory_cache.h
index 3be25a6..be091d5 100644
--- a/net/tools/quic/quic_in_memory_cache.h
+++ b/net/tools/quic/quic_in_memory_cache.h
@@ -32,12 +32,19 @@ class QuicServer;
// `wget -p --save_headers <url>`
class QuicInMemoryCache {
public:
+ enum SpecialResponseType {
+ REGULAR_RESPONSE, // Send the headers and body like a server should.
+ CLOSE_CONNECTION, // Close the connection (sending the close packet).
+ IGNORE_REQUEST, // Do nothing, expect the client to time out.
+ };
+
// Container for response header/body pairs.
class Response {
public:
- Response() {}
+ Response() : response_type_(REGULAR_RESPONSE) {}
~Response() {}
+ const SpecialResponseType response_type() const { return response_type_; }
const BalsaHeaders& headers() const { return headers_; }
const base::StringPiece body() const { return base::StringPiece(body_); }
@@ -51,6 +58,7 @@ class QuicInMemoryCache {
body.CopyToString(&body_);
}
+ SpecialResponseType response_type_;
BalsaHeaders headers_;
std::string body_;
@@ -79,6 +87,12 @@ class QuicInMemoryCache {
const BalsaHeaders& response_headers,
base::StringPiece response_body);
+ // Simulate a special behavior at a particular path.
+ void AddSpecialResponse(base::StringPiece method,
+ base::StringPiece path,
+ base::StringPiece version,
+ SpecialResponseType response_type);
+
private:
typedef base::hash_map<std::string, Response*> ResponseMap;
friend struct DefaultSingletonTraits<QuicInMemoryCache>;
diff --git a/net/tools/quic/quic_server.h b/net/tools/quic/quic_server.h
index cc0f215..76204d4 100644
--- a/net/tools/quic/quic_server.h
+++ b/net/tools/quic/quic_server.h
@@ -68,6 +68,12 @@ class QuicServer : public EpollCallbackInterface {
crypto_config_.set_strike_register_no_startup_period();
}
+ // SetProofSource sets the ProofSource that will be used to verify the
+ // server's certificate, and takes ownership of |source|.
+ void SetProofSource(ProofSource* source) {
+ crypto_config_.SetProofSource(source);
+ }
+
bool overflow_supported() { return overflow_supported_; }
uint32 packets_dropped() { return packets_dropped_; }
diff --git a/net/tools/quic/quic_server_session.cc b/net/tools/quic/quic_server_session.cc
index cb9b146..1213495 100644
--- a/net/tools/quic/quic_server_session.cc
+++ b/net/tools/quic/quic_server_session.cc
@@ -44,7 +44,7 @@ void QuicServerSession::OnConnectionClosed(QuicErrorCode error,
crypto_stream_.get() != NULL) {
crypto_stream_->CancelOutstandingCallbacks();
}
- visitor_->OnConnectionClosed(connection()->guid(), error);
+ visitor_->OnConnectionClosed(connection()->connection_id(), error);
}
void QuicServerSession::OnWriteBlocked() {
diff --git a/net/tools/quic/quic_server_session.h b/net/tools/quic/quic_server_session.h
index 288cc68..ffd8b0a 100644
--- a/net/tools/quic/quic_server_session.h
+++ b/net/tools/quic/quic_server_session.h
@@ -38,7 +38,8 @@ class QuicServerSessionVisitor {
public:
virtual ~QuicServerSessionVisitor() {}
- virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) = 0;
+ virtual void OnConnectionClosed(QuicConnectionId connection_id,
+ QuicErrorCode error) = 0;
virtual void OnWriteBlocked(QuicBlockedWriterInterface* writer) = 0;
};
diff --git a/net/tools/quic/quic_server_test.cc b/net/tools/quic/quic_server_test.cc
index 833c25f..e2d7c4f 100644
--- a/net/tools/quic/quic_server_test.cc
+++ b/net/tools/quic/quic_server_test.cc
@@ -39,9 +39,9 @@ class QuicServerDispatchPacketTest : public ::testing::Test {
TEST_F(QuicServerDispatchPacketTest, DispatchPacket) {
unsigned char valid_packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
diff --git a/net/tools/quic/quic_spdy_server_stream.cc b/net/tools/quic/quic_spdy_server_stream.cc
index bdae62f..f70987d 100644
--- a/net/tools/quic/quic_spdy_server_stream.cc
+++ b/net/tools/quic/quic_spdy_server_stream.cc
@@ -97,6 +97,17 @@ void QuicSpdyServerStream::SendResponse() {
return;
}
+ if (response->response_type() == QuicInMemoryCache::CLOSE_CONNECTION) {
+ DVLOG(1) << "Special response: closing connection.";
+ CloseConnection(QUIC_NO_ERROR);
+ return;
+ }
+
+ if (response->response_type() == QuicInMemoryCache::IGNORE_REQUEST) {
+ DVLOG(1) << "Special response: ignoring request.";
+ return;
+ }
+
DVLOG(1) << "Sending response for stream " << id();
SendHeadersAndBody(response->headers(), response->body());
}
diff --git a/net/tools/quic/quic_time_wait_list_manager.cc b/net/tools/quic/quic_time_wait_list_manager.cc
index b145e8a..780a473 100644
--- a/net/tools/quic/quic_time_wait_list_manager.cc
+++ b/net/tools/quic/quic_time_wait_list_manager.cc
@@ -27,23 +27,24 @@ namespace tools {
namespace {
-// Time period for which the guid should live in time wait state..
+// Time period for which the connection_id should live in time wait state..
const int kTimeWaitSeconds = 5;
} // namespace
// A very simple alarm that just informs the QuicTimeWaitListManager to clean
-// up old guids. This alarm should be unregistered and deleted before the
-// QuicTimeWaitListManager is deleted.
-class GuidCleanUpAlarm : public EpollAlarm {
+// up old connection_ids. This alarm should be unregistered and deleted before
+// the QuicTimeWaitListManager is deleted.
+class ConnectionIdCleanUpAlarm : public EpollAlarm {
public:
- explicit GuidCleanUpAlarm(QuicTimeWaitListManager* time_wait_list_manager)
+ explicit ConnectionIdCleanUpAlarm(
+ QuicTimeWaitListManager* time_wait_list_manager)
: time_wait_list_manager_(time_wait_list_manager) {
}
virtual int64 OnAlarm() OVERRIDE {
EpollAlarm::OnAlarm();
- time_wait_list_manager_->CleanUpOldGuids();
+ time_wait_list_manager_->CleanUpOldConnectionIds();
// Let the time wait manager register the alarm at appropriate time.
return 0;
}
@@ -55,7 +56,7 @@ class GuidCleanUpAlarm : public EpollAlarm {
// This class stores pending public reset packets to be sent to clients.
// server_address - server address on which a packet what was received for
-// a guid in time wait state.
+// a connection_id in time wait state.
// client_address - address of the client that sent that packet. Needed to send
// the public reset packet back to the client.
// packet - the pending public reset packet that is to be sent to the client.
@@ -89,43 +90,48 @@ QuicTimeWaitListManager::QuicTimeWaitListManager(
const QuicVersionVector& supported_versions)
: epoll_server_(epoll_server),
kTimeWaitPeriod_(QuicTime::Delta::FromSeconds(kTimeWaitSeconds)),
- guid_clean_up_alarm_(new GuidCleanUpAlarm(this)),
+ connection_id_clean_up_alarm_(new ConnectionIdCleanUpAlarm(this)),
clock_(epoll_server_),
writer_(writer),
visitor_(visitor) {
- SetGuidCleanUpAlarm();
+ SetConnectionIdCleanUpAlarm();
}
QuicTimeWaitListManager::~QuicTimeWaitListManager() {
- guid_clean_up_alarm_->UnregisterIfRegistered();
+ connection_id_clean_up_alarm_->UnregisterIfRegistered();
STLDeleteElements(&pending_packets_queue_);
- for (GuidMap::iterator it = guid_map_.begin(); it != guid_map_.end(); ++it) {
+ for (ConnectionIdMap::iterator it = connection_id_map_.begin();
+ it != connection_id_map_.end();
+ ++it) {
delete it->second.close_packet;
}
}
-void QuicTimeWaitListManager::AddGuidToTimeWait(
- QuicGuid guid,
+void QuicTimeWaitListManager::AddConnectionIdToTimeWait(
+ QuicConnectionId connection_id,
QuicVersion version,
QuicEncryptedPacket* close_packet) {
int num_packets = 0;
- GuidMap::iterator it = guid_map_.find(guid);
- if (it != guid_map_.end()) { // Replace record if it is reinserted.
+ ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
+ if (it != connection_id_map_.end()) { // Replace record if it is reinserted.
num_packets = it->second.num_packets;
delete it->second.close_packet;
- guid_map_.erase(it);
+ connection_id_map_.erase(it);
}
- GuidData data(num_packets, version, clock_.ApproximateNow(), close_packet);
- guid_map_.insert(make_pair(guid, data));
+ ConnectionIdData data(num_packets, version, clock_.ApproximateNow(),
+ close_packet);
+ connection_id_map_.insert(make_pair(connection_id, data));
}
-bool QuicTimeWaitListManager::IsGuidInTimeWait(QuicGuid guid) const {
- return guid_map_.find(guid) != guid_map_.end();
+bool QuicTimeWaitListManager::IsConnectionIdInTimeWait(
+ QuicConnectionId connection_id) const {
+ return ContainsKey(connection_id_map_, connection_id);
}
-QuicVersion QuicTimeWaitListManager::GetQuicVersionFromGuid(QuicGuid guid) {
- GuidMap::iterator it = guid_map_.find(guid);
- DCHECK(it != guid_map_.end());
+QuicVersion QuicTimeWaitListManager::GetQuicVersionFromConnectionId(
+ QuicConnectionId connection_id) {
+ ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
+ DCHECK(it != connection_id_map_.end());
return (it->second).version;
}
@@ -143,13 +149,13 @@ void QuicTimeWaitListManager::OnCanWrite() {
void QuicTimeWaitListManager::ProcessPacket(
const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number) {
- DCHECK(IsGuidInTimeWait(guid));
+ DCHECK(IsConnectionIdInTimeWait(connection_id));
// TODO(satyamshekhar): Think about handling packets from different client
// addresses.
- GuidMap::iterator it = guid_map_.find(guid);
- DCHECK(it != guid_map_.end());
+ ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
+ DCHECK(it != connection_id_map_.end());
// Increment the received packet count.
++((it->second).num_packets);
if (!ShouldSendResponse((it->second).num_packets)) {
@@ -163,12 +169,16 @@ void QuicTimeWaitListManager::ProcessPacket(
// Takes ownership of the packet.
SendOrQueuePacket(queued_packet);
} else {
- SendPublicReset(server_address, client_address, guid, sequence_number);
+ SendPublicReset(server_address,
+ client_address,
+ connection_id,
+ sequence_number);
}
}
-// Returns true if the number of packets received for this guid is a power of 2
-// to throttle the number of public reset packets we send to a client.
+// Returns true if the number of packets received for this connection_id is a
+// power of 2 to throttle the number of public reset packets we send to a
+// client.
bool QuicTimeWaitListManager::ShouldSendResponse(int received_packet_count) {
return (received_packet_count & (received_packet_count - 1)) == 0;
}
@@ -176,14 +186,14 @@ bool QuicTimeWaitListManager::ShouldSendResponse(int received_packet_count) {
void QuicTimeWaitListManager::SendPublicReset(
const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber rejected_sequence_number) {
QuicPublicResetPacket packet;
- packet.public_header.guid = guid;
+ packet.public_header.connection_id = connection_id;
packet.public_header.reset_flag = true;
packet.public_header.version_flag = false;
packet.rejected_sequence_number = rejected_sequence_number;
- // TODO(satyamshekhar): generate a valid nonce for this guid.
+ // TODO(satyamshekhar): generate a valid nonce for this connection_id.
packet.nonce_proof = 1010101;
packet.client_address = client_address;
QueuedPacket* queued_packet = new QueuedPacket(
@@ -228,42 +238,43 @@ bool QuicTimeWaitListManager::WriteToWire(QueuedPacket* queued_packet) {
return true;
}
-void QuicTimeWaitListManager::SetGuidCleanUpAlarm() {
- guid_clean_up_alarm_->UnregisterIfRegistered();
+void QuicTimeWaitListManager::SetConnectionIdCleanUpAlarm() {
+ connection_id_clean_up_alarm_->UnregisterIfRegistered();
int64 next_alarm_interval;
- if (!guid_map_.empty()) {
- QuicTime oldest_guid = guid_map_.begin()->second.time_added;
+ if (!connection_id_map_.empty()) {
+ QuicTime oldest_connection_id =
+ connection_id_map_.begin()->second.time_added;
QuicTime now = clock_.ApproximateNow();
- if (now.Subtract(oldest_guid) < kTimeWaitPeriod_) {
- next_alarm_interval = oldest_guid.Add(kTimeWaitPeriod_)
- .Subtract(now)
- .ToMicroseconds();
+ if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
+ next_alarm_interval = oldest_connection_id.Add(kTimeWaitPeriod_)
+ .Subtract(now)
+ .ToMicroseconds();
} else {
- LOG(ERROR) << "GUID lingered for longer than kTimeWaitPeriod";
+ LOG(ERROR) << "ConnectionId lingered for longer than kTimeWaitPeriod";
next_alarm_interval = 0;
}
} else {
- // No guids added so none will expire before kTimeWaitPeriod_.
+ // No connection_ids added so none will expire before kTimeWaitPeriod_.
next_alarm_interval = kTimeWaitPeriod_.ToMicroseconds();
}
- epoll_server_->RegisterAlarmApproximateDelta(next_alarm_interval,
- guid_clean_up_alarm_.get());
+ epoll_server_->RegisterAlarmApproximateDelta(
+ next_alarm_interval, connection_id_clean_up_alarm_.get());
}
-void QuicTimeWaitListManager::CleanUpOldGuids() {
+void QuicTimeWaitListManager::CleanUpOldConnectionIds() {
QuicTime now = clock_.ApproximateNow();
- while (!guid_map_.empty()) {
- GuidMap::iterator it = guid_map_.begin();
- QuicTime oldest_guid = it->second.time_added;
- if (now.Subtract(oldest_guid) < kTimeWaitPeriod_) {
+ while (!connection_id_map_.empty()) {
+ ConnectionIdMap::iterator it = connection_id_map_.begin();
+ QuicTime oldest_connection_id = it->second.time_added;
+ if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
break;
}
- // This guid has lived its age, retire it now.
+ // This connection_id has lived its age, retire it now.
delete it->second.close_packet;
- guid_map_.erase(it);
+ connection_id_map_.erase(it);
}
- SetGuidCleanUpAlarm();
+ SetConnectionIdCleanUpAlarm();
}
} // namespace tools
diff --git a/net/tools/quic/quic_time_wait_list_manager.h b/net/tools/quic/quic_time_wait_list_manager.h
index 4654045..3b29123 100644
--- a/net/tools/quic/quic_time_wait_list_manager.h
+++ b/net/tools/quic/quic_time_wait_list_manager.h
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Handles packets for guids in time wait state by discarding the packet and
-// sending the clients a public reset packet with exponential backoff.
+// Handles packets for connection_ids in time wait state by discarding the
+// packet and sending the clients a public reset packet with exponential
+// backoff.
#ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
#define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
@@ -24,21 +25,22 @@
namespace net {
namespace tools {
-class GuidCleanUpAlarm;
+class ConnectionIdCleanUpAlarm;
class QuicServerSessionVisitor;
namespace test {
class QuicTimeWaitListManagerPeer;
} // namespace test
-// Maintains a list of all guids that have been recently closed. A guid lives in
-// this state for kTimeWaitPeriod. All packets received for guids in this state
-// are handed over to the QuicTimeWaitListManager by the QuicDispatcher.
-// Decides whether to send a public reset packet, a copy of the previously sent
-// connection close packet, or nothing to the client which sent a packet
-// with the guid in time wait state. After the guid expires its time wait
-// period, a new connection/session will be created if a packet is received
-// for this guid.
+// Maintains a list of all connection_ids that have been recently closed. A
+// connection_id lives in this state for kTimeWaitPeriod. All packets received
+// for connection_ids in this state are handed over to the
+// QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a
+// public reset packet, a copy of the previously sent connection close packet,
+// or nothing to the client which sent a packet with the connection_id in time
+// wait state. After the connection_id expires its time wait period, a new
+// connection/session will be created if a packet is received for this
+// connection_id.
class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
public:
// writer - the entity that writes to the socket. (Owned by the dispatcher)
@@ -50,28 +52,29 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
const QuicVersionVector& supported_versions);
virtual ~QuicTimeWaitListManager();
- // Adds the given guid to time wait state for kTimeWaitPeriod. Henceforth,
- // any packet bearing this guid should not be processed while the guid remains
- // in this list. If a non-NULL |close_packet| is provided, it is sent again
- // when packets are received for added guids. If NULL, a public reset packet
- // is sent with the specified |version|. DCHECKs that guid is not already on
- // the list.
- void AddGuidToTimeWait(QuicGuid guid,
- QuicVersion version,
- QuicEncryptedPacket* close_packet); // Owned.
-
- // Returns true if the guid is in time wait state, false otherwise. Packets
- // received for this guid should not lead to creation of new QuicSessions.
- bool IsGuidInTimeWait(QuicGuid guid) const;
-
- // Called when a packet is received for a guid that is in time wait state.
- // Sends a public reset packet to the client which sent this guid. Sending
- // of the public reset packet is throttled by using exponential back off.
- // DCHECKs for the guid to be in time wait state.
- // virtual to override in tests.
+ // Adds the given connection_id to time wait state for kTimeWaitPeriod.
+ // Henceforth, any packet bearing this connection_id should not be processed
+ // while the connection_id remains in this list. If a non-NULL |close_packet|
+ // is provided, it is sent again when packets are received for added
+ // connection_ids. If NULL, a public reset packet is sent with the specified
+ // |version|. DCHECKs that connection_id is not already on the list.
+ void AddConnectionIdToTimeWait(QuicConnectionId connection_id,
+ QuicVersion version,
+ QuicEncryptedPacket* close_packet); // Owned.
+
+ // Returns true if the connection_id is in time wait state, false otherwise.
+ // Packets received for this connection_id should not lead to creation of new
+ // QuicSessions.
+ bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) const;
+
+ // Called when a packet is received for a connection_id that is in time wait
+ // state. Sends a public reset packet to the client which sent this
+ // connection_id. Sending of the public reset packet is throttled by using
+ // exponential back off. DCHECKs for the connection_id to be in time wait
+ // state. virtual to override in tests.
virtual void ProcessPacket(const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number);
// Called by the dispatcher when the underlying socket becomes writable again,
@@ -79,12 +82,13 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
// send because the underlying socket was write blocked.
virtual void OnCanWrite() OVERRIDE;
- // Used to delete guid entries that have outlived their time wait period.
- void CleanUpOldGuids();
+ // Used to delete connection_id entries that have outlived their time wait
+ // period.
+ void CleanUpOldConnectionIds();
- // Given a GUID that exists in the time wait list, returns the QuicVersion
- // associated with it.
- QuicVersion GetQuicVersionFromGuid(QuicGuid guid);
+ // Given a ConnectionId that exists in the time wait list, returns the
+ // QuicVersion associated with it.
+ QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id);
private:
friend class test::QuicTimeWaitListManagerPeer;
@@ -92,14 +96,14 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
// Internal structure to store pending public reset packets.
class QueuedPacket;
- // Decides if a packet should be sent for this guid based on the number of
- // received packets.
+ // Decides if a packet should be sent for this connection_id based on the
+ // number of received packets.
bool ShouldSendResponse(int received_packet_count);
// Creates a public reset packet and sends it or queues it to be sent later.
void SendPublicReset(const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber rejected_sequence_number);
// Either sends the packet and deletes it or makes pending_packets_queue_ the
@@ -113,15 +117,16 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
bool WriteToWire(QueuedPacket* packet);
// Register the alarm with the epoll server to wake up at appropriate time.
- void SetGuidCleanUpAlarm();
-
- // A map from a recently closed guid to the number of packets received after
- // the termination of the connection bound to the guid.
- struct GuidData {
- GuidData(int num_packets_,
- QuicVersion version_,
- QuicTime time_added_,
- QuicEncryptedPacket* close_packet)
+ void SetConnectionIdCleanUpAlarm();
+
+ // A map from a recently closed connection_id to the number of packets
+ // received after the termination of the connection bound to the
+ // connection_id.
+ struct ConnectionIdData {
+ ConnectionIdData(int num_packets_,
+ QuicVersion version_,
+ QuicTime time_added_,
+ QuicEncryptedPacket* close_packet)
: num_packets(num_packets_),
version(version_),
time_added(time_added_),
@@ -132,24 +137,24 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
QuicEncryptedPacket* close_packet;
};
- // linked_hash_map allows lookup by Guid and traversal in add order.
- typedef linked_hash_map<QuicGuid, GuidData> GuidMap;
- GuidMap guid_map_;
+ // linked_hash_map allows lookup by ConnectionId and traversal in add order.
+ typedef linked_hash_map<QuicConnectionId, ConnectionIdData> ConnectionIdMap;
+ ConnectionIdMap connection_id_map_;
// Pending public reset packets that need to be sent out to the client
// when we are given a chance to write by the dispatcher.
std::deque<QueuedPacket*> pending_packets_queue_;
- // Used to schedule alarms to delete old guids which have been in the list for
- // too long.
+ // Used to schedule alarms to delete old connection_ids which have been in the
+ // list for too long.
EpollServer* epoll_server_;
- // Time period for which guids should remain in time wait state.
+ // Time period for which connection_ids should remain in time wait state.
const QuicTime::Delta kTimeWaitPeriod_;
- // Alarm registered with the epoll server to clean up guids that have out
- // lived their duration in time wait state.
- scoped_ptr<GuidCleanUpAlarm> guid_clean_up_alarm_;
+ // Alarm registered with the epoll server to clean up connection_ids that have
+ // out lived their duration in time wait state.
+ scoped_ptr<ConnectionIdCleanUpAlarm> connection_id_clean_up_alarm_;
// Clock to efficiently measure approximate time from the epoll server.
QuicEpollClock clock_;
diff --git a/net/tools/quic/quic_time_wait_list_manager_test.cc b/net/tools/quic/quic_time_wait_list_manager_test.cc
index 9aac8b3..8d440f9 100644
--- a/net/tools/quic/quic_time_wait_list_manager_test.cc
+++ b/net/tools/quic/quic_time_wait_list_manager_test.cc
@@ -50,9 +50,10 @@ class QuicTimeWaitListManagerPeer {
return manager->kTimeWaitPeriod_;
}
- static QuicVersion GetQuicVersionFromGuid(QuicTimeWaitListManager* manager,
- QuicGuid guid) {
- return manager->GetQuicVersionFromGuid(guid);
+ static QuicVersion GetQuicVersionFromConnectionId(
+ QuicTimeWaitListManager* manager,
+ QuicConnectionId connection_id) {
+ return manager->GetQuicVersionFromConnectionId(connection_id);
}
};
@@ -70,7 +71,7 @@ class QuicTimeWaitListManagerTest : public testing::Test {
: time_wait_list_manager_(&writer_, &visitor_,
&epoll_server_, QuicSupportedVersions()),
framer_(QuicSupportedVersions(), QuicTime::Zero(), true),
- guid_(45),
+ connection_id_(45),
client_address_(net::test::TestPeerIPAddress(), kTestPort),
writer_is_blocked_(false) {}
@@ -83,34 +84,36 @@ class QuicTimeWaitListManagerTest : public testing::Test {
.WillRepeatedly(Return(false));
}
- void AddGuid(QuicGuid guid) {
- AddGuid(guid, net::test::QuicVersionMax(), NULL);
+ void AddConnectionId(QuicConnectionId connection_id) {
+ AddConnectionId(connection_id, net::test::QuicVersionMax(), NULL);
}
- void AddGuid(QuicGuid guid,
- QuicVersion version,
- QuicEncryptedPacket* packet) {
- time_wait_list_manager_.AddGuidToTimeWait(guid, version, packet);
+ void AddConnectionId(QuicConnectionId connection_id,
+ QuicVersion version,
+ QuicEncryptedPacket* packet) {
+ time_wait_list_manager_.AddConnectionIdToTimeWait(
+ connection_id, version, packet);
}
- bool IsGuidInTimeWait(QuicGuid guid) {
- return time_wait_list_manager_.IsGuidInTimeWait(guid);
+ bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) {
+ return time_wait_list_manager_.IsConnectionIdInTimeWait(connection_id);
}
- void ProcessPacket(QuicGuid guid, QuicPacketSequenceNumber sequence_number) {
+ void ProcessPacket(QuicConnectionId connection_id,
+ QuicPacketSequenceNumber sequence_number) {
time_wait_list_manager_.ProcessPacket(server_address_,
client_address_,
- guid,
+ connection_id,
sequence_number);
}
QuicEncryptedPacket* ConstructEncryptedPacket(
EncryptionLevel level,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number) {
QuicPacketHeader header;
- header.public_header.guid = guid;
- header.public_header.guid_length = PACKET_8BYTE_GUID;
+ header.public_header.connection_id = connection_id;
+ header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID;
header.public_header.version_flag = false;
header.public_header.reset_flag = false;
header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER;
@@ -139,7 +142,7 @@ class QuicTimeWaitListManagerTest : public testing::Test {
StrictMock<MockQuicServerSessionVisitor> visitor_;
QuicTimeWaitListManager time_wait_list_manager_;
QuicFramer framer_;
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
IPEndPoint server_address_;
IPEndPoint client_address_;
bool writer_is_blocked_;
@@ -148,9 +151,9 @@ class QuicTimeWaitListManagerTest : public testing::Test {
class ValidatePublicResetPacketPredicate
: public MatcherInterface<const std::tr1::tuple<const char*, int> > {
public:
- explicit ValidatePublicResetPacketPredicate(QuicGuid guid,
+ explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id,
QuicPacketSequenceNumber number)
- : guid_(guid), sequence_number_(number) {
+ : connection_id_(connection_id), sequence_number_(number) {
}
virtual bool MatchAndExplain(
@@ -165,7 +168,7 @@ class ValidatePublicResetPacketPredicate
std::tr1::get<1>(packet_buffer));
framer.ProcessPacket(encrypted);
QuicPublicResetPacket packet = visitor.public_reset_packet();
- return guid_ == packet.public_header.guid &&
+ return connection_id_ == packet.public_header.connection_id &&
packet.public_header.reset_flag && !packet.public_header.version_flag &&
sequence_number_ == packet.rejected_sequence_number &&
net::test::TestPeerIPAddress() == packet.client_address.address() &&
@@ -177,60 +180,61 @@ class ValidatePublicResetPacketPredicate
virtual void DescribeNegationTo(::std::ostream* os) const { }
private:
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
QuicPacketSequenceNumber sequence_number_;
};
Matcher<const std::tr1::tuple<const char*, int> > PublicResetPacketEq(
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number) {
- return MakeMatcher(new ValidatePublicResetPacketPredicate(guid,
+ return MakeMatcher(new ValidatePublicResetPacketPredicate(connection_id,
sequence_number));
}
-TEST_F(QuicTimeWaitListManagerTest, CheckGuidInTimeWait) {
- EXPECT_FALSE(IsGuidInTimeWait(guid_));
- AddGuid(guid_);
- EXPECT_TRUE(IsGuidInTimeWait(guid_));
+TEST_F(QuicTimeWaitListManagerTest, CheckConnectionIdInTimeWait) {
+ EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
+ AddConnectionId(connection_id_);
+ EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
}
TEST_F(QuicTimeWaitListManagerTest, SendConnectionClose) {
size_t kConnectionCloseLength = 100;
- AddGuid(guid_,
- net::test::QuicVersionMax(),
- new QuicEncryptedPacket(
- new char[kConnectionCloseLength], kConnectionCloseLength, true));
+ AddConnectionId(
+ connection_id_,
+ net::test::QuicVersionMax(),
+ new QuicEncryptedPacket(
+ new char[kConnectionCloseLength], kConnectionCloseLength, true));
const int kRandomSequenceNumber = 1;
EXPECT_CALL(writer_, WritePacket(_, kConnectionCloseLength,
server_address_.address(),
client_address_))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
- ProcessPacket(guid_, kRandomSequenceNumber);
+ ProcessPacket(connection_id_, kRandomSequenceNumber);
}
TEST_F(QuicTimeWaitListManagerTest, SendPublicReset) {
- AddGuid(guid_);
+ AddConnectionId(connection_id_);
const int kRandomSequenceNumber = 1;
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid_,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id_,
kRandomSequenceNumber)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
- ProcessPacket(guid_, kRandomSequenceNumber);
+ ProcessPacket(connection_id_, kRandomSequenceNumber);
}
TEST_F(QuicTimeWaitListManagerTest, SendPublicResetWithExponentialBackOff) {
- AddGuid(guid_);
+ AddConnectionId(connection_id_);
for (int sequence_number = 1; sequence_number < 101; ++sequence_number) {
if ((sequence_number & (sequence_number - 1)) == 0) {
EXPECT_CALL(writer_, WritePacket(_, _, _, _))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
}
- ProcessPacket(guid_, sequence_number);
+ ProcessPacket(connection_id_, sequence_number);
// Send public reset with exponential back off.
if ((sequence_number & (sequence_number - 1)) == 0) {
EXPECT_TRUE(QuicTimeWaitListManagerPeer::ShouldSendResponse(
@@ -242,94 +246,103 @@ TEST_F(QuicTimeWaitListManagerTest, SendPublicResetWithExponentialBackOff) {
}
}
-TEST_F(QuicTimeWaitListManagerTest, CleanUpOldGuids) {
- const int kGuidCount = 100;
- const int kOldGuidCount = 31;
+TEST_F(QuicTimeWaitListManagerTest, CleanUpOldConnectionIds) {
+ const int kConnectionIdCount = 100;
+ const int kOldConnectionIdCount = 31;
- // Add guids such that their expiry time is kTimeWaitPeriod_.
+ // Add connection_ids such that their expiry time is kTimeWaitPeriod_.
epoll_server_.set_now_in_usec(0);
- for (int guid = 1; guid <= kOldGuidCount; ++guid) {
- AddGuid(guid);
+ for (int connection_id = 1;
+ connection_id <= kOldConnectionIdCount;
+ ++connection_id) {
+ AddConnectionId(connection_id);
}
- // Add remaining guids such that their add time is 2 * kTimeWaitPeriod.
+ // Add remaining connection_ids such that their add time is
+ // 2 * kTimeWaitPeriod.
const QuicTime::Delta time_wait_period =
QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_);
epoll_server_.set_now_in_usec(time_wait_period.ToMicroseconds());
- for (int guid = kOldGuidCount + 1; guid <= kGuidCount; ++guid) {
- AddGuid(guid);
+ for (int connection_id = kOldConnectionIdCount + 1;
+ connection_id <= kConnectionIdCount;
+ ++connection_id) {
+ AddConnectionId(connection_id);
}
QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39);
// Now set the current time as time_wait_period + offset usecs.
epoll_server_.set_now_in_usec(time_wait_period.Add(offset).ToMicroseconds());
- // After all the old guids are cleaned up, check the next alarm interval.
+ // After all the old connection_ids are cleaned up, check the next alarm
+ // interval.
int64 next_alarm_time = epoll_server_.ApproximateNowInUsec() +
time_wait_period.Subtract(offset).ToMicroseconds();
EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _));
- time_wait_list_manager_.CleanUpOldGuids();
- for (int guid = 1; guid <= kGuidCount; ++guid) {
- EXPECT_EQ(guid > kOldGuidCount, IsGuidInTimeWait(guid))
- << "kOldGuidCount: " << kOldGuidCount
- << " guid: " << guid;
+ time_wait_list_manager_.CleanUpOldConnectionIds();
+ for (int connection_id = 1;
+ connection_id <= kConnectionIdCount;
+ ++connection_id) {
+ EXPECT_EQ(connection_id > kOldConnectionIdCount,
+ IsConnectionIdInTimeWait(connection_id))
+ << "kOldConnectionIdCount: " << kOldConnectionIdCount
+ << " connection_id: " << connection_id;
}
}
TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) {
- QuicGuid guid = 1;
- AddGuid(guid);
+ QuicConnectionId connection_id = 1;
+ AddConnectionId(connection_id);
QuicPacketSequenceNumber sequence_number = 234;
- scoped_ptr<QuicEncryptedPacket> packet(
- ConstructEncryptedPacket(ENCRYPTION_NONE, guid, sequence_number));
+ scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
+ ENCRYPTION_NONE, connection_id, sequence_number));
// Let first write through.
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id,
sequence_number)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
- ProcessPacket(guid, sequence_number);
+ ProcessPacket(connection_id, sequence_number);
// write block for the next packet.
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id,
sequence_number)))
.WillOnce(DoAll(
Assign(&writer_is_blocked_, true),
Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN))));
EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
- ProcessPacket(guid, sequence_number);
+ ProcessPacket(connection_id, sequence_number);
// 3rd packet. No public reset should be sent;
- ProcessPacket(guid, sequence_number);
+ ProcessPacket(connection_id, sequence_number);
// write packet should not be called since we are write blocked but the
// should be queued.
- QuicGuid other_guid = 2;
- AddGuid(other_guid);
+ QuicConnectionId other_connection_id = 2;
+ AddConnectionId(other_connection_id);
QuicPacketSequenceNumber other_sequence_number = 23423;
scoped_ptr<QuicEncryptedPacket> other_packet(
ConstructEncryptedPacket(
- ENCRYPTION_NONE, other_guid, other_sequence_number));
+ ENCRYPTION_NONE, other_connection_id, other_sequence_number));
EXPECT_CALL(writer_, WritePacket(_, _, _, _))
.Times(0);
EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
- ProcessPacket(other_guid, other_sequence_number);
+ ProcessPacket(other_connection_id, other_sequence_number);
// Now expect all the write blocked public reset packets to be sent again.
writer_is_blocked_ = false;
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id,
sequence_number)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(other_guid,
+ .With(Args<0, 1>(PublicResetPacketEq(other_connection_id,
other_sequence_number)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK,
other_packet->length())));
@@ -337,36 +350,37 @@ TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) {
}
TEST_F(QuicTimeWaitListManagerTest, GetQuicVersionFromMap) {
- const int kGuid1 = 123;
- const int kGuid2 = 456;
- const int kGuid3 = 789;
+ const int kConnectionId1 = 123;
+ const int kConnectionId2 = 456;
+ const int kConnectionId3 = 789;
- AddGuid(kGuid1, net::test::QuicVersionMin(), NULL);
- AddGuid(kGuid2, net::test::QuicVersionMax(), NULL);
- AddGuid(kGuid3, net::test::QuicVersionMax(), NULL);
+ AddConnectionId(kConnectionId1, net::test::QuicVersionMin(), NULL);
+ AddConnectionId(kConnectionId2, net::test::QuicVersionMax(), NULL);
+ AddConnectionId(kConnectionId3, net::test::QuicVersionMax(), NULL);
EXPECT_EQ(net::test::QuicVersionMin(),
- QuicTimeWaitListManagerPeer::GetQuicVersionFromGuid(
- &time_wait_list_manager_, kGuid1));
+ QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
+ &time_wait_list_manager_, kConnectionId1));
EXPECT_EQ(net::test::QuicVersionMax(),
- QuicTimeWaitListManagerPeer::GetQuicVersionFromGuid(
- &time_wait_list_manager_, kGuid2));
+ QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
+ &time_wait_list_manager_, kConnectionId2));
EXPECT_EQ(net::test::QuicVersionMax(),
- QuicTimeWaitListManagerPeer::GetQuicVersionFromGuid(
- &time_wait_list_manager_, kGuid3));
+ QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
+ &time_wait_list_manager_, kConnectionId3));
}
-TEST_F(QuicTimeWaitListManagerTest, AddGuidTwice) {
- // Add guids such that their expiry time is kTimeWaitPeriod_.
+TEST_F(QuicTimeWaitListManagerTest, AddConnectionIdTwice) {
+ // Add connection_ids such that their expiry time is kTimeWaitPeriod_.
epoll_server_.set_now_in_usec(0);
- AddGuid(guid_);
- EXPECT_TRUE(IsGuidInTimeWait(guid_));
+ AddConnectionId(connection_id_);
+ EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
size_t kConnectionCloseLength = 100;
- AddGuid(guid_,
- net::test::QuicVersionMax(),
- new QuicEncryptedPacket(
- new char[kConnectionCloseLength], kConnectionCloseLength, true));
- EXPECT_TRUE(IsGuidInTimeWait(guid_));
+ AddConnectionId(
+ connection_id_,
+ net::test::QuicVersionMax(),
+ new QuicEncryptedPacket(
+ new char[kConnectionCloseLength], kConnectionCloseLength, true));
+ EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
EXPECT_CALL(writer_, WritePacket(_,
kConnectionCloseLength,
@@ -375,7 +389,7 @@ TEST_F(QuicTimeWaitListManagerTest, AddGuidTwice) {
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
const int kRandomSequenceNumber = 1;
- ProcessPacket(guid_, kRandomSequenceNumber);
+ ProcessPacket(connection_id_, kRandomSequenceNumber);
const QuicTime::Delta time_wait_period =
QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_);
@@ -383,30 +397,30 @@ TEST_F(QuicTimeWaitListManagerTest, AddGuidTwice) {
QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39);
// Now set the current time as time_wait_period + offset usecs.
epoll_server_.set_now_in_usec(time_wait_period.Add(offset).ToMicroseconds());
- // After the guids are cleaned up, check the next alarm interval.
+ // After the connection_ids are cleaned up, check the next alarm interval.
int64 next_alarm_time = epoll_server_.ApproximateNowInUsec() +
time_wait_period.ToMicroseconds();
EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _));
- time_wait_list_manager_.CleanUpOldGuids();
- EXPECT_FALSE(IsGuidInTimeWait(guid_));
+ time_wait_list_manager_.CleanUpOldConnectionIds();
+ EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
}
-TEST_F(QuicTimeWaitListManagerTest, GuidsOrderedByTime) {
- // Simple randomization: the values of guids are swapped based on the current
- // seconds on the clock. If the container is broken, the test will be 50%
- // flaky.
+TEST_F(QuicTimeWaitListManagerTest, ConnectionIdsOrderedByTime) {
+ // Simple randomization: the values of connection_ids are swapped based on the
+ // current seconds on the clock. If the container is broken, the test will be
+ // 50% flaky.
int odd_second = static_cast<int>(epoll_server_.ApproximateNowInUsec()) % 2;
EXPECT_TRUE(odd_second == 0 || odd_second == 1);
- const QuicGuid kGuid1 = odd_second;
- const QuicGuid kGuid2 = 1 - odd_second;
+ const QuicConnectionId kConnectionId1 = odd_second;
+ const QuicConnectionId kConnectionId2 = 1 - odd_second;
// 1 will hash lower than 2, but we add it later. They should come out in the
// add order, not hash order.
epoll_server_.set_now_in_usec(0);
- AddGuid(kGuid1);
+ AddConnectionId(kConnectionId1);
epoll_server_.set_now_in_usec(10);
- AddGuid(kGuid2);
+ AddConnectionId(kConnectionId2);
const QuicTime::Delta time_wait_period =
QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_);
@@ -414,9 +428,9 @@ TEST_F(QuicTimeWaitListManagerTest, GuidsOrderedByTime) {
EXPECT_CALL(epoll_server_, RegisterAlarm(_, _));
- time_wait_list_manager_.CleanUpOldGuids();
- EXPECT_FALSE(IsGuidInTimeWait(kGuid1));
- EXPECT_TRUE(IsGuidInTimeWait(kGuid2));
+ time_wait_list_manager_.CleanUpOldConnectionIds();
+ EXPECT_FALSE(IsConnectionIdInTimeWait(kConnectionId1));
+ EXPECT_TRUE(IsConnectionIdInTimeWait(kConnectionId2));
}
} // namespace
} // namespace test
diff --git a/net/tools/quic/test_tools/http_message_test_utils.cc b/net/tools/quic/test_tools/http_message.cc
index 70eb592..9bd3cff 100644
--- a/net/tools/quic/test_tools/http_message_test_utils.cc
+++ b/net/tools/quic/test_tools/http_message.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/tools/quic/test_tools/http_message_test_utils.h"
+#include "net/tools/quic/test_tools/http_message.h"
#include <vector>
diff --git a/net/tools/quic/test_tools/http_message_test_utils.h b/net/tools/quic/test_tools/http_message.h
index fefdb49..6b63daf 100644
--- a/net/tools/quic/test_tools/http_message_test_utils.h
+++ b/net/tools/quic/test_tools/http_message.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_TEST_UTILS_H_
-#define NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_TEST_UTILS_H_
+#ifndef NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_H_
+#define NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_H_
#include <string>
#include <vector>
@@ -130,4 +130,4 @@ class HTTPMessage {
} // namespace tools
} // namespace net
-#endif // NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_TEST_UTILS_H_
+#endif // NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_H_
diff --git a/net/tools/quic/test_tools/quic_test_client.cc b/net/tools/quic/test_tools/quic_test_client.cc
index aac75ab..8cfeefb 100644
--- a/net/tools/quic/test_tools/quic_test_client.cc
+++ b/net/tools/quic/test_tools/quic_test_client.cc
@@ -15,7 +15,7 @@
#include "net/tools/quic/quic_epoll_connection_helper.h"
#include "net/tools/quic/quic_packet_writer_wrapper.h"
#include "net/tools/quic/quic_spdy_client_stream.h"
-#include "net/tools/quic/test_tools/http_message_test_utils.h"
+#include "net/tools/quic/test_tools/http_message.h"
#include "net/tools/quic/test_tools/quic_client_peer.h"
#include "url/gurl.h"
@@ -102,7 +102,7 @@ class MockableQuicClient : public QuicClient {
const string& server_hostname,
const QuicVersionVector& supported_versions)
: QuicClient(server_address, server_hostname, supported_versions, false),
- override_guid_(0),
+ override_connection_id_(0),
test_writer_(NULL) {}
MockableQuicClient(IPEndPoint server_address,
@@ -110,7 +110,7 @@ class MockableQuicClient : public QuicClient {
const QuicConfig& config,
const QuicVersionVector& supported_versions)
: QuicClient(server_address, server_hostname, config, supported_versions),
- override_guid_(0),
+ override_connection_id_(0),
test_writer_(NULL) {}
virtual ~MockableQuicClient() {
@@ -128,17 +128,20 @@ class MockableQuicClient : public QuicClient {
return test_writer_;
}
- virtual QuicGuid GenerateGuid() OVERRIDE {
- return override_guid_ ? override_guid_ : QuicClient::GenerateGuid();
+ virtual QuicConnectionId GenerateConnectionId() OVERRIDE {
+ return override_connection_id_ ? override_connection_id_
+ : QuicClient::GenerateConnectionId();
}
// Takes ownership of writer.
void UseWriter(QuicPacketWriterWrapper* writer) { test_writer_ = writer; }
- void UseGuid(QuicGuid guid) { override_guid_ = guid; }
+ void UseConnectionId(QuicConnectionId connection_id) {
+ override_connection_id_ = connection_id;
+ }
private:
- QuicGuid override_guid_; // GUID to use, if nonzero
+ QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero
QuicPacketWriterWrapper* test_writer_;
};
@@ -445,9 +448,9 @@ void QuicTestClient::UseWriter(QuicPacketWriterWrapper* writer) {
client_->UseWriter(writer);
}
-void QuicTestClient::UseGuid(QuicGuid guid) {
+void QuicTestClient::UseConnectionId(QuicConnectionId connection_id) {
DCHECK(!connected());
- client_->UseGuid(guid);
+ client_->UseConnectionId(connection_id);
}
void QuicTestClient::WaitForWriteToFlush() {
diff --git a/net/tools/quic/test_tools/quic_test_client.h b/net/tools/quic/test_tools/quic_test_client.h
index b750cbff..fd1f4c4 100644
--- a/net/tools/quic/test_tools/quic_test_client.h
+++ b/net/tools/quic/test_tools/quic_test_client.h
@@ -89,9 +89,9 @@ class QuicTestClient : public QuicDataStream::Visitor {
// Configures client_ to take ownership of and use the writer.
// Must be called before initial connect.
void UseWriter(QuicPacketWriterWrapper* writer);
- // If the given GUID is nonzero, configures client_ to use a specific GUID
- // instead of a random one.
- void UseGuid(QuicGuid guid);
+ // If the given ConnectionId is nonzero, configures client_ to use a specific
+ // ConnectionId instead of a random one.
+ void UseConnectionId(QuicConnectionId connection_id);
// Returns NULL if the maximum number of streams have already been created.
QuicSpdyClientStream* GetOrCreateStream();
diff --git a/net/tools/quic/test_tools/quic_test_utils.cc b/net/tools/quic/test_tools/quic_test_utils.cc
index 9b82b9d..9ae1a3d 100644
--- a/net/tools/quic/test_tools/quic_test_utils.cc
+++ b/net/tools/quic/test_tools/quic_test_utils.cc
@@ -18,7 +18,7 @@ namespace tools {
namespace test {
MockConnection::MockConnection(bool is_server)
- : QuicConnection(kTestGuid,
+ : QuicConnection(kTestConnectionId,
IPEndPoint(net::test::Loopback4(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
@@ -29,7 +29,7 @@ MockConnection::MockConnection(bool is_server)
MockConnection::MockConnection(IPEndPoint address,
bool is_server)
- : QuicConnection(kTestGuid, address,
+ : QuicConnection(kTestConnectionId, address,
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
is_server, QuicSupportedVersions()),
@@ -37,9 +37,9 @@ MockConnection::MockConnection(IPEndPoint address,
helper_(helper()) {
}
-MockConnection::MockConnection(QuicGuid guid,
+MockConnection::MockConnection(QuicConnectionId connection_id,
bool is_server)
- : QuicConnection(guid,
+ : QuicConnection(connection_id,
IPEndPoint(net::test::Loopback4(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
@@ -50,7 +50,7 @@ MockConnection::MockConnection(QuicGuid guid,
MockConnection::MockConnection(bool is_server,
const QuicVersionVector& supported_versions)
- : QuicConnection(kTestGuid,
+ : QuicConnection(kTestConnectionId,
IPEndPoint(net::test::Loopback4(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
diff --git a/net/tools/quic/test_tools/quic_test_utils.h b/net/tools/quic/test_tools/quic_test_utils.h
index e2f9c57..da8c269 100644
--- a/net/tools/quic/test_tools/quic_test_utils.h
+++ b/net/tools/quic/test_tools/quic_test_utils.h
@@ -26,7 +26,7 @@ class IPEndPoint;
namespace tools {
namespace test {
-static const QuicGuid kTestGuid = 42;
+static const QuicConnectionId kTestConnectionId = 42;
static const int kTestPort = 123;
// Simple random number generator used to compute random numbers suitable
@@ -48,16 +48,16 @@ class SimpleRandom {
class MockConnection : public QuicConnection {
public:
- // Uses a MockHelper, GUID of 42, and 127.0.0.1:123.
+ // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
explicit MockConnection(bool is_server);
- // Uses a MockHelper, GUID of 42.
+ // Uses a MockHelper, ConnectionId of 42.
MockConnection(IPEndPoint address, bool is_server);
// Uses a MockHelper, and 127.0.0.1:123
- MockConnection(QuicGuid guid, bool is_server);
+ MockConnection(QuicConnectionId connection_id, bool is_server);
- // Uses a Mock helper, GUID of 42, and 127.0.0.1:123.
+ // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123.
MockConnection(bool is_server, const QuicVersionVector& supported_versions);
virtual ~MockConnection();
@@ -79,6 +79,9 @@ class MockConnection : public QuicConnection {
MOCK_METHOD3(SendGoAway, void(QuicErrorCode error,
QuicStreamId last_good_stream_id,
const std::string& reason));
+ MOCK_METHOD1(SendBlocked, void(QuicStreamId id));
+ MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id,
+ QuicStreamOffset byte_offset));
MOCK_METHOD0(OnCanWrite, void());
MOCK_CONST_METHOD0(HasPendingWrites, bool());
@@ -133,7 +136,8 @@ class MockQuicServerSessionVisitor : public QuicServerSessionVisitor {
public:
MockQuicServerSessionVisitor();
virtual ~MockQuicServerSessionVisitor();
- MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error));
+ MOCK_METHOD2(OnConnectionClosed, void(QuicConnectionId connection_id,
+ QuicErrorCode error));
MOCK_METHOD1(OnWriteBlocked, void(QuicBlockedWriterInterface* writer));
};