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/bind.h" | 7 #include "base/bind.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/quic/congestion_control/receive_algorithm_interface.h" | 9 #include "net/quic/congestion_control/receive_algorithm_interface.h" |
10 #include "net/quic/congestion_control/send_algorithm_interface.h" | 10 #include "net/quic/congestion_control/send_algorithm_interface.h" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 9 | 784 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 9 |
785 EXPECT_EQ(9u, last_packet); | 785 EXPECT_EQ(9u, last_packet); |
786 SendAckPacketToPeer(); // Packet10 | 786 SendAckPacketToPeer(); // Packet10 |
787 EXPECT_EQ(9u, last_ack()->sent_info.least_unacked); | 787 EXPECT_EQ(9u, last_ack()->sent_info.least_unacked); |
788 } | 788 } |
789 | 789 |
790 TEST_F(QuicConnectionTest, FECSending) { | 790 TEST_F(QuicConnectionTest, FECSending) { |
791 // Limit to one byte per packet. | 791 // Limit to one byte per packet. |
792 // All packets carry version info till version is negotiated. | 792 // All packets carry version info till version is negotiated. |
793 connection_.options()->max_packet_length = | 793 connection_.options()->max_packet_length = |
794 GetPacketLengthForOneStream(kIncludeVersion, 1); | 794 GetPacketLengthForOneStream(kIncludeVersion, 4); |
795 // And send FEC every two packets. | 795 // And send FEC every two packets. |
796 connection_.options()->max_packets_per_fec_group = 2; | 796 connection_.options()->max_packets_per_fec_group = 2; |
797 | 797 |
798 // Send 4 data packets and 2 FEC packets. | 798 // Send 4 data packets and 2 FEC packets. |
799 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(6); | 799 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(6); |
800 connection_.SendStreamData(1, "food", 0, !kFin); | 800 connection_.SendStreamData(1, "foodfoodfoodfood", 0, !kFin); |
801 // Expect the FEC group to be closed after SendStreamData. | 801 // Expect the FEC group to be closed after SendStreamData. |
802 EXPECT_FALSE(creator_.ShouldSendFec(true)); | 802 EXPECT_FALSE(creator_.ShouldSendFec(true)); |
803 } | 803 } |
804 | 804 |
805 TEST_F(QuicConnectionTest, FECQueueing) { | 805 TEST_F(QuicConnectionTest, FECQueueing) { |
806 // Limit to one byte per packet. | 806 // Limit to one byte per packet. |
807 // All packets carry version info till version is negotiated. | 807 // All packets carry version info till version is negotiated. |
808 connection_.options()->max_packet_length = | 808 connection_.options()->max_packet_length = |
809 GetPacketLengthForOneStream(kIncludeVersion, 1); | 809 GetPacketLengthForOneStream(kIncludeVersion, 4); |
810 // And send FEC every two packets. | 810 // And send FEC every two packets. |
811 connection_.options()->max_packets_per_fec_group = 2; | 811 connection_.options()->max_packets_per_fec_group = 2; |
812 | 812 |
813 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 813 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
814 helper_->set_blocked(true); | 814 helper_->set_blocked(true); |
815 connection_.SendStreamData(1, "food", 0, !kFin); | 815 connection_.SendStreamData(1, "food", 0, !kFin); |
816 EXPECT_FALSE(creator_.ShouldSendFec(true)); | 816 EXPECT_FALSE(creator_.ShouldSendFec(true)); |
817 // Expect the first data packet and the fec packet to be queued. | 817 // Expect the first data packet and the fec packet to be queued. |
818 EXPECT_EQ(2u, connection_.NumQueuedPackets()); | 818 EXPECT_EQ(2u, connection_.NumQueuedPackets()); |
819 } | 819 } |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 // OnCanWrite should not send the packet (because of the delay) | 1524 // OnCanWrite should not send the packet (because of the delay) |
1525 // but should still return true. | 1525 // but should still return true. |
1526 EXPECT_TRUE(connection_.OnCanWrite()); | 1526 EXPECT_TRUE(connection_.OnCanWrite()); |
1527 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1527 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
1528 } | 1528 } |
1529 | 1529 |
1530 TEST_F(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { | 1530 TEST_F(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { |
1531 // Limit to one byte per packet. | 1531 // Limit to one byte per packet. |
1532 // All packets carry version info till version is negotiated. | 1532 // All packets carry version info till version is negotiated. |
1533 connection_.options()->max_packet_length = | 1533 connection_.options()->max_packet_length = |
1534 GetPacketLengthForOneStream(kIncludeVersion, 1); | 1534 GetPacketLengthForOneStream(kIncludeVersion, 4); |
1535 | 1535 |
1536 // Queue the first packet. | 1536 // Queue the first packet. |
1537 EXPECT_CALL(*send_algorithm_, | 1537 EXPECT_CALL(*send_algorithm_, |
1538 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( | 1538 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( |
1539 testing::Return(QuicTime::Delta::FromMicroseconds(10))); | 1539 testing::Return(QuicTime::Delta::FromMicroseconds(10))); |
1540 EXPECT_EQ(0u, connection_.SendStreamData( | 1540 EXPECT_EQ(0u, connection_.SendStreamData( |
1541 1, "EnoughDataToQueue", 0, !kFin).bytes_consumed); | 1541 1, "EnoughDataToQueue", 0, !kFin).bytes_consumed); |
1542 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1542 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1543 } | 1543 } |
1544 | 1544 |
1545 TEST_F(QuicConnectionTest, LoopThroughSendingPackets) { | 1545 TEST_F(QuicConnectionTest, LoopThroughSendingPackets) { |
1546 // Limit to one byte per packet. | 1546 // Limit to 4 bytes per packet. |
1547 // All packets carry version info till version is negotiated. | 1547 // All packets carry version info till version is negotiated. |
1548 connection_.options()->max_packet_length = | 1548 connection_.options()->max_packet_length = |
1549 GetPacketLengthForOneStream(kIncludeVersion, 1); | 1549 GetPacketLengthForOneStream(kIncludeVersion, 4); |
1550 | 1550 |
1551 // Queue the first packet. | 1551 // Queue the first packet. |
1552 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(17); | 1552 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(7); |
1553 EXPECT_EQ(17u, connection_.SendStreamData( | 1553 EXPECT_EQ(27u, connection_.SendStreamData( |
1554 1, "EnoughDataToQueue", 0, !kFin).bytes_consumed); | 1554 1, "EnoughDataToQueueStreamData", 0, !kFin).bytes_consumed); |
1555 } | 1555 } |
1556 | 1556 |
1557 TEST_F(QuicConnectionTest, NoAckForClose) { | 1557 TEST_F(QuicConnectionTest, NoAckForClose) { |
1558 ProcessPacket(1); | 1558 ProcessPacket(1); |
1559 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(0); | 1559 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(0); |
1560 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true)); | 1560 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true)); |
1561 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(0); | 1561 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(0); |
1562 ProcessClosePacket(2, 0); | 1562 ProcessClosePacket(2, 0); |
1563 } | 1563 } |
1564 | 1564 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 EXPECT_EQ(received_bytes, stats.bytes_received); | 1804 EXPECT_EQ(received_bytes, stats.bytes_received); |
1805 EXPECT_EQ(4u, stats.packets_received); | 1805 EXPECT_EQ(4u, stats.packets_received); |
1806 | 1806 |
1807 EXPECT_EQ(1u, stats.packets_revived); | 1807 EXPECT_EQ(1u, stats.packets_revived); |
1808 EXPECT_EQ(1u, stats.packets_dropped); | 1808 EXPECT_EQ(1u, stats.packets_dropped); |
1809 } | 1809 } |
1810 | 1810 |
1811 } // namespace | 1811 } // namespace |
1812 } // namespace test | 1812 } // namespace test |
1813 } // namespace net | 1813 } // namespace net |
OLD | NEW |