OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/quic/congestion_control/loss_detection_interface.h" | 11 #include "net/quic/congestion_control/loss_detection_interface.h" |
12 #include "net/quic/congestion_control/receive_algorithm_interface.h" | 12 #include "net/quic/congestion_control/receive_algorithm_interface.h" |
13 #include "net/quic/congestion_control/send_algorithm_interface.h" | 13 #include "net/quic/congestion_control/send_algorithm_interface.h" |
14 #include "net/quic/crypto/null_encrypter.h" | 14 #include "net/quic/crypto/null_encrypter.h" |
15 #include "net/quic/crypto/quic_decrypter.h" | 15 #include "net/quic/crypto/quic_decrypter.h" |
16 #include "net/quic/crypto/quic_encrypter.h" | 16 #include "net/quic/crypto/quic_encrypter.h" |
17 #include "net/quic/quic_ack_notifier.h" | 17 #include "net/quic/quic_ack_notifier.h" |
18 #include "net/quic/quic_flags.h" | 18 #include "net/quic/quic_flags.h" |
19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
20 #include "net/quic/quic_utils.h" | 20 #include "net/quic/quic_utils.h" |
21 #include "net/quic/test_tools/mock_clock.h" | 21 #include "net/quic/test_tools/mock_clock.h" |
22 #include "net/quic/test_tools/mock_random.h" | 22 #include "net/quic/test_tools/mock_random.h" |
23 #include "net/quic/test_tools/quic_config_peer.h" | 23 #include "net/quic/test_tools/quic_config_peer.h" |
24 #include "net/quic/test_tools/quic_connection_peer.h" | 24 #include "net/quic/test_tools/quic_connection_peer.h" |
25 #include "net/quic/test_tools/quic_framer_peer.h" | 25 #include "net/quic/test_tools/quic_framer_peer.h" |
26 #include "net/quic/test_tools/quic_packet_creator_peer.h" | 26 #include "net/quic/test_tools/quic_packet_creator_peer.h" |
| 27 #include "net/quic/test_tools/quic_packet_generator_peer.h" |
27 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 28 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
28 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
29 #include "net/quic/test_tools/simple_quic_framer.h" | 30 #include "net/quic/test_tools/simple_quic_framer.h" |
30 #include "net/test/gtest_util.h" | 31 #include "net/test/gtest_util.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
33 | 34 |
34 using base::StringPiece; | 35 using base::StringPiece; |
35 using std::map; | 36 using std::map; |
36 using std::string; | 37 using std::string; |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 TestConnectionHelper::TestAlarm* GetAckAlarm() { | 558 TestConnectionHelper::TestAlarm* GetAckAlarm() { |
558 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 559 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
559 QuicConnectionPeer::GetAckAlarm(this)); | 560 QuicConnectionPeer::GetAckAlarm(this)); |
560 } | 561 } |
561 | 562 |
562 TestConnectionHelper::TestAlarm* GetPingAlarm() { | 563 TestConnectionHelper::TestAlarm* GetPingAlarm() { |
563 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 564 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
564 QuicConnectionPeer::GetPingAlarm(this)); | 565 QuicConnectionPeer::GetPingAlarm(this)); |
565 } | 566 } |
566 | 567 |
| 568 TestConnectionHelper::TestAlarm* GetFecAlarm() { |
| 569 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
| 570 QuicConnectionPeer::GetFecAlarm(this)); |
| 571 } |
| 572 |
567 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() { | 573 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() { |
568 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 574 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
569 QuicConnectionPeer::GetResumeWritesAlarm(this)); | 575 QuicConnectionPeer::GetResumeWritesAlarm(this)); |
570 } | 576 } |
571 | 577 |
572 TestConnectionHelper::TestAlarm* GetRetransmissionAlarm() { | 578 TestConnectionHelper::TestAlarm* GetRetransmissionAlarm() { |
573 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 579 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
574 QuicConnectionPeer::GetRetransmissionAlarm(this)); | 580 QuicConnectionPeer::GetRetransmissionAlarm(this)); |
575 } | 581 } |
576 | 582 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 protected: | 632 protected: |
627 QuicConnectionTest() | 633 QuicConnectionTest() |
628 : connection_id_(42), | 634 : connection_id_(42), |
629 framer_(SupportedVersions(version()), QuicTime::Zero(), false), | 635 framer_(SupportedVersions(version()), QuicTime::Zero(), false), |
630 peer_creator_(connection_id_, &framer_, &random_generator_), | 636 peer_creator_(connection_id_, &framer_, &random_generator_), |
631 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 637 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
632 loss_algorithm_(new MockLossAlgorithm()), | 638 loss_algorithm_(new MockLossAlgorithm()), |
633 helper_(new TestConnectionHelper(&clock_, &random_generator_)), | 639 helper_(new TestConnectionHelper(&clock_, &random_generator_)), |
634 writer_(new TestPacketWriter(version(), &clock_)), | 640 writer_(new TestPacketWriter(version(), &clock_)), |
635 factory_(writer_.get()), | 641 factory_(writer_.get()), |
636 connection_(connection_id_, IPEndPoint(), helper_.get(), | 642 connection_(connection_id_, |
637 factory_, false, version()), | 643 IPEndPoint(), |
| 644 helper_.get(), |
| 645 factory_, |
| 646 false, |
| 647 version()), |
| 648 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)), |
| 649 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)), |
| 650 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_)), |
638 frame1_(1, false, 0, MakeIOVector(data1)), | 651 frame1_(1, false, 0, MakeIOVector(data1)), |
639 frame2_(1, false, 3, MakeIOVector(data2)), | 652 frame2_(1, false, 3, MakeIOVector(data2)), |
640 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), | 653 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), |
641 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { | 654 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { |
642 connection_.set_visitor(&visitor_); | 655 connection_.set_visitor(&visitor_); |
643 connection_.SetSendAlgorithm(send_algorithm_); | 656 connection_.SetSendAlgorithm(send_algorithm_); |
644 connection_.SetLossAlgorithm(loss_algorithm_); | 657 connection_.SetLossAlgorithm(loss_algorithm_); |
645 framer_.set_received_entropy_calculator(&entropy_calculator_); | 658 framer_.set_received_entropy_calculator(&entropy_calculator_); |
646 // Simplify tests by not sending feedback unless specifically configured. | 659 // Simplify tests by not sending feedback unless specifically configured. |
647 SetFeedback(nullptr); | 660 SetFeedback(nullptr); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 QuicByteCount SendStreamDataToPeer(QuicStreamId id, | 840 QuicByteCount SendStreamDataToPeer(QuicStreamId id, |
828 StringPiece data, | 841 StringPiece data, |
829 QuicStreamOffset offset, | 842 QuicStreamOffset offset, |
830 bool fin, | 843 bool fin, |
831 QuicPacketSequenceNumber* last_packet) { | 844 QuicPacketSequenceNumber* last_packet) { |
832 QuicByteCount packet_size; | 845 QuicByteCount packet_size; |
833 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 846 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
834 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); | 847 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); |
835 connection_.SendStreamDataWithString(id, data, offset, fin, nullptr); | 848 connection_.SendStreamDataWithString(id, data, offset, fin, nullptr); |
836 if (last_packet != nullptr) { | 849 if (last_packet != nullptr) { |
837 *last_packet = | 850 *last_packet = creator_->sequence_number(); |
838 QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number(); | |
839 } | 851 } |
840 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 852 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
841 .Times(AnyNumber()); | 853 .Times(AnyNumber()); |
842 return packet_size; | 854 return packet_size; |
843 } | 855 } |
844 | 856 |
845 void SendAckPacketToPeer() { | 857 void SendAckPacketToPeer() { |
846 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 858 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
847 connection_.SendAck(); | 859 connection_.SendAck(); |
848 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 860 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 | 1029 |
1018 MockSendAlgorithm* send_algorithm_; | 1030 MockSendAlgorithm* send_algorithm_; |
1019 MockLossAlgorithm* loss_algorithm_; | 1031 MockLossAlgorithm* loss_algorithm_; |
1020 TestReceiveAlgorithm* receive_algorithm_; | 1032 TestReceiveAlgorithm* receive_algorithm_; |
1021 MockClock clock_; | 1033 MockClock clock_; |
1022 MockRandom random_generator_; | 1034 MockRandom random_generator_; |
1023 scoped_ptr<TestConnectionHelper> helper_; | 1035 scoped_ptr<TestConnectionHelper> helper_; |
1024 scoped_ptr<TestPacketWriter> writer_; | 1036 scoped_ptr<TestPacketWriter> writer_; |
1025 NiceMock<MockPacketWriterFactory> factory_; | 1037 NiceMock<MockPacketWriterFactory> factory_; |
1026 TestConnection connection_; | 1038 TestConnection connection_; |
| 1039 QuicPacketCreator* creator_; |
| 1040 QuicPacketGenerator* generator_; |
| 1041 QuicSentPacketManager* manager_; |
1027 StrictMock<MockConnectionVisitor> visitor_; | 1042 StrictMock<MockConnectionVisitor> visitor_; |
1028 | 1043 |
1029 QuicPacketHeader header_; | 1044 QuicPacketHeader header_; |
1030 QuicStreamFrame frame1_; | 1045 QuicStreamFrame frame1_; |
1031 QuicStreamFrame frame2_; | 1046 QuicStreamFrame frame2_; |
1032 scoped_ptr<QuicAckFrame> outgoing_ack_; | 1047 scoped_ptr<QuicAckFrame> outgoing_ack_; |
1033 scoped_ptr<QuicStopWaitingFrame> stop_waiting_; | 1048 scoped_ptr<QuicStopWaitingFrame> stop_waiting_; |
1034 QuicSequenceNumberLength sequence_number_length_; | 1049 QuicSequenceNumberLength sequence_number_length_; |
1035 QuicConnectionIdLength connection_id_length_; | 1050 QuicConnectionIdLength connection_id_length_; |
1036 | 1051 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 lost_packets.insert(i * 2); | 1182 lost_packets.insert(i * 2); |
1168 } | 1183 } |
1169 } | 1184 } |
1170 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1185 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1171 .WillOnce(Return(lost_packets)); | 1186 .WillOnce(Return(lost_packets)); |
1172 EXPECT_CALL(entropy_calculator_, EntropyHash(511)) | 1187 EXPECT_CALL(entropy_calculator_, EntropyHash(511)) |
1173 .WillOnce(Return(static_cast<QuicPacketEntropyHash>(0))); | 1188 .WillOnce(Return(static_cast<QuicPacketEntropyHash>(0))); |
1174 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1189 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1175 ProcessAckPacket(&frame); | 1190 ProcessAckPacket(&frame); |
1176 | 1191 |
1177 const QuicSentPacketManager& sent_packet_manager = | |
1178 connection_.sent_packet_manager(); | |
1179 // A truncated ack will not have the true largest observed. | 1192 // A truncated ack will not have the true largest observed. |
1180 EXPECT_GT(num_packets, sent_packet_manager.largest_observed()); | 1193 EXPECT_GT(num_packets, manager_->largest_observed()); |
1181 | 1194 |
1182 AckPacket(192, &frame); | 1195 AckPacket(192, &frame); |
1183 | 1196 |
1184 // Removing one missing packet allows us to ack 192 and one more range, but | 1197 // Removing one missing packet allows us to ack 192 and one more range, but |
1185 // 192 has already been declared lost, so it doesn't register as an ack. | 1198 // 192 has already been declared lost, so it doesn't register as an ack. |
1186 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1199 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1187 .WillOnce(Return(SequenceNumberSet())); | 1200 .WillOnce(Return(SequenceNumberSet())); |
1188 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1201 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1189 ProcessAckPacket(&frame); | 1202 ProcessAckPacket(&frame); |
1190 EXPECT_EQ(num_packets, sent_packet_manager.largest_observed()); | 1203 EXPECT_EQ(num_packets, manager_->largest_observed()); |
1191 } | 1204 } |
1192 | 1205 |
1193 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { | 1206 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { |
1194 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1207 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1195 | 1208 |
1196 ProcessPacket(1); | 1209 ProcessPacket(1); |
1197 // Delay sending, then queue up an ack. | 1210 // Delay sending, then queue up an ack. |
1198 EXPECT_CALL(*send_algorithm_, | 1211 EXPECT_CALL(*send_algorithm_, |
1199 TimeUntilSend(_, _, _)).WillOnce( | 1212 TimeUntilSend(_, _, _)).WillOnce( |
1200 testing::Return(QuicTime::Delta::FromMicroseconds(1))); | 1213 testing::Return(QuicTime::Delta::FromMicroseconds(1))); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1421 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1409 ProcessPacket(1); | 1422 ProcessPacket(1); |
1410 | 1423 |
1411 peer_creator_.set_sequence_number(1); | 1424 peer_creator_.set_sequence_number(1); |
1412 QuicAckFrame frame1 = InitAckFrame(0); | 1425 QuicAckFrame frame1 = InitAckFrame(0); |
1413 ProcessAckPacket(&frame1); | 1426 ProcessAckPacket(&frame1); |
1414 } | 1427 } |
1415 | 1428 |
1416 TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsBandwidth) { | 1429 TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsBandwidth) { |
1417 QuicPacketSequenceNumber last_packet; | 1430 QuicPacketSequenceNumber last_packet; |
1418 QuicPacketCreator* creator = | |
1419 QuicConnectionPeer::GetPacketCreator(&connection_); | |
1420 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); | 1431 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); |
1421 EXPECT_EQ(1u, last_packet); | 1432 EXPECT_EQ(1u, last_packet); |
1422 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, | 1433 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, |
1423 creator->next_sequence_number_length()); | 1434 creator_->next_sequence_number_length()); |
1424 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, | 1435 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, |
1425 writer_->header().public_header.sequence_number_length); | 1436 writer_->header().public_header.sequence_number_length); |
1426 | 1437 |
1427 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( | 1438 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( |
1428 Return(kMaxPacketSize * 256)); | 1439 Return(kMaxPacketSize * 256)); |
1429 | 1440 |
1430 SendStreamDataToPeer(1, "bar", 3, !kFin, &last_packet); | 1441 SendStreamDataToPeer(1, "bar", 3, !kFin, &last_packet); |
1431 EXPECT_EQ(2u, last_packet); | 1442 EXPECT_EQ(2u, last_packet); |
1432 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, | 1443 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, |
1433 creator->next_sequence_number_length()); | 1444 creator_->next_sequence_number_length()); |
1434 // The 1 packet lag is due to the sequence number length being recalculated in | 1445 // The 1 packet lag is due to the sequence number length being recalculated in |
1435 // QuicConnection after a packet is sent. | 1446 // QuicConnection after a packet is sent. |
1436 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, | 1447 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, |
1437 writer_->header().public_header.sequence_number_length); | 1448 writer_->header().public_header.sequence_number_length); |
1438 | 1449 |
1439 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( | 1450 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( |
1440 Return(kMaxPacketSize * 256 * 256)); | 1451 Return(kMaxPacketSize * 256 * 256)); |
1441 | 1452 |
1442 SendStreamDataToPeer(1, "foo", 6, !kFin, &last_packet); | 1453 SendStreamDataToPeer(1, "foo", 6, !kFin, &last_packet); |
1443 EXPECT_EQ(3u, last_packet); | 1454 EXPECT_EQ(3u, last_packet); |
1444 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1455 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1445 creator->next_sequence_number_length()); | 1456 creator_->next_sequence_number_length()); |
1446 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, | 1457 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, |
1447 writer_->header().public_header.sequence_number_length); | 1458 writer_->header().public_header.sequence_number_length); |
1448 | 1459 |
1449 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( | 1460 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( |
1450 Return(kMaxPacketSize * 256 * 256 * 256)); | 1461 Return(kMaxPacketSize * 256 * 256 * 256)); |
1451 | 1462 |
1452 SendStreamDataToPeer(1, "bar", 9, !kFin, &last_packet); | 1463 SendStreamDataToPeer(1, "bar", 9, !kFin, &last_packet); |
1453 EXPECT_EQ(4u, last_packet); | 1464 EXPECT_EQ(4u, last_packet); |
1454 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1465 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1455 creator->next_sequence_number_length()); | 1466 creator_->next_sequence_number_length()); |
1456 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1467 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1457 writer_->header().public_header.sequence_number_length); | 1468 writer_->header().public_header.sequence_number_length); |
1458 | 1469 |
1459 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( | 1470 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( |
1460 Return(kMaxPacketSize * 256 * 256 * 256 * 256)); | 1471 Return(kMaxPacketSize * 256 * 256 * 256 * 256)); |
1461 | 1472 |
1462 SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet); | 1473 SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet); |
1463 EXPECT_EQ(5u, last_packet); | 1474 EXPECT_EQ(5u, last_packet); |
1464 EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER, | 1475 EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER, |
1465 creator->next_sequence_number_length()); | 1476 creator_->next_sequence_number_length()); |
1466 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1477 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1467 writer_->header().public_header.sequence_number_length); | 1478 writer_->header().public_header.sequence_number_length); |
1468 } | 1479 } |
1469 | 1480 |
1470 // TODO(ianswett): Re-enable this test by finding a good way to test different | 1481 // TODO(ianswett): Re-enable this test by finding a good way to test different |
1471 // sequence number lengths without sending packets with giant gaps. | 1482 // sequence number lengths without sending packets with giant gaps. |
1472 TEST_P(QuicConnectionTest, | 1483 TEST_P(QuicConnectionTest, |
1473 DISABLED_SendingDifferentSequenceNumberLengthsUnackedDelta) { | 1484 DISABLED_SendingDifferentSequenceNumberLengthsUnackedDelta) { |
1474 QuicPacketSequenceNumber last_packet; | 1485 QuicPacketSequenceNumber last_packet; |
1475 QuicPacketCreator* creator = | |
1476 QuicConnectionPeer::GetPacketCreator(&connection_); | |
1477 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); | 1486 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); |
1478 EXPECT_EQ(1u, last_packet); | 1487 EXPECT_EQ(1u, last_packet); |
1479 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, | 1488 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, |
1480 creator->next_sequence_number_length()); | 1489 creator_->next_sequence_number_length()); |
1481 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, | 1490 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, |
1482 writer_->header().public_header.sequence_number_length); | 1491 writer_->header().public_header.sequence_number_length); |
1483 | 1492 |
1484 creator->set_sequence_number(100); | 1493 creator_->set_sequence_number(100); |
1485 | 1494 |
1486 SendStreamDataToPeer(1, "bar", 3, !kFin, &last_packet); | 1495 SendStreamDataToPeer(1, "bar", 3, !kFin, &last_packet); |
1487 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, | 1496 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, |
1488 creator->next_sequence_number_length()); | 1497 creator_->next_sequence_number_length()); |
1489 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, | 1498 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, |
1490 writer_->header().public_header.sequence_number_length); | 1499 writer_->header().public_header.sequence_number_length); |
1491 | 1500 |
1492 creator->set_sequence_number(100 * 256); | 1501 creator_->set_sequence_number(100 * 256); |
1493 | 1502 |
1494 SendStreamDataToPeer(1, "foo", 6, !kFin, &last_packet); | 1503 SendStreamDataToPeer(1, "foo", 6, !kFin, &last_packet); |
1495 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1504 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1496 creator->next_sequence_number_length()); | 1505 creator_->next_sequence_number_length()); |
1497 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, | 1506 EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER, |
1498 writer_->header().public_header.sequence_number_length); | 1507 writer_->header().public_header.sequence_number_length); |
1499 | 1508 |
1500 creator->set_sequence_number(100 * 256 * 256); | 1509 creator_->set_sequence_number(100 * 256 * 256); |
1501 | 1510 |
1502 SendStreamDataToPeer(1, "bar", 9, !kFin, &last_packet); | 1511 SendStreamDataToPeer(1, "bar", 9, !kFin, &last_packet); |
1503 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1512 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1504 creator->next_sequence_number_length()); | 1513 creator_->next_sequence_number_length()); |
1505 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1514 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1506 writer_->header().public_header.sequence_number_length); | 1515 writer_->header().public_header.sequence_number_length); |
1507 | 1516 |
1508 creator->set_sequence_number(100 * 256 * 256 * 256); | 1517 creator_->set_sequence_number(100 * 256 * 256 * 256); |
1509 | 1518 |
1510 SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet); | 1519 SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet); |
1511 EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER, | 1520 EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER, |
1512 creator->next_sequence_number_length()); | 1521 creator_->next_sequence_number_length()); |
1513 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, | 1522 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, |
1514 writer_->header().public_header.sequence_number_length); | 1523 writer_->header().public_header.sequence_number_length); |
1515 } | 1524 } |
1516 | 1525 |
1517 TEST_P(QuicConnectionTest, BasicSending) { | 1526 TEST_P(QuicConnectionTest, BasicSending) { |
1518 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1527 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1519 QuicPacketSequenceNumber last_packet; | 1528 QuicPacketSequenceNumber last_packet; |
1520 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 | 1529 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 |
1521 EXPECT_EQ(1u, last_packet); | 1530 EXPECT_EQ(1u, last_packet); |
1522 SendAckPacketToPeer(); // Packet 2 | 1531 SendAckPacketToPeer(); // Packet 2 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1637 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
1629 .WillOnce(DoAll(SaveArg<0>(&actual_recorded_send_time), Return(true))); | 1638 .WillOnce(DoAll(SaveArg<0>(&actual_recorded_send_time), Return(true))); |
1630 connection_.SendStreamDataWithString(2, "baz", 0, !kFin, nullptr); | 1639 connection_.SendStreamDataWithString(2, "baz", 0, !kFin, nullptr); |
1631 EXPECT_EQ(expected_recorded_send_time, actual_recorded_send_time) | 1640 EXPECT_EQ(expected_recorded_send_time, actual_recorded_send_time) |
1632 << "Expected time = " << expected_recorded_send_time.ToDebuggingValue() | 1641 << "Expected time = " << expected_recorded_send_time.ToDebuggingValue() |
1633 << ". Actual time = " << actual_recorded_send_time.ToDebuggingValue(); | 1642 << ". Actual time = " << actual_recorded_send_time.ToDebuggingValue(); |
1634 } | 1643 } |
1635 | 1644 |
1636 TEST_P(QuicConnectionTest, FECSending) { | 1645 TEST_P(QuicConnectionTest, FECSending) { |
1637 // All packets carry version info till version is negotiated. | 1646 // All packets carry version info till version is negotiated. |
1638 QuicPacketCreator* creator = | |
1639 QuicConnectionPeer::GetPacketCreator(&connection_); | |
1640 size_t payload_length; | 1647 size_t payload_length; |
1641 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining | 1648 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining |
1642 // packet length. The size of the offset field in a stream frame is 0 for | 1649 // packet length. The size of the offset field in a stream frame is 0 for |
1643 // offset 0, and 2 for non-zero offsets up through 64K. Increase | 1650 // offset 0, and 2 for non-zero offsets up through 64K. Increase |
1644 // max_packet_length by 2 so that subsequent packets containing subsequent | 1651 // max_packet_length by 2 so that subsequent packets containing subsequent |
1645 // stream frames with non-zero offets will fit within the packet length. | 1652 // stream frames with non-zero offets will fit within the packet length. |
1646 size_t length = 2 + GetPacketLengthForOneStream( | 1653 size_t length = 2 + GetPacketLengthForOneStream( |
1647 connection_.version(), kIncludeVersion, | 1654 connection_.version(), kIncludeVersion, |
1648 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, | 1655 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, |
1649 IN_FEC_GROUP, &payload_length); | 1656 IN_FEC_GROUP, &payload_length); |
1650 creator->set_max_packet_length(length); | 1657 creator_->set_max_packet_length(length); |
1651 | 1658 |
1652 // Send 4 protected data packets, which should also trigger 1 FEC packet. | 1659 // Send 4 protected data packets, which should also trigger 1 FEC packet. |
1653 EXPECT_CALL(*send_algorithm_, | 1660 EXPECT_CALL(*send_algorithm_, |
1654 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(5); | 1661 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(5); |
1655 // The first stream frame will have 2 fewer overhead bytes than the other 3. | 1662 // The first stream frame will have 2 fewer overhead bytes than the other 3. |
1656 const string payload(payload_length * 4 + 2, 'a'); | 1663 const string payload(payload_length * 4 + 2, 'a'); |
1657 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); | 1664 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); |
1658 // Expect the FEC group to be closed after SendStreamDataWithString. | 1665 // Expect the FEC group to be closed after SendStreamDataWithString. |
1659 EXPECT_FALSE(creator->IsFecGroupOpen()); | 1666 EXPECT_FALSE(creator_->IsFecGroupOpen()); |
1660 EXPECT_FALSE(creator->IsFecProtected()); | 1667 EXPECT_FALSE(creator_->IsFecProtected()); |
1661 } | 1668 } |
1662 | 1669 |
1663 TEST_P(QuicConnectionTest, FECQueueing) { | 1670 TEST_P(QuicConnectionTest, FECQueueing) { |
1664 // All packets carry version info till version is negotiated. | 1671 // All packets carry version info till version is negotiated. |
1665 size_t payload_length; | 1672 size_t payload_length; |
1666 QuicPacketCreator* creator = | |
1667 QuicConnectionPeer::GetPacketCreator(&connection_); | |
1668 size_t length = GetPacketLengthForOneStream( | 1673 size_t length = GetPacketLengthForOneStream( |
1669 connection_.version(), kIncludeVersion, | 1674 connection_.version(), kIncludeVersion, |
1670 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, | 1675 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, |
1671 IN_FEC_GROUP, &payload_length); | 1676 IN_FEC_GROUP, &payload_length); |
1672 creator->set_max_packet_length(length); | 1677 creator_->set_max_packet_length(length); |
1673 EXPECT_TRUE(creator->IsFecEnabled()); | 1678 EXPECT_TRUE(creator_->IsFecEnabled()); |
1674 | 1679 |
1675 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1680 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1676 BlockOnNextWrite(); | 1681 BlockOnNextWrite(); |
1677 const string payload(payload_length, 'a'); | 1682 const string payload(payload_length, 'a'); |
1678 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); | 1683 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); |
1679 EXPECT_FALSE(creator->IsFecGroupOpen()); | 1684 EXPECT_FALSE(creator_->IsFecGroupOpen()); |
1680 EXPECT_FALSE(creator->IsFecProtected()); | 1685 EXPECT_FALSE(creator_->IsFecProtected()); |
1681 // Expect the first data packet and the fec packet to be queued. | 1686 // Expect the first data packet and the fec packet to be queued. |
1682 EXPECT_EQ(2u, connection_.NumQueuedPackets()); | 1687 EXPECT_EQ(2u, connection_.NumQueuedPackets()); |
1683 } | 1688 } |
1684 | 1689 |
| 1690 TEST_P(QuicConnectionTest, FECAlarmStoppedWhenFECPacketSent) { |
| 1691 EXPECT_TRUE(creator_->IsFecEnabled()); |
| 1692 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1693 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1694 |
| 1695 creator_->set_max_packets_per_fec_group(2); |
| 1696 |
| 1697 // 1 Data packet. FEC alarm should be set. |
| 1698 EXPECT_CALL(*send_algorithm_, |
| 1699 OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1700 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, true, nullptr); |
| 1701 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
| 1702 |
| 1703 // Second data packet triggers FEC packet out. FEC alarm should not be set. |
| 1704 EXPECT_CALL(*send_algorithm_, |
| 1705 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(2); |
| 1706 connection_.SendStreamDataWithStringWithFec(5, "foo", 0, true, nullptr); |
| 1707 EXPECT_TRUE(writer_->header().fec_flag); |
| 1708 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1709 } |
| 1710 |
| 1711 TEST_P(QuicConnectionTest, FECAlarmStoppedOnConnectionClose) { |
| 1712 EXPECT_TRUE(creator_->IsFecEnabled()); |
| 1713 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1714 creator_->set_max_packets_per_fec_group(100); |
| 1715 |
| 1716 // 1 Data packet. FEC alarm should be set. |
| 1717 EXPECT_CALL(*send_algorithm_, |
| 1718 OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1719 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
| 1720 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
| 1721 |
| 1722 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NO_ERROR, false)); |
| 1723 // Closing connection should stop the FEC alarm. |
| 1724 connection_.CloseConnection(QUIC_NO_ERROR, /*from_peer=*/false); |
| 1725 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1726 } |
| 1727 |
1685 TEST_P(QuicConnectionTest, RemoveFECFromInflightOnRetransmissionTimeout) { | 1728 TEST_P(QuicConnectionTest, RemoveFECFromInflightOnRetransmissionTimeout) { |
1686 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1729 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1687 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | 1730 EXPECT_TRUE(creator_->IsFecEnabled()); |
1688 &connection_)->IsFecEnabled()); | 1731 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1689 QuicSentPacketManager* manager = | 1732 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
1690 QuicConnectionPeer::GetSentPacketManager(&connection_); | |
1691 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager)); | |
1692 | 1733 |
1693 // 1 Data and 1 FEC packet. | 1734 // 1 Data packet. FEC alarm should be set. |
1694 EXPECT_CALL(*send_algorithm_, | 1735 EXPECT_CALL(*send_algorithm_, |
1695 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(2); | 1736 OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
1696 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); | 1737 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
1697 size_t data_and_fec = QuicSentPacketManagerPeer::GetBytesInFlight(manager); | 1738 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
1698 EXPECT_LT(0u, data_and_fec); | 1739 size_t protected_packet = |
| 1740 QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
1699 | 1741 |
| 1742 // Force FEC timeout to send FEC packet out. |
| 1743 EXPECT_CALL(*send_algorithm_, |
| 1744 OnPacketSent(_, _, 2u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1745 connection_.GetFecAlarm()->Fire(); |
| 1746 EXPECT_TRUE(writer_->header().fec_flag); |
| 1747 |
| 1748 size_t fec_packet = protected_packet; |
| 1749 EXPECT_EQ(protected_packet + fec_packet, |
| 1750 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1700 clock_.AdvanceTime(DefaultRetransmissionTime()); | 1751 clock_.AdvanceTime(DefaultRetransmissionTime()); |
1701 | 1752 |
1702 // On RTO, both data and FEC packets are removed from inflight, | 1753 // On RTO, both data and FEC packets are removed from inflight, only the data |
1703 // and retransmission of the data (but not FEC) gets added into the inflight. | 1754 // packet is retransmitted, and this retransmission (but not FEC) gets added |
| 1755 // back into the inflight. |
1704 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1756 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
1705 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 1757 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
1706 connection_.GetRetransmissionAlarm()->Fire(); | 1758 connection_.GetRetransmissionAlarm()->Fire(); |
1707 | 1759 |
1708 size_t data_only = QuicSentPacketManagerPeer::GetBytesInFlight(manager); | 1760 // The retransmission of packet 1 will be 3 bytes smaller than packet 1, since |
1709 EXPECT_LT(0u, data_only); | 1761 // the first transmission will have 1 byte for FEC group number and 2 bytes of |
1710 EXPECT_GE(data_and_fec, 2 * data_only); | 1762 // stream frame size, which are absent in the retransmission. |
| 1763 size_t retransmitted_packet = protected_packet - 3; |
| 1764 EXPECT_EQ(retransmitted_packet, |
| 1765 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1766 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
1711 | 1767 |
1712 // Receive ack for the retransmission. No data should be outstanding. | 1768 // Receive ack for the retransmission. No data should be outstanding. |
1713 QuicAckFrame ack = InitAckFrame(3); | 1769 QuicAckFrame ack = InitAckFrame(3); |
1714 NackPacket(1, &ack); | 1770 NackPacket(1, &ack); |
1715 NackPacket(2, &ack); | 1771 NackPacket(2, &ack); |
1716 SequenceNumberSet lost_packets; | 1772 SequenceNumberSet lost_packets; |
1717 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1773 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1718 .WillOnce(Return(lost_packets)); | 1774 .WillOnce(Return(lost_packets)); |
1719 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1775 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1720 ProcessAckPacket(&ack); | 1776 ProcessAckPacket(&ack); |
1721 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager)); | 1777 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1722 | 1778 |
1723 // Ensure the alarm is not set since all packets have been acked or abandoned. | 1779 // Ensure the alarm is not set since all packets have been acked or abandoned. |
1724 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 1780 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
1725 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager)); | 1781 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1726 } | 1782 } |
1727 | 1783 |
1728 TEST_P(QuicConnectionTest, RemoveFECFromInflightOnLossRetransmission) { | 1784 TEST_P(QuicConnectionTest, RemoveFECFromInflightOnLossRetransmission) { |
1729 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1785 EXPECT_TRUE(creator_->IsFecEnabled()); |
1730 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | 1786 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
1731 &connection_)->IsFecEnabled()); | |
1732 QuicSentPacketManager* manager = | |
1733 QuicConnectionPeer::GetSentPacketManager(&connection_); | |
1734 | 1787 |
1735 // 1 Data packet and 1 FEC packet, followed by more data to trigger NACKs. | 1788 // 1 FEC-protected data packet. FEC alarm should be set. |
1736 EXPECT_CALL(*send_algorithm_, | 1789 EXPECT_CALL(*send_algorithm_, |
1737 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(6); | 1790 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
1738 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); | 1791 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
1739 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); | 1792 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
1740 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, nullptr); | 1793 size_t protected_packet = |
1741 connection_.SendStreamDataWithString(3, "foo", 9, !kFin, nullptr); | 1794 QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
1742 connection_.SendStreamDataWithString(3, "foo", 12, !kFin, nullptr); | |
1743 size_t multiple_data_and_fec = | |
1744 QuicSentPacketManagerPeer::GetBytesInFlight(manager); | |
1745 EXPECT_LT(0u, multiple_data_and_fec); | |
1746 | 1795 |
1747 // Ack data packets, and NACK 1 data packet and FEC packet. Triggers | 1796 // Force FEC timeout to send FEC packet out. |
1748 // NACK-based loss detection of data and FEC packet, but only data is | 1797 EXPECT_CALL(*send_algorithm_, |
| 1798 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1799 connection_.GetFecAlarm()->Fire(); |
| 1800 EXPECT_TRUE(writer_->header().fec_flag); |
| 1801 size_t fec_packet = protected_packet; |
| 1802 EXPECT_EQ(protected_packet + fec_packet, |
| 1803 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1804 |
| 1805 // Send more data to trigger NACKs. Note that all data starts at stream offset |
| 1806 // 0 to ensure the same packet size, for ease of testing. |
| 1807 EXPECT_CALL(*send_algorithm_, |
| 1808 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(4); |
| 1809 connection_.SendStreamDataWithString(5, "foo", 0, kFin, nullptr); |
| 1810 connection_.SendStreamDataWithString(7, "foo", 0, kFin, nullptr); |
| 1811 connection_.SendStreamDataWithString(9, "foo", 0, kFin, nullptr); |
| 1812 connection_.SendStreamDataWithString(11, "foo", 0, kFin, nullptr); |
| 1813 |
| 1814 // An unprotected packet will be 3 bytes smaller than an FEC-protected packet, |
| 1815 // since the protected packet will have 1 byte for FEC group number and |
| 1816 // 2 bytes of stream frame size, which are absent in the unprotected packet. |
| 1817 size_t unprotected_packet = protected_packet - 3; |
| 1818 EXPECT_EQ(protected_packet + fec_packet + 4 * unprotected_packet, |
| 1819 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1820 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1821 |
| 1822 // Ack data packets, and NACK FEC packet and one data packet. Triggers |
| 1823 // NACK-based loss detection of both packets, but only data packet is |
1749 // retransmitted and considered oustanding. | 1824 // retransmitted and considered oustanding. |
1750 QuicAckFrame ack = InitAckFrame(6); | 1825 QuicAckFrame ack = InitAckFrame(6); |
1751 NackPacket(2, &ack); | 1826 NackPacket(2, &ack); |
1752 NackPacket(3, &ack); | 1827 NackPacket(3, &ack); |
1753 SequenceNumberSet lost_packets; | 1828 SequenceNumberSet lost_packets; |
1754 lost_packets.insert(2); | 1829 lost_packets.insert(2); |
1755 lost_packets.insert(3); | 1830 lost_packets.insert(3); |
1756 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1831 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1757 .WillOnce(Return(lost_packets)); | 1832 .WillOnce(Return(lost_packets)); |
1758 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1833 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1759 EXPECT_CALL(*send_algorithm_, | 1834 EXPECT_CALL(*send_algorithm_, |
1760 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(1); | 1835 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1836 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1761 ProcessAckPacket(&ack); | 1837 ProcessAckPacket(&ack); |
1762 size_t data_only = QuicSentPacketManagerPeer::GetBytesInFlight(manager); | 1838 // On receiving this ack from the server, the client will no longer send |
1763 EXPECT_GT(multiple_data_and_fec, data_only); | 1839 // version number in subsequent packets, including in this retransmission. |
1764 EXPECT_LT(0u, data_only); | 1840 size_t unprotected_packet_no_version = unprotected_packet - 4; |
| 1841 EXPECT_EQ(unprotected_packet_no_version, |
| 1842 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1765 | 1843 |
1766 // Receive ack for the retransmission. No data should be outstanding. | 1844 // Receive ack for the retransmission. No data should be outstanding. |
1767 QuicAckFrame ack2 = InitAckFrame(7); | 1845 QuicAckFrame ack2 = InitAckFrame(7); |
1768 NackPacket(2, &ack2); | 1846 NackPacket(2, &ack2); |
1769 NackPacket(3, &ack2); | 1847 NackPacket(3, &ack2); |
1770 SequenceNumberSet lost_packets2; | 1848 SequenceNumberSet lost_packets2; |
1771 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1849 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1772 .WillOnce(Return(lost_packets2)); | 1850 .WillOnce(Return(lost_packets2)); |
1773 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1851 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1774 ProcessAckPacket(&ack2); | 1852 ProcessAckPacket(&ack2); |
1775 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager)); | 1853 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1854 } |
| 1855 |
| 1856 TEST_P(QuicConnectionTest, FECRemainsInflightOnTLPOfEarlierData) { |
| 1857 // This test checks if TLP is sent correctly when a data and an FEC packet |
| 1858 // are outstanding. TLP should be sent for the data packet when the |
| 1859 // retransmission alarm fires. |
| 1860 // Turn on TLP for this test. |
| 1861 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
| 1862 EXPECT_TRUE(creator_->IsFecEnabled()); |
| 1863 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1864 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1865 |
| 1866 // 1 Data packet. FEC alarm should be set. |
| 1867 EXPECT_CALL(*send_algorithm_, |
| 1868 OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1869 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
| 1870 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
| 1871 size_t protected_packet = |
| 1872 QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
| 1873 EXPECT_LT(0u, protected_packet); |
| 1874 |
| 1875 // Force FEC timeout to send FEC packet out. |
| 1876 EXPECT_CALL(*send_algorithm_, |
| 1877 OnPacketSent(_, _, 2u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1878 connection_.GetFecAlarm()->Fire(); |
| 1879 EXPECT_TRUE(writer_->header().fec_flag); |
| 1880 size_t fec_packet = protected_packet; |
| 1881 EXPECT_EQ(protected_packet + fec_packet, |
| 1882 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1883 |
| 1884 // TLP alarm should be set. |
| 1885 QuicTime retransmission_time = |
| 1886 connection_.GetRetransmissionAlarm()->deadline(); |
| 1887 EXPECT_NE(QuicTime::Zero(), retransmission_time); |
| 1888 // Simulate the retransmission alarm firing and sending a TLP, so send |
| 1889 // algorithm's OnRetransmissionTimeout is not called. |
| 1890 clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); |
| 1891 EXPECT_CALL(*send_algorithm_, |
| 1892 OnPacketSent(_, _, 3u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1893 connection_.GetRetransmissionAlarm()->Fire(); |
| 1894 // The TLP retransmission of packet 1 will be 3 bytes smaller than packet 1, |
| 1895 // since packet 1 will have 1 byte for FEC group number and 2 bytes of stream |
| 1896 // frame size, which are absent in the the TLP retransmission. |
| 1897 size_t tlp_packet = protected_packet - 3; |
| 1898 EXPECT_EQ(protected_packet + fec_packet + tlp_packet, |
| 1899 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1900 } |
| 1901 |
| 1902 TEST_P(QuicConnectionTest, FECRemainsInflightOnTLPOfLaterData) { |
| 1903 // Tests if TLP is sent correctly when data packet 1 and an FEC packet are |
| 1904 // sent followed by data packet 2, and data packet 1 is acked. TLP should be |
| 1905 // sent for data packet 2 when the retransmission alarm fires. Turn on TLP for |
| 1906 // this test. |
| 1907 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
| 1908 EXPECT_TRUE(creator_->IsFecEnabled()); |
| 1909 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1910 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1911 |
| 1912 // 1 Data packet. FEC alarm should be set. |
| 1913 EXPECT_CALL(*send_algorithm_, |
| 1914 OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1915 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
| 1916 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
| 1917 size_t protected_packet = |
| 1918 QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
| 1919 EXPECT_LT(0u, protected_packet); |
| 1920 |
| 1921 // Force FEC timeout to send FEC packet out. |
| 1922 EXPECT_CALL(*send_algorithm_, |
| 1923 OnPacketSent(_, _, 2u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1924 connection_.GetFecAlarm()->Fire(); |
| 1925 EXPECT_TRUE(writer_->header().fec_flag); |
| 1926 // Protected data packet and FEC packet oustanding. |
| 1927 size_t fec_packet = protected_packet; |
| 1928 EXPECT_EQ(protected_packet + fec_packet, |
| 1929 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1930 |
| 1931 // Send 1 unprotected data packet. No FEC alarm should be set. |
| 1932 EXPECT_CALL(*send_algorithm_, |
| 1933 OnPacketSent(_, _, 3u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1934 connection_.SendStreamDataWithString(5, "foo", 0, kFin, nullptr); |
| 1935 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1936 // Protected data packet, FEC packet, and unprotected data packet oustanding. |
| 1937 // An unprotected packet will be 3 bytes smaller than an FEC-protected packet, |
| 1938 // since the protected packet will have 1 byte for FEC group number and |
| 1939 // 2 bytes of stream frame size, which are absent in the unprotected packet. |
| 1940 size_t unprotected_packet = protected_packet - 3; |
| 1941 EXPECT_EQ(protected_packet + fec_packet + unprotected_packet, |
| 1942 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1943 |
| 1944 // Receive ack for first data packet. FEC and second data packet are still |
| 1945 // outstanding. |
| 1946 QuicAckFrame ack = InitAckFrame(1); |
| 1947 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1948 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1949 ProcessAckPacket(&ack); |
| 1950 // FEC packet and unprotected data packet oustanding. |
| 1951 EXPECT_EQ(fec_packet + unprotected_packet, |
| 1952 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1953 |
| 1954 // TLP alarm should be set. |
| 1955 QuicTime retransmission_time = |
| 1956 connection_.GetRetransmissionAlarm()->deadline(); |
| 1957 EXPECT_NE(QuicTime::Zero(), retransmission_time); |
| 1958 // Simulate the retransmission alarm firing and sending a TLP, so send |
| 1959 // algorithm's OnRetransmissionTimeout is not called. |
| 1960 clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); |
| 1961 EXPECT_CALL(*send_algorithm_, |
| 1962 OnPacketSent(_, _, 4u, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1963 connection_.GetRetransmissionAlarm()->Fire(); |
| 1964 |
| 1965 // Having received an ack from the server, the client will no longer send |
| 1966 // version number in subsequent packets, including in this retransmission. |
| 1967 size_t tlp_packet_no_version = unprotected_packet - 4; |
| 1968 EXPECT_EQ(fec_packet + unprotected_packet + tlp_packet_no_version, |
| 1969 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1776 } | 1970 } |
1777 | 1971 |
1778 TEST_P(QuicConnectionTest, NoTLPForFECPacket) { | 1972 TEST_P(QuicConnectionTest, NoTLPForFECPacket) { |
1779 // Turn on TLP for this test. | 1973 // Turn on TLP for this test. |
1780 QuicSentPacketManagerPeer::SetMaxTailLossProbes( | 1974 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
1781 QuicConnectionPeer::GetSentPacketManager(&connection_), 1); | 1975 EXPECT_TRUE(creator_->IsFecEnabled()); |
| 1976 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1782 | 1977 |
1783 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1978 // Send 1 FEC-protected data packet. FEC alarm should be set. |
1784 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | |
1785 &connection_)->IsFecEnabled()); | |
1786 QuicSentPacketManager* manager = | |
1787 QuicConnectionPeer::GetSentPacketManager(&connection_); | |
1788 | |
1789 // 1 Data packet and 1 FEC packet. | |
1790 EXPECT_CALL(*send_algorithm_, | 1979 EXPECT_CALL(*send_algorithm_, |
1791 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(2); | 1980 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
1792 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); | 1981 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
| 1982 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
| 1983 // Force FEC timeout to send FEC packet out. |
| 1984 EXPECT_CALL(*send_algorithm_, |
| 1985 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(1); |
| 1986 connection_.GetFecAlarm()->Fire(); |
| 1987 EXPECT_TRUE(writer_->header().fec_flag); |
1793 | 1988 |
1794 // Ack data packet, but not FEC packet. | 1989 // Ack data packet, but not FEC packet. |
1795 QuicAckFrame ack = InitAckFrame(1); | 1990 QuicAckFrame ack = InitAckFrame(1); |
1796 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1991 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1797 ProcessAckPacket(&ack); | 1992 ProcessAckPacket(&ack); |
1798 | 1993 |
1799 // No TLP alarm for FEC, so when retransmission alarm fires, it is an RTO. | 1994 // No TLP alarm for FEC, but retransmission alarm should be set for an RTO. |
| 1995 EXPECT_LT(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1800 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 1996 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
1801 EXPECT_LT(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager)); | |
1802 QuicTime rto_time = connection_.GetRetransmissionAlarm()->deadline(); | 1997 QuicTime rto_time = connection_.GetRetransmissionAlarm()->deadline(); |
1803 EXPECT_NE(QuicTime::Zero(), rto_time); | 1998 EXPECT_NE(QuicTime::Zero(), rto_time); |
1804 | 1999 |
1805 // Simulate the retransmission alarm firing. FEC packet is no longer | 2000 // Simulate the retransmission alarm firing. FEC packet is no longer |
1806 // outstanding. | 2001 // outstanding. |
1807 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(false)); | 2002 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(false)); |
1808 clock_.AdvanceTime(rto_time.Subtract(clock_.Now())); | 2003 clock_.AdvanceTime(rto_time.Subtract(clock_.Now())); |
1809 connection_.GetRetransmissionAlarm()->Fire(); | 2004 connection_.GetRetransmissionAlarm()->Fire(); |
1810 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 2005 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
1811 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager)); | 2006 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
1812 } | 2007 } |
1813 | 2008 |
1814 TEST_P(QuicConnectionTest, FramePacking) { | 2009 TEST_P(QuicConnectionTest, FramePacking) { |
1815 CongestionBlockWrites(); | 2010 CongestionBlockWrites(); |
1816 | 2011 |
1817 // Send an ack and two stream frames in 1 packet by queueing them. | 2012 // Send an ack and two stream frames in 1 packet by queueing them. |
1818 connection_.SendAck(); | 2013 connection_.SendAck(); |
1819 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( | 2014 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( |
1820 IgnoreResult(InvokeWithoutArgs(&connection_, | 2015 IgnoreResult(InvokeWithoutArgs(&connection_, |
1821 &TestConnection::SendStreamData3)), | 2016 &TestConnection::SendStreamData3)), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 2075 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1881 EXPECT_FALSE(connection_.HasQueuedData()); | 2076 EXPECT_FALSE(connection_.HasQueuedData()); |
1882 | 2077 |
1883 // Parse the last packet and ensure it's the stream frame from stream 3. | 2078 // Parse the last packet and ensure it's the stream frame from stream 3. |
1884 EXPECT_EQ(1u, writer_->frame_count()); | 2079 EXPECT_EQ(1u, writer_->frame_count()); |
1885 ASSERT_EQ(1u, writer_->stream_frames().size()); | 2080 ASSERT_EQ(1u, writer_->stream_frames().size()); |
1886 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0].stream_id); | 2081 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0].stream_id); |
1887 } | 2082 } |
1888 | 2083 |
1889 TEST_P(QuicConnectionTest, FramePackingFEC) { | 2084 TEST_P(QuicConnectionTest, FramePackingFEC) { |
1890 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | 2085 EXPECT_TRUE(creator_->IsFecEnabled()); |
1891 &connection_)->IsFecEnabled()); | |
1892 | 2086 |
1893 CongestionBlockWrites(); | 2087 CongestionBlockWrites(); |
1894 | 2088 |
1895 // Queue an ack and two stream frames. Ack gets flushed when FEC is turned on | 2089 // Queue an ack and two stream frames. Ack gets flushed when FEC is turned on |
1896 // for sending protected data; two stream frames are packing in 1 packet. | 2090 // for sending protected data; two stream frames are packed in 1 packet. |
1897 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( | 2091 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( |
1898 IgnoreResult(InvokeWithoutArgs( | 2092 IgnoreResult(InvokeWithoutArgs( |
1899 &connection_, &TestConnection::SendStreamData3WithFec)), | 2093 &connection_, &TestConnection::SendStreamData3WithFec)), |
1900 IgnoreResult(InvokeWithoutArgs( | 2094 IgnoreResult(InvokeWithoutArgs( |
1901 &connection_, &TestConnection::SendStreamData5WithFec)))); | 2095 &connection_, &TestConnection::SendStreamData5WithFec)))); |
1902 connection_.SendAck(); | 2096 connection_.SendAck(); |
1903 | 2097 |
1904 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); | 2098 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
1905 CongestionUnblockWrites(); | 2099 CongestionUnblockWrites(); |
1906 connection_.GetSendAlarm()->Fire(); | 2100 connection_.GetSendAlarm()->Fire(); |
1907 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 2101 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1908 EXPECT_FALSE(connection_.HasQueuedData()); | 2102 EXPECT_FALSE(connection_.HasQueuedData()); |
1909 | 2103 |
1910 // Parse the last packet and ensure it's in an fec group. | 2104 // Parse the last packet and ensure it's in an fec group. |
1911 EXPECT_EQ(2u, writer_->header().fec_group); | 2105 EXPECT_EQ(2u, writer_->header().fec_group); |
1912 EXPECT_EQ(0u, writer_->frame_count()); | 2106 EXPECT_EQ(2u, writer_->frame_count()); |
| 2107 |
| 2108 // FEC alarm should be set. |
| 2109 EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
1913 } | 2110 } |
1914 | 2111 |
1915 TEST_P(QuicConnectionTest, FramePackingAckResponse) { | 2112 TEST_P(QuicConnectionTest, FramePackingAckResponse) { |
1916 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2113 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1917 // Process a data packet to queue up a pending ack. | 2114 // Process a data packet to queue up a pending ack. |
1918 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); | 2115 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); |
1919 ProcessDataPacket(1, 1, kEntropyFlag); | 2116 ProcessDataPacket(1, 1, kEntropyFlag); |
1920 | 2117 |
1921 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( | 2118 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( |
1922 IgnoreResult(InvokeWithoutArgs(&connection_, | 2119 IgnoreResult(InvokeWithoutArgs(&connection_, |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 ProcessFecPacket(6, 1, false, kEntropyFlag, nullptr); | 2621 ProcessFecPacket(6, 1, false, kEntropyFlag, nullptr); |
2425 ProcessFecProtectedPacket(3, false, kEntropyFlag); | 2622 ProcessFecProtectedPacket(3, false, kEntropyFlag); |
2426 ProcessFecProtectedPacket(4, false, kEntropyFlag); | 2623 ProcessFecProtectedPacket(4, false, kEntropyFlag); |
2427 ProcessFecProtectedPacket(5, true, !kEntropyFlag); | 2624 ProcessFecProtectedPacket(5, true, !kEntropyFlag); |
2428 // Ensure entropy is not revived for the missing packet. | 2625 // Ensure entropy is not revived for the missing packet. |
2429 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2626 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
2430 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 3)); | 2627 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 3)); |
2431 } | 2628 } |
2432 | 2629 |
2433 TEST_P(QuicConnectionTest, TLP) { | 2630 TEST_P(QuicConnectionTest, TLP) { |
2434 QuicSentPacketManagerPeer::SetMaxTailLossProbes( | 2631 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
2435 QuicConnectionPeer::GetSentPacketManager(&connection_), 1); | |
2436 | 2632 |
2437 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); | 2633 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); |
2438 EXPECT_EQ(1u, stop_waiting()->least_unacked); | 2634 EXPECT_EQ(1u, stop_waiting()->least_unacked); |
2439 QuicTime retransmission_time = | 2635 QuicTime retransmission_time = |
2440 connection_.GetRetransmissionAlarm()->deadline(); | 2636 connection_.GetRetransmissionAlarm()->deadline(); |
2441 EXPECT_NE(QuicTime::Zero(), retransmission_time); | 2637 EXPECT_NE(QuicTime::Zero(), retransmission_time); |
2442 | 2638 |
2443 EXPECT_EQ(1u, writer_->header().packet_sequence_number); | 2639 EXPECT_EQ(1u, writer_->header().packet_sequence_number); |
2444 // Simulate the retransmission alarm firing and sending a tlp, | 2640 // Simulate the retransmission alarm firing and sending a tlp, |
2445 // so send algorithm's OnRetransmissionTimeout is not called. | 2641 // so send algorithm's OnRetransmissionTimeout is not called. |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 // Simulate the timeout alarm firing. | 3115 // Simulate the timeout alarm firing. |
2920 clock_.AdvanceTime( | 3116 clock_.AdvanceTime( |
2921 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); | 3117 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); |
2922 connection_.GetTimeoutAlarm()->Fire(); | 3118 connection_.GetTimeoutAlarm()->Fire(); |
2923 | 3119 |
2924 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3120 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
2925 EXPECT_FALSE(connection_.connected()); | 3121 EXPECT_FALSE(connection_.connected()); |
2926 | 3122 |
2927 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3123 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
2928 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3124 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3125 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
2929 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 3126 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
2930 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 3127 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
2931 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); | 3128 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
2932 } | 3129 } |
2933 | 3130 |
2934 TEST_P(QuicConnectionTest, OverallTimeout) { | 3131 TEST_P(QuicConnectionTest, OverallTimeout) { |
2935 // Use a shorter overall connection timeout than idle timeout for this test. | 3132 // Use a shorter overall connection timeout than idle timeout for this test. |
2936 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5); | 3133 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5); |
2937 connection_.SetNetworkTimeouts(timeout, timeout); | 3134 connection_.SetNetworkTimeouts(timeout, timeout); |
2938 EXPECT_TRUE(connection_.connected()); | 3135 EXPECT_TRUE(connection_.connected()); |
(...skipping 22 matching lines...) Expand all Loading... |
2961 EXPECT_CALL(visitor_, | 3158 EXPECT_CALL(visitor_, |
2962 OnConnectionClosed(QUIC_CONNECTION_OVERALL_TIMED_OUT, false)); | 3159 OnConnectionClosed(QUIC_CONNECTION_OVERALL_TIMED_OUT, false)); |
2963 // Simulate the timeout alarm firing. | 3160 // Simulate the timeout alarm firing. |
2964 connection_.GetTimeoutAlarm()->Fire(); | 3161 connection_.GetTimeoutAlarm()->Fire(); |
2965 | 3162 |
2966 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3163 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
2967 EXPECT_FALSE(connection_.connected()); | 3164 EXPECT_FALSE(connection_.connected()); |
2968 | 3165 |
2969 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3166 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
2970 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3167 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3168 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
2971 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 3169 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
2972 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 3170 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
2973 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); | 3171 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
2974 } | 3172 } |
2975 | 3173 |
2976 TEST_P(QuicConnectionTest, PingAfterSend) { | 3174 TEST_P(QuicConnectionTest, PingAfterSend) { |
2977 EXPECT_TRUE(connection_.connected()); | 3175 EXPECT_TRUE(connection_.connected()); |
2978 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); | 3176 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); |
2979 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3177 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2980 | 3178 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3132 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 3330 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
3133 } | 3331 } |
3134 | 3332 |
3135 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { | 3333 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { |
3136 // All packets carry version info till version is negotiated. | 3334 // All packets carry version info till version is negotiated. |
3137 size_t payload_length; | 3335 size_t payload_length; |
3138 size_t length = GetPacketLengthForOneStream( | 3336 size_t length = GetPacketLengthForOneStream( |
3139 connection_.version(), kIncludeVersion, | 3337 connection_.version(), kIncludeVersion, |
3140 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, | 3338 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, |
3141 NOT_IN_FEC_GROUP, &payload_length); | 3339 NOT_IN_FEC_GROUP, &payload_length); |
3142 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( | 3340 creator_->set_max_packet_length(length); |
3143 length); | |
3144 | 3341 |
3145 // Queue the first packet. | 3342 // Queue the first packet. |
3146 EXPECT_CALL(*send_algorithm_, | 3343 EXPECT_CALL(*send_algorithm_, |
3147 TimeUntilSend(_, _, _)).WillOnce( | 3344 TimeUntilSend(_, _, _)).WillOnce( |
3148 testing::Return(QuicTime::Delta::FromMicroseconds(10))); | 3345 testing::Return(QuicTime::Delta::FromMicroseconds(10))); |
3149 const string payload(payload_length, 'a'); | 3346 const string payload(payload_length, 'a'); |
3150 EXPECT_EQ(0u, connection_.SendStreamDataWithString(3, payload, 0, !kFin, | 3347 EXPECT_EQ(0u, connection_.SendStreamDataWithString(3, payload, 0, !kFin, |
3151 nullptr).bytes_consumed); | 3348 nullptr).bytes_consumed); |
3152 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 3349 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
3153 } | 3350 } |
3154 | 3351 |
3155 TEST_P(QuicConnectionTest, LoopThroughSendingPackets) { | 3352 TEST_P(QuicConnectionTest, LoopThroughSendingPackets) { |
3156 // All packets carry version info till version is negotiated. | 3353 // All packets carry version info till version is negotiated. |
3157 size_t payload_length; | 3354 size_t payload_length; |
3158 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining | 3355 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining |
3159 // packet length. The size of the offset field in a stream frame is 0 for | 3356 // packet length. The size of the offset field in a stream frame is 0 for |
3160 // offset 0, and 2 for non-zero offsets up through 16K. Increase | 3357 // offset 0, and 2 for non-zero offsets up through 16K. Increase |
3161 // max_packet_length by 2 so that subsequent packets containing subsequent | 3358 // max_packet_length by 2 so that subsequent packets containing subsequent |
3162 // stream frames with non-zero offets will fit within the packet length. | 3359 // stream frames with non-zero offets will fit within the packet length. |
3163 size_t length = 2 + GetPacketLengthForOneStream( | 3360 size_t length = 2 + GetPacketLengthForOneStream( |
3164 connection_.version(), kIncludeVersion, | 3361 connection_.version(), kIncludeVersion, |
3165 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, | 3362 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, |
3166 NOT_IN_FEC_GROUP, &payload_length); | 3363 NOT_IN_FEC_GROUP, &payload_length); |
3167 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( | 3364 creator_->set_max_packet_length(length); |
3168 length); | |
3169 | 3365 |
3170 // Queue the first packet. | 3366 // Queue the first packet. |
3171 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(7); | 3367 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(7); |
3172 // The first stream frame will have 2 fewer overhead bytes than the other six. | 3368 // The first stream frame will have 2 fewer overhead bytes than the other six. |
3173 const string payload(payload_length * 7 + 2, 'a'); | 3369 const string payload(payload_length * 7 + 2, 'a'); |
3174 EXPECT_EQ(payload.size(), | 3370 EXPECT_EQ(payload.size(), |
3175 connection_.SendStreamDataWithString(1, payload, 0, !kFin, nullptr) | 3371 connection_.SendStreamDataWithString(1, payload, 0, !kFin, nullptr) |
3176 .bytes_consumed); | 3372 .bytes_consumed); |
3177 } | 3373 } |
3178 | 3374 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3731 QuicFrames frames; | 3927 QuicFrames frames; |
3732 QuicFrame frame(&frame1_); | 3928 QuicFrame frame(&frame1_); |
3733 frames.push_back(frame); | 3929 frames.push_back(frame); |
3734 scoped_ptr<QuicPacket> packet( | 3930 scoped_ptr<QuicPacket> packet( |
3735 BuildUnsizedDataPacket(&framer_, header, frames).packet); | 3931 BuildUnsizedDataPacket(&framer_, header, frames).packet); |
3736 encrypted.reset(framer_.EncryptPacket(ENCRYPTION_NONE, 12, *packet)); | 3932 encrypted.reset(framer_.EncryptPacket(ENCRYPTION_NONE, 12, *packet)); |
3737 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); | 3933 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); |
3738 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3934 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3739 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3935 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
3740 | 3936 |
3741 ASSERT_FALSE(QuicPacketCreatorPeer::SendVersionInPacket( | 3937 ASSERT_FALSE(QuicPacketCreatorPeer::SendVersionInPacket(creator_)); |
3742 QuicConnectionPeer::GetPacketCreator(&connection_))); | |
3743 } | 3938 } |
3744 | 3939 |
3745 TEST_P(QuicConnectionTest, BadVersionNegotiation) { | 3940 TEST_P(QuicConnectionTest, BadVersionNegotiation) { |
3746 QuicPacketHeader header; | 3941 QuicPacketHeader header; |
3747 header.public_header.connection_id = connection_id_; | 3942 header.public_header.connection_id = connection_id_; |
3748 header.public_header.reset_flag = false; | 3943 header.public_header.reset_flag = false; |
3749 header.public_header.version_flag = true; | 3944 header.public_header.version_flag = true; |
3750 header.entropy_flag = false; | 3945 header.entropy_flag = false; |
3751 header.fec_flag = false; | 3946 header.fec_flag = false; |
3752 header.packet_sequence_number = 12; | 3947 header.packet_sequence_number = 12; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4168 | 4363 |
4169 QuicPacket* packet = | 4364 QuicPacket* packet = |
4170 BuildUnsizedDataPacket(&framer_, ack_header, frames).packet; | 4365 BuildUnsizedDataPacket(&framer_, ack_header, frames).packet; |
4171 | 4366 |
4172 // Take the packet which contains the ACK frame, and construct and deliver an | 4367 // Take the packet which contains the ACK frame, and construct and deliver an |
4173 // FEC packet which allows the ACK packet to be recovered. | 4368 // FEC packet which allows the ACK packet to be recovered. |
4174 ProcessFecPacket(2, 1, true, !kEntropyFlag, packet); | 4369 ProcessFecPacket(2, 1, true, !kEntropyFlag, packet); |
4175 } | 4370 } |
4176 | 4371 |
4177 TEST_P(QuicConnectionTest, NetworkChangeVisitorCwndCallbackChangesFecState) { | 4372 TEST_P(QuicConnectionTest, NetworkChangeVisitorCwndCallbackChangesFecState) { |
4178 QuicPacketCreator* creator = | 4373 size_t max_packets_per_fec_group = creator_->max_packets_per_fec_group(); |
4179 QuicConnectionPeer::GetPacketCreator(&connection_); | |
4180 size_t max_packets_per_fec_group = creator->max_packets_per_fec_group(); | |
4181 | 4374 |
4182 QuicSentPacketManager::NetworkChangeVisitor* visitor = | 4375 QuicSentPacketManager::NetworkChangeVisitor* visitor = |
4183 QuicSentPacketManagerPeer::GetNetworkChangeVisitor( | 4376 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); |
4184 QuicConnectionPeer::GetSentPacketManager(&connection_)); | |
4185 EXPECT_TRUE(visitor); | 4377 EXPECT_TRUE(visitor); |
4186 | 4378 |
4187 // Increase FEC group size by increasing congestion window to a large number. | 4379 // Increase FEC group size by increasing congestion window to a large number. |
4188 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( | 4380 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( |
4189 Return(1000 * kDefaultTCPMSS)); | 4381 Return(1000 * kDefaultTCPMSS)); |
4190 visitor->OnCongestionWindowChange(); | 4382 visitor->OnCongestionWindowChange(); |
4191 EXPECT_LT(max_packets_per_fec_group, creator->max_packets_per_fec_group()); | 4383 EXPECT_LT(max_packets_per_fec_group, creator_->max_packets_per_fec_group()); |
4192 } | 4384 } |
4193 | 4385 |
4194 TEST_P(QuicConnectionTest, NetworkChangeVisitorConfigCallbackChangesFecState) { | 4386 TEST_P(QuicConnectionTest, NetworkChangeVisitorConfigCallbackChangesFecState) { |
4195 QuicSentPacketManager* sent_packet_manager = | |
4196 QuicConnectionPeer::GetSentPacketManager(&connection_); | |
4197 QuicSentPacketManager::NetworkChangeVisitor* visitor = | 4387 QuicSentPacketManager::NetworkChangeVisitor* visitor = |
4198 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(sent_packet_manager); | 4388 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); |
4199 EXPECT_TRUE(visitor); | 4389 EXPECT_TRUE(visitor); |
4200 | 4390 EXPECT_EQ(QuicTime::Delta::Zero(), |
4201 QuicPacketGenerator* generator = | 4391 QuicPacketGeneratorPeer::GetFecTimeout(generator_)); |
4202 QuicConnectionPeer::GetPacketGenerator(&connection_); | |
4203 EXPECT_EQ(QuicTime::Delta::Zero(), generator->fec_timeout()); | |
4204 | 4392 |
4205 // Verify that sending a config with a new initial rtt changes fec timeout. | 4393 // Verify that sending a config with a new initial rtt changes fec timeout. |
4206 // Create and process a config with a non-zero initial RTT. | 4394 // Create and process a config with a non-zero initial RTT. |
4207 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); | 4395 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); |
4208 QuicConfig config; | 4396 QuicConfig config; |
4209 config.SetInitialRoundTripTimeUsToSend(300000); | 4397 config.SetInitialRoundTripTimeUsToSend(300000); |
4210 connection_.SetFromConfig(config); | 4398 connection_.SetFromConfig(config); |
4211 EXPECT_LT(QuicTime::Delta::Zero(), generator->fec_timeout()); | 4399 EXPECT_LT(QuicTime::Delta::Zero(), |
| 4400 QuicPacketGeneratorPeer::GetFecTimeout(generator_)); |
4212 } | 4401 } |
4213 | 4402 |
4214 TEST_P(QuicConnectionTest, NetworkChangeVisitorRttCallbackChangesFecState) { | 4403 TEST_P(QuicConnectionTest, NetworkChangeVisitorRttCallbackChangesFecState) { |
4215 // Verify that sending a config with a new initial rtt changes fec timeout. | 4404 // Verify that sending a config with a new initial rtt changes fec timeout. |
4216 QuicSentPacketManager* sent_packet_manager = | |
4217 QuicConnectionPeer::GetSentPacketManager(&connection_); | |
4218 QuicSentPacketManager::NetworkChangeVisitor* visitor = | 4405 QuicSentPacketManager::NetworkChangeVisitor* visitor = |
4219 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(sent_packet_manager); | 4406 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); |
4220 EXPECT_TRUE(visitor); | 4407 EXPECT_TRUE(visitor); |
4221 | 4408 EXPECT_EQ(QuicTime::Delta::Zero(), |
4222 QuicPacketGenerator* generator = | 4409 QuicPacketGeneratorPeer::GetFecTimeout(generator_)); |
4223 QuicConnectionPeer::GetPacketGenerator(&connection_); | |
4224 EXPECT_EQ(QuicTime::Delta::Zero(), generator->fec_timeout()); | |
4225 | 4410 |
4226 // Increase FEC timeout by increasing RTT. | 4411 // Increase FEC timeout by increasing RTT. |
4227 RttStats* rtt_stats = | 4412 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
4228 QuicSentPacketManagerPeer::GetRttStats(sent_packet_manager); | |
4229 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(300), | 4413 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(300), |
4230 QuicTime::Delta::Zero(), QuicTime::Zero()); | 4414 QuicTime::Delta::Zero(), QuicTime::Zero()); |
4231 visitor->OnRttChange(); | 4415 visitor->OnRttChange(); |
4232 EXPECT_LT(QuicTime::Delta::Zero(), generator->fec_timeout()); | 4416 EXPECT_LT(QuicTime::Delta::Zero(), |
| 4417 QuicPacketGeneratorPeer::GetFecTimeout(generator_)); |
4233 } | 4418 } |
4234 | 4419 |
4235 class MockQuicConnectionDebugVisitor | 4420 class MockQuicConnectionDebugVisitor |
4236 : public QuicConnectionDebugVisitor { | 4421 : public QuicConnectionDebugVisitor { |
4237 public: | 4422 public: |
4238 MOCK_METHOD1(OnFrameAddedToPacket, | 4423 MOCK_METHOD1(OnFrameAddedToPacket, |
4239 void(const QuicFrame&)); | 4424 void(const QuicFrame&)); |
4240 | 4425 |
4241 MOCK_METHOD6(OnPacketSent, | 4426 MOCK_METHOD6(OnPacketSent, |
4242 void(const SerializedPacket&, | 4427 void(const SerializedPacket&, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4334 // Regression test for b/18594622 | 4519 // Regression test for b/18594622 |
4335 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 4520 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
4336 EXPECT_DFATAL( | 4521 EXPECT_DFATAL( |
4337 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), | 4522 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), |
4338 "Attempt to send empty stream frame"); | 4523 "Attempt to send empty stream frame"); |
4339 } | 4524 } |
4340 | 4525 |
4341 } // namespace | 4526 } // namespace |
4342 } // namespace test | 4527 } // namespace test |
4343 } // namespace net | 4528 } // namespace net |
OLD | NEW |