summaryrefslogtreecommitdiffstats
path: root/net/quic
diff options
context:
space:
mode:
Diffstat (limited to 'net/quic')
-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
59 files changed, 1286 insertions, 652 deletions
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: