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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 QuicVersion version) | 469 QuicVersion version) |
470 : QuicConnection(connection_id, | 470 : QuicConnection(connection_id, |
471 address, | 471 address, |
472 helper, | 472 helper, |
473 alarm_factory, | 473 alarm_factory, |
474 writer, | 474 writer, |
475 /* owns_writer= */ false, | 475 /* owns_writer= */ false, |
476 perspective, | 476 perspective, |
477 SupportedVersions(version)) { | 477 SupportedVersions(version)) { |
478 writer->set_perspective(perspective); | 478 writer->set_perspective(perspective); |
| 479 SetEncrypter(ENCRYPTION_FORWARD_SECURE, new NullEncrypter()); |
479 } | 480 } |
480 | 481 |
481 void SendAck() { QuicConnectionPeer::SendAck(this); } | 482 void SendAck() { QuicConnectionPeer::SendAck(this); } |
482 | 483 |
483 void SetSendAlgorithm(QuicPathId path_id, | 484 void SetSendAlgorithm(QuicPathId path_id, |
484 SendAlgorithmInterface* send_algorithm) { | 485 SendAlgorithmInterface* send_algorithm) { |
485 QuicConnectionPeer::SetSendAlgorithm(this, path_id, send_algorithm); | 486 QuicConnectionPeer::SetSendAlgorithm(this, path_id, send_algorithm); |
486 } | 487 } |
487 | 488 |
488 void SetLossAlgorithm(QuicPathId path_id, | 489 void SetLossAlgorithm(QuicPathId path_id, |
(...skipping 24 matching lines...) Expand all Loading... |
513 } | 514 } |
514 OnSerializedPacket(&serialized_packet); | 515 OnSerializedPacket(&serialized_packet); |
515 } | 516 } |
516 | 517 |
517 QuicConsumedData SendStreamDataWithString( | 518 QuicConsumedData SendStreamDataWithString( |
518 QuicStreamId id, | 519 QuicStreamId id, |
519 StringPiece data, | 520 StringPiece data, |
520 QuicStreamOffset offset, | 521 QuicStreamOffset offset, |
521 bool fin, | 522 bool fin, |
522 QuicAckListenerInterface* listener) { | 523 QuicAckListenerInterface* listener) { |
| 524 if (id != kCryptoStreamId && this->encryption_level() == ENCRYPTION_NONE) { |
| 525 this->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); |
| 526 } |
523 struct iovec iov; | 527 struct iovec iov; |
524 QuicIOVector data_iov(MakeIOVector(data, &iov)); | 528 QuicIOVector data_iov(MakeIOVector(data, &iov)); |
525 return QuicConnection::SendStreamData(id, data_iov, offset, fin, listener); | 529 return QuicConnection::SendStreamData(id, data_iov, offset, fin, listener); |
526 } | 530 } |
527 | 531 |
528 QuicConsumedData SendStreamData3() { | 532 QuicConsumedData SendStreamData3() { |
529 return SendStreamDataWithString(kClientDataStreamId1, "food", 0, !kFin, | 533 return SendStreamDataWithString(kClientDataStreamId1, "food", 0, !kFin, |
530 nullptr); | 534 nullptr); |
531 } | 535 } |
532 | 536 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); | 743 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); |
740 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); | 744 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); |
741 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) | 745 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) |
742 .WillRepeatedly(Return(false)); | 746 .WillRepeatedly(Return(false)); |
743 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); | 747 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); |
744 | 748 |
745 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) | 749 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
746 .WillRepeatedly(Return(QuicTime::Zero())); | 750 .WillRepeatedly(Return(QuicTime::Zero())); |
747 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)) | 751 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)) |
748 .Times(AnyNumber()); | 752 .Times(AnyNumber()); |
749 // TODO(ianswett): Fix QuicConnectionTests so they don't attempt to write | |
750 // non-crypto stream data at ENCRYPTION_NONE. | |
751 FLAGS_quic_never_write_unencrypted_data = false; | |
752 } | 753 } |
753 | 754 |
754 QuicVersion version() { return GetParam().version; } | 755 QuicVersion version() { return GetParam().version; } |
755 | 756 |
756 QuicAckFrame* outgoing_ack() { | 757 QuicAckFrame* outgoing_ack() { |
757 QuicFrame ack_frame = QuicConnectionPeer::GetUpdatedAckFrame(&connection_); | 758 QuicFrame ack_frame = QuicConnectionPeer::GetUpdatedAckFrame(&connection_); |
758 ack_ = *ack_frame.ack_frame; | 759 ack_ = *ack_frame.ack_frame; |
759 return &ack_; | 760 return &ack_; |
760 } | 761 } |
761 | 762 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 connection_.ProcessUdpPacket( | 802 connection_.ProcessUdpPacket( |
802 self_address, peer_address, | 803 self_address, peer_address, |
803 QuicReceivedPacket(serialized_packet.encrypted_buffer, | 804 QuicReceivedPacket(serialized_packet.encrypted_buffer, |
804 serialized_packet.encrypted_length, clock_.Now())); | 805 serialized_packet.encrypted_length, clock_.Now())); |
805 if (connection_.GetSendAlarm()->IsSet()) { | 806 if (connection_.GetSendAlarm()->IsSet()) { |
806 connection_.GetSendAlarm()->Fire(); | 807 connection_.GetSendAlarm()->Fire(); |
807 } | 808 } |
808 return serialized_packet.entropy_hash; | 809 return serialized_packet.entropy_hash; |
809 } | 810 } |
810 | 811 |
| 812 // Bypassing the packet creator is unrealistic, but allows us to process |
| 813 // packets the QuicPacketCreator won't allow us to create. |
| 814 void ForceProcessFramePacket(QuicFrame frame) { |
| 815 QuicFrames frames; |
| 816 frames.push_back(QuicFrame(frame)); |
| 817 QuicPacketCreatorPeer::SetSendVersionInPacket( |
| 818 &peer_creator_, connection_.perspective() == Perspective::IS_SERVER); |
| 819 QuicPacketHeader header; |
| 820 QuicPacketCreatorPeer::FillPacketHeader(&peer_creator_, &header); |
| 821 char encrypted_buffer[kMaxPacketSize]; |
| 822 size_t length = peer_framer_.BuildDataPacket( |
| 823 header, frames, encrypted_buffer, kMaxPacketSize); |
| 824 DCHECK_GT(length, 0u); |
| 825 |
| 826 const size_t encrypted_length = peer_framer_.EncryptInPlace( |
| 827 ENCRYPTION_NONE, kDefaultPathId, header.packet_number, |
| 828 GetStartOfEncryptedData(peer_framer_.version(), header), length, |
| 829 kMaxPacketSize, encrypted_buffer); |
| 830 DCHECK_GT(encrypted_length, 0u); |
| 831 |
| 832 connection_.ProcessUdpPacket( |
| 833 kSelfAddress, kPeerAddress, |
| 834 QuicReceivedPacket(encrypted_buffer, encrypted_length, clock_.Now())); |
| 835 } |
| 836 |
811 QuicPacketEntropyHash ProcessFramePacketAtLevel(QuicPathId path_id, | 837 QuicPacketEntropyHash ProcessFramePacketAtLevel(QuicPathId path_id, |
812 QuicPacketNumber number, | 838 QuicPacketNumber number, |
813 QuicFrame frame, | 839 QuicFrame frame, |
814 EncryptionLevel level) { | 840 EncryptionLevel level) { |
815 QuicPacketHeader header; | 841 QuicPacketHeader header; |
816 header.public_header.connection_id = connection_id_; | 842 header.public_header.connection_id = connection_id_; |
817 header.public_header.packet_number_length = packet_number_length_; | 843 header.public_header.packet_number_length = packet_number_length_; |
818 header.public_header.connection_id_length = connection_id_length_; | 844 header.public_header.connection_id_length = connection_id_length_; |
819 header.public_header.multipath_flag = path_id != kDefaultPathId; | 845 header.public_header.multipath_flag = path_id != kDefaultPathId; |
820 header.path_id = path_id; | 846 header.path_id = path_id; |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 // Should ack immediately since we have missing packets. | 1495 // Should ack immediately since we have missing packets. |
1470 EXPECT_EQ(2u, writer_->packets_write_attempts()); | 1496 EXPECT_EQ(2u, writer_->packets_write_attempts()); |
1471 | 1497 |
1472 ProcessAckPacket(1, &ack1); | 1498 ProcessAckPacket(1, &ack1); |
1473 // Should not ack an ack filling a missing packet. | 1499 // Should not ack an ack filling a missing packet. |
1474 EXPECT_EQ(2u, writer_->packets_write_attempts()); | 1500 EXPECT_EQ(2u, writer_->packets_write_attempts()); |
1475 } | 1501 } |
1476 | 1502 |
1477 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { | 1503 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { |
1478 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1504 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1479 | |
1480 QuicPacketNumber original; | 1505 QuicPacketNumber original; |
1481 QuicByteCount packet_size; | 1506 QuicByteCount packet_size; |
1482 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1507 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
1483 .WillOnce( | 1508 .WillOnce( |
1484 DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), Return(true))); | 1509 DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), Return(true))); |
1485 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 1510 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
1486 QuicAckFrame frame = InitAckFrame(original); | 1511 QuicAckFrame frame = InitAckFrame(original); |
1487 NackPacket(original, &frame); | 1512 NackPacket(original, &frame); |
1488 // First nack triggers early retransmit. | 1513 // First nack triggers early retransmit. |
1489 SendAlgorithmInterface::CongestionVector lost_packets; | 1514 SendAlgorithmInterface::CongestionVector lost_packets; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 connection_.OnCanWrite(); | 1907 connection_.OnCanWrite(); |
1883 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1908 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1884 | 1909 |
1885 // Parse the last packet and ensure it's one stream frame from one stream. | 1910 // Parse the last packet and ensure it's one stream frame from one stream. |
1886 EXPECT_EQ(1u, writer_->frame_count()); | 1911 EXPECT_EQ(1u, writer_->frame_count()); |
1887 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1912 EXPECT_EQ(1u, writer_->stream_frames().size()); |
1888 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); | 1913 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); |
1889 } | 1914 } |
1890 | 1915 |
1891 TEST_P(QuicConnectionTest, SendingZeroBytes) { | 1916 TEST_P(QuicConnectionTest, SendingZeroBytes) { |
| 1917 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); |
1892 // Send a zero byte write with a fin using writev. | 1918 // Send a zero byte write with a fin using writev. |
1893 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1919 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
1894 QuicIOVector empty_iov(nullptr, 0, 0); | 1920 QuicIOVector empty_iov(nullptr, 0, 0); |
1895 connection_.SendStreamData(kHeadersStreamId, empty_iov, 0, kFin, nullptr); | 1921 connection_.SendStreamData(kHeadersStreamId, empty_iov, 0, kFin, nullptr); |
1896 | 1922 |
1897 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1923 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1898 EXPECT_FALSE(connection_.HasQueuedData()); | 1924 EXPECT_FALSE(connection_.HasQueuedData()); |
1899 | 1925 |
1900 // Parse the last packet and ensure it's one stream frame from one stream. | 1926 // Parse the last packet and ensure it's one stream frame from one stream. |
1901 EXPECT_EQ(1u, writer_->frame_count()); | 1927 EXPECT_EQ(1u, writer_->frame_count()); |
1902 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1928 EXPECT_EQ(1u, writer_->stream_frames().size()); |
1903 EXPECT_EQ(kHeadersStreamId, writer_->stream_frames()[0]->stream_id); | 1929 EXPECT_EQ(kHeadersStreamId, writer_->stream_frames()[0]->stream_id); |
1904 EXPECT_TRUE(writer_->stream_frames()[0]->fin); | 1930 EXPECT_TRUE(writer_->stream_frames()[0]->fin); |
1905 } | 1931 } |
1906 | 1932 |
1907 TEST_P(QuicConnectionTest, LargeSendWithPendingAck) { | 1933 TEST_P(QuicConnectionTest, LargeSendWithPendingAck) { |
| 1934 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); |
1908 // Set the ack alarm by processing a ping frame. | 1935 // Set the ack alarm by processing a ping frame. |
1909 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1910 | 1937 |
1911 // Processs a PING frame. | 1938 // Processs a PING frame. |
1912 ProcessFramePacket(QuicFrame(QuicPingFrame())); | 1939 ProcessFramePacket(QuicFrame(QuicPingFrame())); |
1913 // Ensure that this has caused the ACK alarm to be set. | 1940 // Ensure that this has caused the ACK alarm to be set. |
1914 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); | 1941 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); |
1915 EXPECT_TRUE(ack_alarm->IsSet()); | 1942 EXPECT_TRUE(ack_alarm->IsSet()); |
1916 | 1943 |
1917 // Send data and ensure the ack is bundled. | 1944 // Send data and ensure the ack is bundled. |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 connection_.GetRetransmissionAlarm()->deadline()); | 2511 connection_.GetRetransmissionAlarm()->deadline()); |
2485 // Simulate the retransmission alarm firing. | 2512 // Simulate the retransmission alarm firing. |
2486 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2513 clock_.AdvanceTime(DefaultRetransmissionTime()); |
2487 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); | 2514 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); |
2488 connection_.GetRetransmissionAlarm()->Fire(); | 2515 connection_.GetRetransmissionAlarm()->Fire(); |
2489 EXPECT_EQ(2u, writer_->header().packet_number); | 2516 EXPECT_EQ(2u, writer_->header().packet_number); |
2490 // We do not raise the high water mark yet. | 2517 // We do not raise the high water mark yet. |
2491 EXPECT_EQ(1u, stop_waiting()->least_unacked); | 2518 EXPECT_EQ(1u, stop_waiting()->least_unacked); |
2492 } | 2519 } |
2493 | 2520 |
2494 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) { | 2521 TEST_P(QuicConnectionTest, RetransmitWithSameEncryptionLevel) { |
2495 connection_.SetMaxTailLossProbes(kDefaultPathId, 0); | |
2496 | |
2497 QuicTime default_retransmission_time = | |
2498 clock_.ApproximateNow() + DefaultRetransmissionTime(); | |
2499 use_tagging_decrypter(); | 2522 use_tagging_decrypter(); |
2500 | 2523 |
2501 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at | 2524 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at |
2502 // the end of the packet. We can test this to check which encrypter was used. | 2525 // the end of the packet. We can test this to check which encrypter was used. |
2503 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); | 2526 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); |
2504 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); | 2527 SendStreamDataToPeer(kCryptoStreamId, "foo", 0, !kFin, nullptr); |
2505 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); | 2528 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); |
2506 | 2529 |
2507 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); | 2530 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); |
2508 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | 2531 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); |
2509 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); | 2532 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); |
2510 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); | 2533 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); |
2511 | 2534 |
2512 EXPECT_EQ(default_retransmission_time, | |
2513 connection_.GetRetransmissionAlarm()->deadline()); | |
2514 { | 2535 { |
2515 InSequence s; | 2536 InSequence s; |
2516 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 3, _, _)); | 2537 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 3, _, _)); |
2517 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)); | 2538 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)); |
2518 } | 2539 } |
2519 | 2540 |
2520 // Simulate the retransmission alarm firing. | 2541 // Manually mark both packets for retransmission. |
2521 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2542 connection_.RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION); |
2522 connection_.GetRetransmissionAlarm()->Fire(); | |
2523 | 2543 |
2524 // Packet should have been sent with ENCRYPTION_NONE. | 2544 // Packet should have been sent with ENCRYPTION_NONE. |
2525 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_previous_packet()); | 2545 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_previous_packet()); |
2526 | 2546 |
2527 // Packet should have been sent with ENCRYPTION_INITIAL. | 2547 // Packet should have been sent with ENCRYPTION_INITIAL. |
2528 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); | 2548 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); |
2529 } | 2549 } |
2530 | 2550 |
2531 TEST_P(QuicConnectionTest, SendHandshakeMessages) { | 2551 TEST_P(QuicConnectionTest, SendHandshakeMessages) { |
2532 use_tagging_decrypter(); | 2552 use_tagging_decrypter(); |
(...skipping 21 matching lines...) Expand all Loading... |
2554 | 2574 |
2555 // Verify that the handshake packet went out at the null encryption. | 2575 // Verify that the handshake packet went out at the null encryption. |
2556 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); | 2576 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); |
2557 } | 2577 } |
2558 | 2578 |
2559 TEST_P(QuicConnectionTest, | 2579 TEST_P(QuicConnectionTest, |
2560 DropRetransmitsForNullEncryptedPacketAfterForwardSecure) { | 2580 DropRetransmitsForNullEncryptedPacketAfterForwardSecure) { |
2561 use_tagging_decrypter(); | 2581 use_tagging_decrypter(); |
2562 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); | 2582 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); |
2563 QuicPacketNumber packet_number; | 2583 QuicPacketNumber packet_number; |
2564 SendStreamDataToPeer(3, "foo", 0, !kFin, &packet_number); | 2584 SendStreamDataToPeer(kCryptoStreamId, "foo", 0, !kFin, &packet_number); |
2565 | 2585 |
2566 // Simulate the retransmission alarm firing and the socket blocking. | 2586 // Simulate the retransmission alarm firing and the socket blocking. |
2567 BlockOnNextWrite(); | 2587 BlockOnNextWrite(); |
2568 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2588 clock_.AdvanceTime(DefaultRetransmissionTime()); |
2569 connection_.GetRetransmissionAlarm()->Fire(); | 2589 connection_.GetRetransmissionAlarm()->Fire(); |
2570 | 2590 |
2571 // Go forward secure. | 2591 // Go forward secure. |
2572 connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, | 2592 connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, |
2573 new TaggingEncrypter(0x02)); | 2593 new TaggingEncrypter(0x02)); |
2574 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); | 2594 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); |
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5012 } | 5032 } |
5013 | 5033 |
5014 TEST_P(QuicConnectionTest, SendPingImmediately) { | 5034 TEST_P(QuicConnectionTest, SendPingImmediately) { |
5015 CongestionBlockWrites(); | 5035 CongestionBlockWrites(); |
5016 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 5036 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
5017 connection_.SendPing(); | 5037 connection_.SendPing(); |
5018 EXPECT_FALSE(connection_.HasQueuedData()); | 5038 EXPECT_FALSE(connection_.HasQueuedData()); |
5019 } | 5039 } |
5020 | 5040 |
5021 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) { | 5041 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) { |
5022 FLAGS_quic_never_write_unencrypted_data = true; | |
5023 EXPECT_CALL(visitor_, | 5042 EXPECT_CALL(visitor_, |
5024 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, | 5043 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, |
5025 _, ConnectionCloseSource::FROM_SELF)); | 5044 _, ConnectionCloseSource::FROM_SELF)); |
5026 EXPECT_QUIC_BUG(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr), | 5045 struct iovec iov; |
| 5046 QuicIOVector data_iov(MakeIOVector("", &iov)); |
| 5047 EXPECT_QUIC_BUG(connection_.SendStreamData(3, data_iov, 0, kFin, nullptr), |
5027 "Cannot send stream data without encryption."); | 5048 "Cannot send stream data without encryption."); |
5028 EXPECT_FALSE(connection_.connected()); | 5049 EXPECT_FALSE(connection_.connected()); |
5029 } | 5050 } |
5030 | 5051 |
5031 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) { | 5052 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) { |
5032 // Test multipath negotiation during crypto handshake. Multipath is enabled | 5053 // Test multipath negotiation during crypto handshake. Multipath is enabled |
5033 // when both endpoints enable multipath. | 5054 // when both endpoints enable multipath. |
5034 FLAGS_quic_enable_multipath = true; | 5055 FLAGS_quic_enable_multipath = true; |
5035 EXPECT_TRUE(connection_.connected()); | 5056 EXPECT_TRUE(connection_.connected()); |
5036 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); | 5057 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5124 CryptoHandshakeMessage message; | 5145 CryptoHandshakeMessage message; |
5125 CryptoFramer framer; | 5146 CryptoFramer framer; |
5126 message.set_tag(kCHLO); | 5147 message.set_tag(kCHLO); |
5127 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); | 5148 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); |
5128 frame1_.stream_id = 10; | 5149 frame1_.stream_id = 10; |
5129 frame1_.data_buffer = data->data(); | 5150 frame1_.data_buffer = data->data(); |
5130 frame1_.data_length = data->length(); | 5151 frame1_.data_length = data->length(); |
5131 | 5152 |
5132 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, | 5153 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
5133 ConnectionCloseSource::FROM_SELF)); | 5154 ConnectionCloseSource::FROM_SELF)); |
5134 ProcessFramePacket(QuicFrame(&frame1_)); | 5155 ForceProcessFramePacket(QuicFrame(&frame1_)); |
5135 } | 5156 } |
5136 | 5157 |
5137 TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) { | 5158 TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) { |
5138 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 5159 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
5139 | 5160 |
5140 CryptoHandshakeMessage message; | 5161 CryptoHandshakeMessage message; |
5141 CryptoFramer framer; | 5162 CryptoFramer framer; |
5142 message.set_tag(kREJ); | 5163 message.set_tag(kREJ); |
5143 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); | 5164 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); |
5144 frame1_.stream_id = 10; | 5165 frame1_.stream_id = 10; |
5145 frame1_.data_buffer = data->data(); | 5166 frame1_.data_buffer = data->data(); |
5146 frame1_.data_length = data->length(); | 5167 frame1_.data_length = data->length(); |
5147 | 5168 |
5148 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, | 5169 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
5149 ConnectionCloseSource::FROM_SELF)); | 5170 ConnectionCloseSource::FROM_SELF)); |
5150 ProcessFramePacket(QuicFrame(&frame1_)); | 5171 ForceProcessFramePacket(QuicFrame(&frame1_)); |
5151 } | 5172 } |
5152 | 5173 |
5153 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) { | 5174 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) { |
5154 FLAGS_quic_close_connection_on_packet_too_large = true; | 5175 FLAGS_quic_close_connection_on_packet_too_large = true; |
5155 SimulateNextPacketTooLarge(); | 5176 SimulateNextPacketTooLarge(); |
5156 // Although the data packet cannot be written, the send packet manager is | 5177 // Although the data packet cannot be written, the send packet manager is |
5157 // informed. Also a connection close packet is sent. | 5178 // informed. Also a connection close packet is sent. |
5158 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); | 5179 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
5159 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, | 5180 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, |
5160 ConnectionCloseSource::FROM_SELF)) | 5181 ConnectionCloseSource::FROM_SELF)) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5252 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5273 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
5253 EXPECT_EQ(1u, writer_->frame_count()); | 5274 EXPECT_EQ(1u, writer_->frame_count()); |
5254 EXPECT_FALSE(writer_->connection_close_frames().empty()); | 5275 EXPECT_FALSE(writer_->connection_close_frames().empty()); |
5255 // Ack frame is not bundled in connection close packet. | 5276 // Ack frame is not bundled in connection close packet. |
5256 EXPECT_TRUE(writer_->ack_frames().empty()); | 5277 EXPECT_TRUE(writer_->ack_frames().empty()); |
5257 } | 5278 } |
5258 | 5279 |
5259 } // namespace | 5280 } // namespace |
5260 } // namespace test | 5281 } // namespace test |
5261 } // namespace net | 5282 } // namespace net |
OLD | NEW |