summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrtenneti <rtenneti@chromium.org>2014-09-03 14:52:11 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-03 22:53:24 +0000
commit16142b6bac36b5058f36d89e96c9f7c8ad8bf707 (patch)
treece87c87c7591d2874bbc2b1c2e4f65018ae3ca3a /net
parent0b08967cc3c1a8e6bc17921201553bb6d8a7bb90 (diff)
downloadchromium_src-16142b6bac36b5058f36d89e96c9f7c8ad8bf707.zip
chromium_src-16142b6bac36b5058f36d89e96c9f7c8ad8bf707.tar.gz
chromium_src-16142b6bac36b5058f36d89e96c9f7c8ad8bf707.tar.bz2
Landing Recent QUIC Changes.
Remove unused QUIC_VERSION_20. We are already speaking QUIC_VERSION_21 in the wild, and QUIC_VERSION_20 was never intended to be used. Not much code removed in this CL, but should make end to end tests a bit faster. Merge internal change: 74594489 https://codereview.chromium.org/532093002/ Change GetLeastUnacked() to return the next packet that could be sent when there are no packets in flight instead of 0. This should help solve the problem we are seeing in trace logs from internal servers where the ack line drops to 0. Merge internal change: 74396185 https://codereview.chromium.org/530343002/ Change IsRetransmittable to not check transmission type but instead let ShouldDiscardPacket check it directly. Merge internal change: 74359363 https://codereview.chromium.org/536743002/ Change the QUIC CongestionMap to be based on a vector. Saves ~0.75% CPU when profiling. Merge internal change: 74321352 https://codereview.chromium.org/528083004/ Some improvements to quic_client_bin. - user can supply specific version - added a number of comments - added a number of descriptive ERROR logs on failure - removed unneeded flow control options (SetDefaults covers this) Merge internal change: 74309904 https://codereview.chromium.org/532073002/ R=rch@chromium.org Review URL: https://codereview.chromium.org/530343003 Cr-Commit-Position: refs/heads/master@{#293208}
Diffstat (limited to 'net')
-rw-r--r--net/quic/congestion_control/pacing_sender.cc4
-rw-r--r--net/quic/congestion_control/pacing_sender.h4
-rw-r--r--net/quic/congestion_control/pacing_sender_test.cc6
-rw-r--r--net/quic/congestion_control/send_algorithm_interface.h8
-rw-r--r--net/quic/congestion_control/send_algorithm_simulator.cc11
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender.cc8
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender.h4
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender_test.cc22
-rw-r--r--net/quic/quic_connection.cc29
-rw-r--r--net/quic/quic_connection.h6
-rw-r--r--net/quic/quic_crypto_stream.cc2
-rw-r--r--net/quic/quic_crypto_stream_test.cc2
-rw-r--r--net/quic/quic_headers_stream.cc2
-rw-r--r--net/quic/quic_headers_stream_test.cc2
-rw-r--r--net/quic/quic_protocol.cc3
-rw-r--r--net/quic/quic_protocol.h2
-rw-r--r--net/quic/quic_sent_packet_manager.cc12
-rw-r--r--net/quic/quic_sent_packet_manager.h10
-rw-r--r--net/quic/quic_sent_packet_manager_test.cc24
-rw-r--r--net/quic/quic_session.cc8
-rw-r--r--net/quic/quic_unacked_packet_map.cc4
-rw-r--r--net/quic/reliable_quic_stream.cc2
-rw-r--r--net/quic/reliable_quic_stream.h2
-rw-r--r--net/quic/test_tools/quic_test_utils.h4
-rw-r--r--net/tools/quic/end_to_end_test.cc2
-rw-r--r--net/tools/quic/quic_client_bin.cc72
26 files changed, 131 insertions, 124 deletions
diff --git a/net/quic/congestion_control/pacing_sender.cc b/net/quic/congestion_control/pacing_sender.cc
index cc4f983..002db98 100644
--- a/net/quic/congestion_control/pacing_sender.cc
+++ b/net/quic/congestion_control/pacing_sender.cc
@@ -36,8 +36,8 @@ void PacingSender::OnIncomingQuicCongestionFeedbackFrame(
void PacingSender::OnCongestionEvent(bool rtt_updated,
QuicByteCount bytes_in_flight,
- const CongestionMap& acked_packets,
- const CongestionMap& lost_packets) {
+ const CongestionVector& acked_packets,
+ const CongestionVector& lost_packets) {
if (rtt_updated) {
has_valid_rtt_ = true;
}
diff --git a/net/quic/congestion_control/pacing_sender.h b/net/quic/congestion_control/pacing_sender.h
index 3fef6f89..e642a51 100644
--- a/net/quic/congestion_control/pacing_sender.h
+++ b/net/quic/congestion_control/pacing_sender.h
@@ -41,8 +41,8 @@ class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface {
QuicTime feedback_receive_time) OVERRIDE;
virtual void OnCongestionEvent(bool rtt_updated,
QuicByteCount bytes_in_flight,
- const CongestionMap& acked_packets,
- const CongestionMap& lost_packets) OVERRIDE;
+ const CongestionVector& acked_packets,
+ const CongestionVector& lost_packets) OVERRIDE;
virtual bool OnPacketSent(QuicTime sent_time,
QuicByteCount bytes_in_flight,
QuicPacketSequenceNumber sequence_number,
diff --git a/net/quic/congestion_control/pacing_sender_test.cc b/net/quic/congestion_control/pacing_sender_test.cc
index 026905d..768cc22 100644
--- a/net/quic/congestion_control/pacing_sender_test.cc
+++ b/net/quic/congestion_control/pacing_sender_test.cc
@@ -149,7 +149,7 @@ TEST_F(PacingSenderTest, VariousSending) {
// Now update the RTT and verify that packets are actually paced.
EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytesInFlight, _, _));
- SendAlgorithmInterface::CongestionMap empty_map;
+ SendAlgorithmInterface::CongestionVector empty_map;
pacing_sender_->OnCongestionEvent(true, kBytesInFlight, empty_map, empty_map);
CheckPacketIsSentImmediately();
@@ -224,7 +224,7 @@ TEST_F(PacingSenderTest, CongestionAvoidanceSending) {
// Now update the RTT and verify that packets are actually paced.
EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytesInFlight, _, _));
- SendAlgorithmInterface::CongestionMap empty_map;
+ SendAlgorithmInterface::CongestionVector empty_map;
pacing_sender_->OnCongestionEvent(true, kBytesInFlight, empty_map, empty_map);
CheckPacketIsSentImmediately();
@@ -292,7 +292,7 @@ TEST_F(PacingSenderTest, InitialBurst) {
// Update the RTT and verify that the first 10 packets aren't paced.
EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytesInFlight, _, _));
- SendAlgorithmInterface::CongestionMap empty_map;
+ SendAlgorithmInterface::CongestionVector empty_map;
pacing_sender_->OnCongestionEvent(true, kBytesInFlight, empty_map, empty_map);
// Send 10 packets, and verify that they are not paced.
diff --git a/net/quic/congestion_control/send_algorithm_interface.h b/net/quic/congestion_control/send_algorithm_interface.h
index 5d1f6df..24d965d 100644
--- a/net/quic/congestion_control/send_algorithm_interface.h
+++ b/net/quic/congestion_control/send_algorithm_interface.h
@@ -25,7 +25,9 @@ class RttStats;
class NET_EXPORT_PRIVATE SendAlgorithmInterface {
public:
- typedef std::map<QuicPacketSequenceNumber, TransmissionInfo> CongestionMap;
+ // A sorted vector of packets.
+ typedef std::vector<std::pair<QuicPacketSequenceNumber, TransmissionInfo>>
+ CongestionVector;
static SendAlgorithmInterface* Create(const QuicClock* clock,
const RttStats* rtt_stats,
@@ -48,8 +50,8 @@ class NET_EXPORT_PRIVATE SendAlgorithmInterface {
// any packets considered acked or lost as a result of the congestion event.
virtual void OnCongestionEvent(bool rtt_updated,
QuicByteCount bytes_in_flight,
- const CongestionMap& acked_packets,
- const CongestionMap& lost_packets) = 0;
+ const CongestionVector& acked_packets,
+ const CongestionVector& lost_packets) = 0;
// Inform that we sent |bytes| to the wire, and if the packet is
// retransmittable. Returns true if the packet should be tracked by the
diff --git a/net/quic/congestion_control/send_algorithm_simulator.cc b/net/quic/congestion_control/send_algorithm_simulator.cc
index 33f6ba00..3864a74 100644
--- a/net/quic/congestion_control/send_algorithm_simulator.cc
+++ b/net/quic/congestion_control/send_algorithm_simulator.cc
@@ -11,6 +11,7 @@
#include "net/quic/crypto/quic_random.h"
using std::list;
+using std::make_pair;
using std::max;
using std::min;
using std::vector;
@@ -244,8 +245,8 @@ bool SendAlgorithmSimulator::HasRecentLostPackets(
void SendAlgorithmSimulator::HandlePendingAck(Transfer* transfer) {
Sender* sender = transfer->sender;
DCHECK_LT(sender->last_acked, sender->next_acked);
- SendAlgorithmInterface::CongestionMap acked_packets;
- SendAlgorithmInterface::CongestionMap lost_packets;
+ SendAlgorithmInterface::CongestionVector acked_packets;
+ SendAlgorithmInterface::CongestionVector lost_packets;
DVLOG(1) << "Acking packets from:" << sender->last_acked
<< " to " << sender->next_acked
<< " bytes_in_flight:" << transfer->bytes_in_flight
@@ -268,13 +269,13 @@ void SendAlgorithmSimulator::HandlePendingAck(Transfer* transfer) {
if (it->sequence_number > sender->last_acked) {
DVLOG(1) << "Lost packet:" << sender->last_acked
<< " dropped by buffer overflow.";
- lost_packets[sender->last_acked] = info;
+ lost_packets.push_back(make_pair(sender->last_acked, info));
continue;
}
if (it->lost) {
- lost_packets[sender->last_acked] = info;
+ lost_packets.push_back(make_pair(sender->last_acked, info));
} else {
- acked_packets[sender->last_acked] = info;
+ acked_packets.push_back(make_pair(sender->last_acked, info));
}
// This packet has been acked or lost, remove it from sent_packets_.
largest_observed = *it;
diff --git a/net/quic/congestion_control/tcp_cubic_sender.cc b/net/quic/congestion_control/tcp_cubic_sender.cc
index 3e7115d..9c01fa9 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender.cc
@@ -88,19 +88,19 @@ void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame(
void TcpCubicSender::OnCongestionEvent(
bool rtt_updated,
QuicByteCount bytes_in_flight,
- const CongestionMap& acked_packets,
- const CongestionMap& lost_packets) {
+ const CongestionVector& acked_packets,
+ const CongestionVector& lost_packets) {
if (rtt_updated && InSlowStart() &&
hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(),
rtt_stats_->min_rtt(),
congestion_window_)) {
slowstart_threshold_ = congestion_window_;
}
- for (CongestionMap::const_iterator it = lost_packets.begin();
+ for (CongestionVector::const_iterator it = lost_packets.begin();
it != lost_packets.end(); ++it) {
OnPacketLost(it->first, bytes_in_flight);
}
- for (CongestionMap::const_iterator it = acked_packets.begin();
+ for (CongestionVector::const_iterator it = acked_packets.begin();
it != acked_packets.end(); ++it) {
OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight);
}
diff --git a/net/quic/congestion_control/tcp_cubic_sender.h b/net/quic/congestion_control/tcp_cubic_sender.h
index c11620c..3f5baa3 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.h
+++ b/net/quic/congestion_control/tcp_cubic_sender.h
@@ -44,8 +44,8 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
QuicTime feedback_receive_time) OVERRIDE;
virtual void OnCongestionEvent(bool rtt_updated,
QuicByteCount bytes_in_flight,
- const CongestionMap& acked_packets,
- const CongestionMap& lost_packets) OVERRIDE;
+ const CongestionVector& acked_packets,
+ const CongestionVector& lost_packets) OVERRIDE;
virtual bool OnPacketSent(QuicTime sent_time,
QuicByteCount bytes_in_flight,
QuicPacketSequenceNumber sequence_number,
diff --git a/net/quic/congestion_control/tcp_cubic_sender_test.cc b/net/quic/congestion_control/tcp_cubic_sender_test.cc
index cc52da6..f6afdc8 100644
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender_test.cc
@@ -15,6 +15,7 @@
#include "net/quic/test_tools/quic_config_peer.h"
#include "testing/gtest/include/gtest/gtest.h"
+using std::make_pair;
using std::min;
namespace net {
@@ -86,11 +87,12 @@ class TcpCubicSenderTest : public ::testing::Test {
sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(60),
QuicTime::Delta::Zero(),
clock_.Now());
- SendAlgorithmInterface::CongestionMap acked_packets;
- SendAlgorithmInterface::CongestionMap lost_packets;
+ SendAlgorithmInterface::CongestionVector acked_packets;
+ SendAlgorithmInterface::CongestionVector lost_packets;
for (int i = 0; i < n; ++i) {
++acked_sequence_number_;
- acked_packets[acked_sequence_number_] = standard_packet_;
+ acked_packets.push_back(
+ make_pair(acked_sequence_number_, standard_packet_));
}
sender_->OnCongestionEvent(
true, bytes_in_flight_, acked_packets, lost_packets);
@@ -99,11 +101,12 @@ class TcpCubicSenderTest : public ::testing::Test {
}
void LoseNPackets(int n) {
- SendAlgorithmInterface::CongestionMap acked_packets;
- SendAlgorithmInterface::CongestionMap lost_packets;
+ SendAlgorithmInterface::CongestionVector acked_packets;
+ SendAlgorithmInterface::CongestionVector lost_packets;
for (int i = 0; i < n; ++i) {
++acked_sequence_number_;
- lost_packets[acked_sequence_number_] = standard_packet_;
+ lost_packets.push_back(
+ make_pair(acked_sequence_number_, standard_packet_));
}
sender_->OnCongestionEvent(
false, bytes_in_flight_, acked_packets, lost_packets);
@@ -112,9 +115,10 @@ class TcpCubicSenderTest : public ::testing::Test {
// Does not increment acked_sequence_number_.
void LosePacket(QuicPacketSequenceNumber sequence_number) {
- SendAlgorithmInterface::CongestionMap acked_packets;
- SendAlgorithmInterface::CongestionMap lost_packets;
- lost_packets[sequence_number] = standard_packet_;
+ SendAlgorithmInterface::CongestionVector acked_packets;
+ SendAlgorithmInterface::CongestionVector lost_packets;
+ lost_packets.push_back(
+ make_pair(sequence_number, standard_packet_));
sender_->OnCongestionEvent(
false, bytes_in_flight_, acked_packets, lost_packets);
bytes_in_flight_ -= kDefaultTCPMSS;
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 4adf624..f84d08c 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -933,9 +933,7 @@ void QuicConnection::UpdateStopWaitingCount() {
}
QuicPacketSequenceNumber QuicConnection::GetLeastUnacked() const {
- return sent_packet_manager_.HasUnackedPackets() ?
- sent_packet_manager_.GetLeastUnackedSentPacket() :
- packet_generator_.sequence_number() + 1;
+ return sent_packet_manager_.GetLeastUnacked();
}
void QuicConnection::MaybeSendInResponseToPacket() {
@@ -1304,11 +1302,7 @@ bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) {
}
bool QuicConnection::WritePacket(const QueuedPacket& packet) {
- QuicPacketSequenceNumber sequence_number =
- packet.serialized_packet.sequence_number;
- if (ShouldDiscardPacket(packet.encryption_level,
- sequence_number,
- IsRetransmittable(packet))) {
+ if (ShouldDiscardPacket(packet)) {
++stats_.packets_discarded;
return true;
}
@@ -1317,6 +1311,8 @@ bool QuicConnection::WritePacket(const QueuedPacket& packet) {
return false;
}
+ QuicPacketSequenceNumber sequence_number =
+ packet.serialized_packet.sequence_number;
// Some encryption algorithms require the packet sequence numbers not be
// repeated.
DCHECK_LE(sequence_number_of_last_sent_packet_, sequence_number);
@@ -1436,16 +1432,15 @@ bool QuicConnection::WritePacket(const QueuedPacket& packet) {
return true;
}
-bool QuicConnection::ShouldDiscardPacket(
- EncryptionLevel level,
- QuicPacketSequenceNumber sequence_number,
- HasRetransmittableData retransmittable) {
+bool QuicConnection::ShouldDiscardPacket(const QueuedPacket& packet) {
if (!connected_) {
DVLOG(1) << ENDPOINT
<< "Not sending packet as connection is disconnected.";
return true;
}
+ QuicPacketSequenceNumber sequence_number =
+ packet.serialized_packet.sequence_number;
// If the packet has been discarded before sending, don't send it.
// This occurs if a packet gets serialized, queued, then discarded.
if (!sent_packet_manager_.IsUnacked(sequence_number)) {
@@ -1455,7 +1450,7 @@ bool QuicConnection::ShouldDiscardPacket(
}
if (encryption_level_ == ENCRYPTION_FORWARD_SECURE &&
- level == ENCRYPTION_NONE) {
+ packet.encryption_level == ENCRYPTION_NONE) {
// Drop packets that are NULL encrypted since the peer won't accept them
// anymore.
DVLOG(1) << ENDPOINT << "Dropping NULL encrypted packet: "
@@ -1467,7 +1462,7 @@ bool QuicConnection::ShouldDiscardPacket(
return true;
}
- if (retransmittable == HAS_RETRANSMITTABLE_DATA &&
+ if (packet.transmission_type != NOT_RETRANSMISSION &&
!sent_packet_manager_.HasRetransmittableFrames(sequence_number)) {
DVLOG(1) << ENDPOINT << "Dropping unacked packet: " << sequence_number
<< " A previous transmission was acked while write blocked.";
@@ -1978,9 +1973,9 @@ QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() {
}
HasRetransmittableData QuicConnection::IsRetransmittable(
- QueuedPacket packet) {
- // TODO(cyr): Understand why the first check here is necessary. Without it,
- // DiscardRetransmit test fails.
+ const QueuedPacket& packet) {
+ // Retransmitted packets retransmittable frames are owned by the unacked
+ // packet map, but are not present in the serialized packet.
if (packet.transmission_type != NOT_RETRANSMISSION ||
packet.serialized_packet.retransmittable_frames != NULL) {
return HAS_RETRANSMITTABLE_DATA;
diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h
index 6bbb84f..9251c20 100644
--- a/net/quic/quic_connection.h
+++ b/net/quic/quic_connection.h
@@ -601,9 +601,7 @@ class NET_EXPORT_PRIVATE QuicConnection
void WritePendingRetransmissions();
// Returns true if the packet should be discarded and not sent.
- bool ShouldDiscardPacket(EncryptionLevel level,
- QuicPacketSequenceNumber sequence_number,
- HasRetransmittableData retransmittable);
+ bool ShouldDiscardPacket(const QueuedPacket& packet);
// Queues |packet| in the hopes that it can be decrypted in the
// future, when a new key is installed.
@@ -657,7 +655,7 @@ class NET_EXPORT_PRIVATE QuicConnection
void CheckForAddressMigration(const IPEndPoint& self_address,
const IPEndPoint& peer_address);
- HasRetransmittableData IsRetransmittable(QueuedPacket packet);
+ HasRetransmittableData IsRetransmittable(const QueuedPacket& packet);
bool IsConnectionClose(QueuedPacket packet);
QuicFramer framer_;
diff --git a/net/quic/quic_crypto_stream.cc b/net/quic/quic_crypto_stream.cc
index 8aa8d3e..0361a72 100644
--- a/net/quic/quic_crypto_stream.cc
+++ b/net/quic/quic_crypto_stream.cc
@@ -25,7 +25,7 @@ QuicCryptoStream::QuicCryptoStream(QuicSession* session)
encryption_established_(false),
handshake_confirmed_(false) {
crypto_framer_.set_visitor(this);
- if (version() <= QUIC_VERSION_20) {
+ if (version() < QUIC_VERSION_21) {
// Prior to QUIC_VERSION_21 the crypto stream is not subject to any flow
// control.
DisableFlowControl();
diff --git a/net/quic/quic_crypto_stream_test.cc b/net/quic/quic_crypto_stream_test.cc
index 7664912..4ea8f49 100644
--- a/net/quic/quic_crypto_stream_test.cc
+++ b/net/quic/quic_crypto_stream_test.cc
@@ -103,7 +103,7 @@ TEST_F(QuicCryptoStreamTest, ProcessBadData) {
}
TEST_F(QuicCryptoStreamTest, NoConnectionLevelFlowControl) {
- if (connection_->version() <= QUIC_VERSION_20) {
+ if (connection_->version() < QUIC_VERSION_21) {
EXPECT_FALSE(stream_.flow_controller()->IsEnabled());
} else {
EXPECT_TRUE(stream_.flow_controller()->IsEnabled());
diff --git a/net/quic/quic_headers_stream.cc b/net/quic/quic_headers_stream.cc
index a9b0433..35dac3fe 100644
--- a/net/quic/quic_headers_stream.cc
+++ b/net/quic/quic_headers_stream.cc
@@ -179,7 +179,7 @@ QuicHeadersStream::QuicHeadersStream(QuicSession* session)
spdy_framer_visitor_(new SpdyFramerVisitor(this)) {
spdy_framer_.set_visitor(spdy_framer_visitor_.get());
spdy_framer_.set_debug_visitor(spdy_framer_visitor_.get());
- if (version() <= QUIC_VERSION_20) {
+ if (version() < QUIC_VERSION_21) {
// Prior to QUIC_VERSION_21 the headers stream is not subject to any flow
// control.
DisableFlowControl();
diff --git a/net/quic/quic_headers_stream_test.cc b/net/quic/quic_headers_stream_test.cc
index 097df99..aa9a013 100644
--- a/net/quic/quic_headers_stream_test.cc
+++ b/net/quic/quic_headers_stream_test.cc
@@ -326,7 +326,7 @@ TEST_P(QuicHeadersStreamTest, ProcessSpdyWindowUpdateFrame) {
}
TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) {
- if (connection_->version() <= QUIC_VERSION_20) {
+ if (connection_->version() < QUIC_VERSION_21) {
EXPECT_FALSE(headers_stream_->flow_controller()->IsEnabled());
} else {
EXPECT_TRUE(headers_stream_->flow_controller()->IsEnabled());
diff --git a/net/quic/quic_protocol.cc b/net/quic/quic_protocol.cc
index 545d8ec..5ebd737 100644
--- a/net/quic/quic_protocol.cc
+++ b/net/quic/quic_protocol.cc
@@ -165,8 +165,6 @@ QuicTag QuicVersionToQuicTag(const QuicVersion version) {
return MakeQuicTag('Q', '0', '1', '8');
case QUIC_VERSION_19:
return MakeQuicTag('Q', '0', '1', '9');
- case QUIC_VERSION_20:
- return MakeQuicTag('Q', '0', '2', '0');
case QUIC_VERSION_21:
return MakeQuicTag('Q', '0', '2', '1');
case QUIC_VERSION_22:
@@ -202,7 +200,6 @@ string QuicVersionToString(const QuicVersion version) {
RETURN_STRING_LITERAL(QUIC_VERSION_16);
RETURN_STRING_LITERAL(QUIC_VERSION_18);
RETURN_STRING_LITERAL(QUIC_VERSION_19);
- RETURN_STRING_LITERAL(QUIC_VERSION_20);
RETURN_STRING_LITERAL(QUIC_VERSION_21);
RETURN_STRING_LITERAL(QUIC_VERSION_22);
RETURN_STRING_LITERAL(QUIC_VERSION_23);
diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h
index a15c912..888b410 100644
--- a/net/quic/quic_protocol.h
+++ b/net/quic/quic_protocol.h
@@ -289,7 +289,6 @@ enum QuicVersion {
QUIC_VERSION_16 = 16, // STOP_WAITING frame.
QUIC_VERSION_18 = 18, // PING frame.
QUIC_VERSION_19 = 19, // Connection level flow control.
- QUIC_VERSION_20 = 20, // Independent stream/connection flow control windows.
QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled.
QUIC_VERSION_22 = 22, // Send Server Config Update messages on crypto stream.
QUIC_VERSION_23 = 23, // Timestamp in the ack frame.
@@ -305,7 +304,6 @@ enum QuicVersion {
static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_23,
QUIC_VERSION_22,
QUIC_VERSION_21,
- QUIC_VERSION_20,
QUIC_VERSION_19,
QUIC_VERSION_18,
QUIC_VERSION_16};
diff --git a/net/quic/quic_sent_packet_manager.cc b/net/quic/quic_sent_packet_manager.cc
index c592e133..a5b1a9d 100644
--- a/net/quic/quic_sent_packet_manager.cc
+++ b/net/quic/quic_sent_packet_manager.cc
@@ -228,7 +228,7 @@ void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame,
ack_receive_time,
unacked_packets_.largest_observed(),
largest_observed_acked,
- GetLeastUnackedSentPacket());
+ GetLeastUnacked());
}
}
@@ -270,6 +270,10 @@ void QuicSentPacketManager::HandleAckForSentPackets(
}
if (ContainsKey(ack_frame.missing_packets, sequence_number)) {
+ // Don't continue to increase the nack count for packets not in flight.
+ if (!it->in_flight) {
+ continue;
+ }
// Consider it multiple nacks when there is a gap between the missing
// packet and the largest observed, since the purpose of a nack
// threshold is to tolerate re-ordering. This handles both StretchAcks
@@ -288,7 +292,7 @@ void QuicSentPacketManager::HandleAckForSentPackets(
// If data is associated with the most recent transmission of this
// packet, then inform the caller.
if (it->in_flight) {
- packets_acked_[sequence_number] = *it;
+ packets_acked_.push_back(make_pair(sequence_number, *it));
}
MarkPacketHandled(sequence_number, *it, delta_largest_observed);
}
@@ -494,7 +498,7 @@ bool QuicSentPacketManager::HasUnackedPackets() const {
}
QuicPacketSequenceNumber
-QuicSentPacketManager::GetLeastUnackedSentPacket() const {
+QuicSentPacketManager::GetLeastUnacked() const {
return unacked_packets_.GetLeastUnacked();
}
@@ -689,7 +693,7 @@ void QuicSentPacketManager::InvokeLossDetection(QuicTime time) {
// should be recorded as a loss to the send algorithm, but not retransmitted
// until it's known whether the FEC packet arrived.
++stats_->packets_lost;
- packets_lost_[sequence_number] = transmission_info;
+ packets_lost_.push_back(make_pair(sequence_number, transmission_info));
DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number;
if (transmission_info.retransmittable_frames != NULL) {
diff --git a/net/quic/quic_sent_packet_manager.h b/net/quic/quic_sent_packet_manager.h
index 84294d1..0950067 100644
--- a/net/quic/quic_sent_packet_manager.h
+++ b/net/quic/quic_sent_packet_manager.h
@@ -158,8 +158,8 @@ class NET_EXPORT_PRIVATE QuicSentPacketManager {
bool HasUnackedPackets() const;
// Returns the smallest sequence number of a serialized packet which has not
- // been acked by the peer. If there are no unacked packets, returns 0.
- QuicPacketSequenceNumber GetLeastUnackedSentPacket() const;
+ // been acked by the peer.
+ QuicPacketSequenceNumber GetLeastUnacked() const;
// Called when a congestion feedback frame is received from peer.
virtual void OnIncomingQuicCongestionFeedbackFrame(
@@ -377,9 +377,9 @@ class NET_EXPORT_PRIVATE QuicSentPacketManager {
size_t max_tail_loss_probes_;
bool using_pacing_;
- // Sets of packets acked and lost as a result of the last congestion event.
- SendAlgorithmInterface::CongestionMap packets_acked_;
- SendAlgorithmInterface::CongestionMap packets_lost_;
+ // Vectors packets acked and lost as a result of the last congestion event.
+ SendAlgorithmInterface::CongestionVector packets_acked_;
+ SendAlgorithmInterface::CongestionVector packets_lost_;
// Set to true after the crypto handshake has successfully completed. After
// this is true we no longer use HANDSHAKE_MODE, and further frames sent on
diff --git a/net/quic/quic_sent_packet_manager_test.cc b/net/quic/quic_sent_packet_manager_test.cc
index d00ea09..0972060 100644
--- a/net/quic/quic_sent_packet_manager_test.cc
+++ b/net/quic/quic_sent_packet_manager_test.cc
@@ -80,7 +80,7 @@ class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
}
EXPECT_TRUE(manager_.HasUnackedPackets());
- EXPECT_EQ(packets[0], manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(packets[0], manager_.GetLeastUnacked());
for (size_t i = 0; i < num_packets; ++i) {
EXPECT_TRUE(manager_.IsUnacked(packets[i])) << packets[i];
}
@@ -643,38 +643,38 @@ TEST_F(QuicSentPacketManagerTest, AckPreviousTransmissionThenTruncatedAck) {
VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
}
-TEST_F(QuicSentPacketManagerTest, GetLeastUnackedSentPacket) {
- EXPECT_EQ(0u, manager_.GetLeastUnackedSentPacket());
+TEST_F(QuicSentPacketManagerTest, GetLeastUnacked) {
+ EXPECT_EQ(1u, manager_.GetLeastUnacked());
}
-TEST_F(QuicSentPacketManagerTest, GetLeastUnackedSentPacketUnacked) {
+TEST_F(QuicSentPacketManagerTest, GetLeastUnackedUnacked) {
SerializedPacket serialized_packet(CreateDataPacket(1));
manager_.OnSerializedPacket(serialized_packet);
- EXPECT_EQ(1u, manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(1u, manager_.GetLeastUnacked());
}
-TEST_F(QuicSentPacketManagerTest, GetLeastUnackedSentPacketUnackedFec) {
+TEST_F(QuicSentPacketManagerTest, GetLeastUnackedUnackedFec) {
SerializedPacket serialized_packet(CreateFecPacket(1));
manager_.OnSerializedPacket(serialized_packet);
- EXPECT_EQ(1u, manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(1u, manager_.GetLeastUnacked());
}
-TEST_F(QuicSentPacketManagerTest, GetLeastUnackedPacketAndDiscard) {
+TEST_F(QuicSentPacketManagerTest, GetLeastUnackedAndDiscard) {
VerifyUnackedPackets(NULL, 0);
SerializedPacket serialized_packet(CreateFecPacket(1));
manager_.OnSerializedPacket(serialized_packet);
- EXPECT_EQ(1u, manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(1u, manager_.GetLeastUnacked());
SerializedPacket serialized_packet2(CreateFecPacket(2));
manager_.OnSerializedPacket(serialized_packet2);
- EXPECT_EQ(1u, manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(1u, manager_.GetLeastUnacked());
SerializedPacket serialized_packet3(CreateFecPacket(3));
manager_.OnSerializedPacket(serialized_packet3);
- EXPECT_EQ(1u, manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(1u, manager_.GetLeastUnacked());
QuicPacketSequenceNumber unacked[] = { 1, 2, 3 };
VerifyUnackedPackets(unacked, arraysize(unacked));
@@ -685,7 +685,7 @@ TEST_F(QuicSentPacketManagerTest, GetLeastUnackedPacketAndDiscard) {
ack_frame.largest_observed = 2;
manager_.OnIncomingAck(ack_frame, clock_.Now());
- EXPECT_EQ(3u, manager_.GetLeastUnackedSentPacket());
+ EXPECT_EQ(3u, manager_.GetLeastUnacked());
}
TEST_F(QuicSentPacketManagerTest, GetSentTime) {
diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc
index d327da6..91d8e55 100644
--- a/net/quic/quic_session.cc
+++ b/net/quic/quic_session.cc
@@ -272,7 +272,7 @@ void QuicSession::OnWindowUpdateFrames(
continue;
}
- if (connection_->version() <= QUIC_VERSION_20 &&
+ if (connection_->version() <= QUIC_VERSION_21 &&
(stream_id == kCryptoStreamId || stream_id == kHeadersStreamId)) {
DLOG(DFATAL) << "WindowUpdate for stream " << stream_id << " in version "
<< QuicVersionToString(connection_->version());
@@ -500,7 +500,7 @@ void QuicSession::OnConfigNegotiated() {
return;
}
- // QUIC_VERSION_20 and higher can have independent stream and session flow
+ // QUIC_VERSION_21 and higher can have independent stream and session flow
// control windows.
if (config_.HasReceivedInitialStreamFlowControlWindowBytes()) {
// Streams which were created before the SHLO was received (0-RTT
@@ -526,7 +526,7 @@ void QuicSession::OnNewStreamFlowControlWindow(uint32 new_window) {
}
// Inform all existing streams about the new window.
- if (connection_->version() > QUIC_VERSION_20) {
+ if (connection_->version() >= QUIC_VERSION_21) {
GetCryptoStream()->flow_controller()->UpdateSendWindowOffset(new_window);
headers_stream_->flow_controller()->UpdateSendWindowOffset(new_window);
}
@@ -759,7 +759,7 @@ void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion& version) {
// Disable stream level flow control based on negotiated version. Streams may
// have been created with a different version.
- if (version <= QUIC_VERSION_20) {
+ if (version < QUIC_VERSION_21) {
GetCryptoStream()->flow_controller()->Disable();
headers_stream_->flow_controller()->Disable();
}
diff --git a/net/quic/quic_unacked_packet_map.cc b/net/quic/quic_unacked_packet_map.cc
index 0640c29..4d2bec9 100644
--- a/net/quic/quic_unacked_packet_map.cc
+++ b/net/quic/quic_unacked_packet_map.cc
@@ -295,10 +295,6 @@ bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const {
QuicPacketSequenceNumber
QuicUnackedPacketMap::GetLeastUnacked() const {
- if (unacked_packets_.empty()) {
- // If there are no unacked packets, return 0.
- return 0;
- }
return least_unacked_;
}
diff --git a/net/quic/reliable_quic_stream.cc b/net/quic/reliable_quic_stream.cc
index dbb5d44..8c3e906 100644
--- a/net/quic/reliable_quic_stream.cc
+++ b/net/quic/reliable_quic_stream.cc
@@ -44,7 +44,7 @@ size_t GetReceivedFlowControlWindow(QuicSession* session) {
return kDefaultFlowControlSendWindow;
}
- // Version must be >= QUIC_VERSION_20, so we check for stream specific flow
+ // Version must be >= QUIC_VERSION_21, so we check for stream specific flow
// control window.
if (session->config()->HasReceivedInitialStreamFlowControlWindowBytes()) {
return session->config()->ReceivedInitialStreamFlowControlWindowBytes();
diff --git a/net/quic/reliable_quic_stream.h b/net/quic/reliable_quic_stream.h
index b9aa8ee..5b5ae0f 100644
--- a/net/quic/reliable_quic_stream.h
+++ b/net/quic/reliable_quic_stream.h
@@ -161,7 +161,7 @@ class NET_EXPORT_PRIVATE ReliableQuicStream {
const QuicStreamSequencer* sequencer() const { return &sequencer_; }
QuicStreamSequencer* sequencer() { return &sequencer_; }
- // TODO(rjshade): Remove this method when removing QUIC_VERSION_20.
+ // TODO(rjshade): Remove this method when removing QUIC_VERSION_19.
void DisableFlowControl() {
flow_controller_.Disable();
}
diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h
index 7d34692..31564fc 100644
--- a/net/quic/test_tools/quic_test_utils.h
+++ b/net/quic/test_tools/quic_test_utils.h
@@ -448,8 +448,8 @@ class MockSendAlgorithm : public SendAlgorithmInterface {
QuicTime feedback_receive_time));
MOCK_METHOD4(OnCongestionEvent, void(bool rtt_updated,
QuicByteCount bytes_in_flight,
- const CongestionMap& acked_packets,
- const CongestionMap& lost_packets));
+ const CongestionVector& acked_packets,
+ const CongestionVector& lost_packets));
MOCK_METHOD5(OnPacketSent,
bool(QuicTime, QuicByteCount, QuicPacketSequenceNumber,
QuicByteCount, HasRetransmittableData));
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index 28c277f..e92516c 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -1327,7 +1327,7 @@ TEST_P(EndToEndTest, HeadersAndCryptoStreamsNoConnectionFlowControl) {
set_server_initial_session_flow_control_receive_window(kSessionIFCW);
ASSERT_TRUE(Initialize());
- if (negotiated_version_ <= QUIC_VERSION_20) {
+ if (negotiated_version_ < QUIC_VERSION_21) {
return;
}
diff --git a/net/tools/quic/quic_client_bin.cc b/net/tools/quic/quic_client_bin.cc
index b9ea915..e9ce928 100644
--- a/net/tools/quic/quic_client_bin.cc
+++ b/net/tools/quic/quic_client_bin.cc
@@ -2,16 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// A binary wrapper for QuicClient. Connects to --hostname via --address
-// on --port and requests URLs specified on the command line.
-// Pass --secure to check the certificates using proof verifier.
-// Pass --initial_stream_flow_control_window to specify the size of the initial
-// stream flow control receive window to advertise to server.
-// Pass --initial_session_flow_control_window to specify the size of the initial
-// session flow control receive window to advertise to server.
+// A binary wrapper for QuicClient.
+// Connects to a host using QUIC, and sends requests to the provided URLS.
//
-// For example:
-// quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com
+// Example usage:
+// quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com \
// http://www.google.com/index.html http://www.google.com/favicon.ico
#include <iostream>
@@ -27,19 +22,16 @@
#include "net/tools/epoll_server/epoll_server.h"
#include "net/tools/quic/quic_client.h"
-// The port the quic client will connect to.
-int32 FLAGS_port = 6121;
std::string FLAGS_address = "127.0.0.1";
-// The hostname the quic client will connect to.
+// The IP or hostname the quic client will connect to.
std::string FLAGS_hostname = "localhost";
-// Size of the initial stream flow control receive window to advertise to
-// server.
-int32 FLAGS_initial_stream_flow_control_window = 100 * net::kMaxPacketSize;
-// Size of the initial session flow control receive window to advertise to
-// server.
-int32 FLAGS_initial_session_flow_control_window = 200 * net::kMaxPacketSize;
+// The port the quic client will connect to.
+int32 FLAGS_port = 6121;
// Check the certificates using proof verifier.
bool FLAGS_secure = false;
+// QUIC version to speak, e.g. 21. Default value of 0 means 'use the latest
+// version'.
+int32 FLAGS_quic_version = 0;
int main(int argc, char *argv[]) {
base::CommandLine::Init(argc, argv);
@@ -61,7 +53,8 @@ int main(int argc, char *argv[]) {
"--port=<port> specify the port to connect to\n"
"--address=<address> specify the IP address to connect to\n"
"--host=<host> specify the SNI hostname to use\n"
- "--secure check certificates\n";
+ "--secure check certificates\n"
+ "--quic-version=<quic version> specify QUIC version to speak\n";
std::cout << help_str;
exit(0);
}
@@ -80,37 +73,56 @@ int main(int argc, char *argv[]) {
if (line->HasSwitch("secure")) {
FLAGS_secure = true;
}
+ if (line->HasSwitch("quic-version")) {
+ int quic_version;
+ if (base::StringToInt(line->GetSwitchValueASCII("quic-version"),
+ &quic_version)) {
+ FLAGS_quic_version = quic_version;
+ }
+ }
VLOG(1) << "server port: " << FLAGS_port
<< " address: " << FLAGS_address
<< " hostname: " << FLAGS_hostname
- << " secure: " << FLAGS_secure;
+ << " secure: " << FLAGS_secure
+ << " quic-version: " << FLAGS_quic_version;
base::AtExitManager exit_manager;
+ // Determine IP address to connect to from supplied hostname.
net::IPAddressNumber addr;
CHECK(net::ParseIPLiteralToNumber(FLAGS_address, &addr));
+ // Populate version vector with all versions if none specified.
+ net::QuicVersionVector versions;
+ if (FLAGS_quic_version == 0) {
+ versions = net::QuicSupportedVersions();
+ } else {
+ versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
+ }
+
+ // Build the client, and try to connect.
+ VLOG(1) << "Conecting to " << FLAGS_hostname << ":" << FLAGS_port
+ << " with supported versions "
+ << QuicVersionVectorToString(versions);
+ net::EpollServer epoll_server;
net::QuicConfig config;
config.SetDefaults();
- config.SetInitialFlowControlWindowToSend(
- FLAGS_initial_session_flow_control_window);
- config.SetInitialStreamFlowControlWindowToSend(
- FLAGS_initial_stream_flow_control_window);
- config.SetInitialSessionFlowControlWindowToSend(
- FLAGS_initial_session_flow_control_window);
- // TODO(rjshade): Set version on command line.
- net::EpollServer epoll_server;
net::tools::QuicClient client(
net::IPEndPoint(addr, FLAGS_port),
net::QuicServerId(FLAGS_hostname, FLAGS_port, FLAGS_secure,
net::PRIVACY_MODE_DISABLED),
- net::QuicSupportedVersions(), true, config, &epoll_server);
+ versions, true, config, &epoll_server);
client.Initialize();
- if (!client.Connect()) return 1;
+ if (!client.Connect()) {
+ LOG(ERROR) << "Client failed to connect to host: "
+ << FLAGS_hostname << ":" << FLAGS_port;
+ return 1;
+ }
+ // Send a GET request for each supplied url.
client.SendRequestsAndWaitForResponse(urls);
return 0;
}