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_framer.h" | 5 #include "net/quic/quic_framer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1719 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1720 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1720 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1721 | 1721 |
1722 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1722 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1723 ASSERT_TRUE(visitor_.header_.get()); | 1723 ASSERT_TRUE(visitor_.header_.get()); |
1724 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1724 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1725 | 1725 |
1726 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 1726 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
1727 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 1727 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
1728 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; | 1728 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; |
1729 EXPECT_EQ(0xBA, frame.received_info.entropy_hash); | 1729 EXPECT_EQ(0xBA, frame.entropy_hash); |
1730 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.received_info.largest_observed); | 1730 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.largest_observed); |
1731 ASSERT_EQ(1u, frame.received_info.missing_packets.size()); | 1731 ASSERT_EQ(1u, frame.missing_packets.size()); |
1732 SequenceNumberSet::const_iterator missing_iter = | 1732 SequenceNumberSet::const_iterator missing_iter = |
1733 frame.received_info.missing_packets.begin(); | 1733 frame.missing_packets.begin(); |
1734 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); | 1734 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); |
1735 | 1735 |
1736 const size_t kReceivedEntropyOffset = kQuicFrameTypeSize; | 1736 const size_t kReceivedEntropyOffset = kQuicFrameTypeSize; |
1737 const size_t kLargestObservedOffset = kReceivedEntropyOffset + | 1737 const size_t kLargestObservedOffset = kReceivedEntropyOffset + |
1738 kQuicEntropyHashSize; | 1738 kQuicEntropyHashSize; |
1739 const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + | 1739 const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + |
1740 PACKET_6BYTE_SEQUENCE_NUMBER; | 1740 PACKET_6BYTE_SEQUENCE_NUMBER; |
1741 const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + | 1741 const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + |
1742 kQuicDeltaTimeLargestObservedSize; | 1742 kQuicDeltaTimeLargestObservedSize; |
1743 const size_t kMissingPacketsOffset = kNumMissingPacketOffset + | 1743 const size_t kMissingPacketsOffset = kNumMissingPacketOffset + |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1813 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1814 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1814 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1815 | 1815 |
1816 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1816 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1817 ASSERT_TRUE(visitor_.header_.get()); | 1817 ASSERT_TRUE(visitor_.header_.get()); |
1818 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1818 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1819 | 1819 |
1820 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 1820 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
1821 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 1821 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
1822 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; | 1822 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; |
1823 EXPECT_EQ(0xBA, frame.received_info.entropy_hash); | 1823 EXPECT_EQ(0xBA, frame.entropy_hash); |
1824 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.received_info.largest_observed); | 1824 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.largest_observed); |
1825 ASSERT_EQ(1u, frame.received_info.missing_packets.size()); | 1825 ASSERT_EQ(1u, frame.missing_packets.size()); |
1826 SequenceNumberSet::const_iterator missing_iter = | 1826 SequenceNumberSet::const_iterator missing_iter = |
1827 frame.received_info.missing_packets.begin(); | 1827 frame.missing_packets.begin(); |
1828 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); | 1828 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); |
1829 | 1829 |
1830 const size_t kReceivedEntropyOffset = kQuicFrameTypeSize; | 1830 const size_t kReceivedEntropyOffset = kQuicFrameTypeSize; |
1831 const size_t kLargestObservedOffset = kReceivedEntropyOffset + | 1831 const size_t kLargestObservedOffset = kReceivedEntropyOffset + |
1832 kQuicEntropyHashSize; | 1832 kQuicEntropyHashSize; |
1833 const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + | 1833 const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + |
1834 PACKET_6BYTE_SEQUENCE_NUMBER; | 1834 PACKET_6BYTE_SEQUENCE_NUMBER; |
1835 const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + | 1835 const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + |
1836 kQuicDeltaTimeLargestObservedSize; | 1836 kQuicDeltaTimeLargestObservedSize; |
1837 const size_t kMissingPacketsOffset = kNumMissingPacketOffset + | 1837 const size_t kMissingPacketsOffset = kNumMissingPacketOffset + |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1902 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1903 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1903 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1904 | 1904 |
1905 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1905 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1906 ASSERT_TRUE(visitor_.header_.get()); | 1906 ASSERT_TRUE(visitor_.header_.get()); |
1907 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1907 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1908 | 1908 |
1909 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 1909 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
1910 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 1910 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
1911 QuicAckFrame* frame = visitor_.ack_frames_[0]; | 1911 QuicAckFrame* frame = visitor_.ack_frames_[0]; |
1912 EXPECT_EQ(0xBA, frame->received_info.entropy_hash); | 1912 EXPECT_EQ(0xBA, frame->entropy_hash); |
1913 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), | 1913 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame->largest_observed); |
1914 frame->received_info.largest_observed); | 1914 ASSERT_EQ(0u, frame->missing_packets.size()); |
1915 ASSERT_EQ(0u, frame->received_info.missing_packets.size()); | |
1916 | 1915 |
1917 // Verify that the packet re-serializes identically. | 1916 // Verify that the packet re-serializes identically. |
1918 QuicFrames frames; | 1917 QuicFrames frames; |
1919 frames.push_back(QuicFrame(frame)); | 1918 frames.push_back(QuicFrame(frame)); |
1920 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); | 1919 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); |
1921 ASSERT_TRUE(data != NULL); | 1920 ASSERT_TRUE(data != NULL); |
1922 | 1921 |
1923 test::CompareCharArraysWithHexError("constructed packet", | 1922 test::CompareCharArraysWithHexError("constructed packet", |
1924 data->data(), data->length(), | 1923 data->data(), data->length(), |
1925 AsChars(packet), arraysize(packet)); | 1924 AsChars(packet), arraysize(packet)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1965 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1967 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1966 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1968 | 1967 |
1969 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1968 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1970 ASSERT_TRUE(visitor_.header_.get()); | 1969 ASSERT_TRUE(visitor_.header_.get()); |
1971 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1970 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1972 | 1971 |
1973 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 1972 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
1974 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 1973 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
1975 QuicAckFrame* frame = visitor_.ack_frames_[0]; | 1974 QuicAckFrame* frame = visitor_.ack_frames_[0]; |
1976 EXPECT_EQ(0xBA, frame->received_info.entropy_hash); | 1975 EXPECT_EQ(0xBA, frame->entropy_hash); |
1977 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), | 1976 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame->largest_observed); |
1978 frame->received_info.largest_observed); | 1977 EXPECT_EQ(0u, frame->revived_packets.size()); |
1979 EXPECT_EQ(0u, frame->received_info.revived_packets.size()); | 1978 ASSERT_EQ(500u, frame->missing_packets.size()); |
1980 ASSERT_EQ(500u, frame->received_info.missing_packets.size()); | |
1981 SequenceNumberSet::const_iterator first_missing_iter = | 1979 SequenceNumberSet::const_iterator first_missing_iter = |
1982 frame->received_info.missing_packets.begin(); | 1980 frame->missing_packets.begin(); |
1983 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter); | 1981 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter); |
1984 SequenceNumberSet::const_reverse_iterator last_missing_iter = | 1982 SequenceNumberSet::const_reverse_iterator last_missing_iter = |
1985 frame->received_info.missing_packets.rbegin(); | 1983 frame->missing_packets.rbegin(); |
1986 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter); | 1984 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter); |
1987 | 1985 |
1988 // Verify that the packet re-serializes identically. | 1986 // Verify that the packet re-serializes identically. |
1989 QuicFrames frames; | 1987 QuicFrames frames; |
1990 frames.push_back(QuicFrame(frame)); | 1988 frames.push_back(QuicFrame(frame)); |
1991 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); | 1989 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); |
1992 ASSERT_TRUE(data != NULL); | 1990 ASSERT_TRUE(data != NULL); |
1993 | 1991 |
1994 test::CompareCharArraysWithHexError("constructed packet", | 1992 test::CompareCharArraysWithHexError("constructed packet", |
1995 data->data(), data->length(), | 1993 data->data(), data->length(), |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2258 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 2256 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
2259 | 2257 |
2260 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.rst_stream_frame_.stream_id); | 2258 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.rst_stream_frame_.stream_id); |
2261 EXPECT_EQ(0x01, visitor_.rst_stream_frame_.error_code); | 2259 EXPECT_EQ(0x01, visitor_.rst_stream_frame_.error_code); |
2262 EXPECT_EQ("because I can", visitor_.rst_stream_frame_.error_details); | 2260 EXPECT_EQ("because I can", visitor_.rst_stream_frame_.error_details); |
2263 EXPECT_EQ(GG_UINT64_C(0x0807060504030201), | 2261 EXPECT_EQ(GG_UINT64_C(0x0807060504030201), |
2264 visitor_.rst_stream_frame_.byte_offset); | 2262 visitor_.rst_stream_frame_.byte_offset); |
2265 | 2263 |
2266 // Now test framing boundaries | 2264 // Now test framing boundaries |
2267 for (size_t i = kQuicFrameTypeSize; | 2265 for (size_t i = kQuicFrameTypeSize; |
2268 i < QuicFramer::GetMinRstStreamFrameSize(version_); ++i) { | 2266 i < QuicFramer::GetMinRstStreamFrameSize(); ++i) { |
2269 string expected_error; | 2267 string expected_error; |
2270 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { | 2268 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { |
2271 expected_error = "Unable to read stream_id."; | 2269 expected_error = "Unable to read stream_id."; |
2272 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + | 2270 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + |
2273 + kQuicMaxStreamOffsetSize) { | 2271 + kQuicMaxStreamOffsetSize) { |
2274 expected_error = "Unable to read rst stream sent byte offset."; | 2272 expected_error = "Unable to read rst stream sent byte offset."; |
2275 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + | 2273 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + |
2276 + kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { | 2274 + kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { |
2277 expected_error = "Unable to read rst stream error code."; | 2275 expected_error = "Unable to read rst stream error code."; |
2278 } else { | 2276 } else { |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3149 QuicPacketHeader header; | 3147 QuicPacketHeader header; |
3150 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); | 3148 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); |
3151 header.public_header.reset_flag = false; | 3149 header.public_header.reset_flag = false; |
3152 header.public_header.version_flag = false; | 3150 header.public_header.version_flag = false; |
3153 header.fec_flag = false; | 3151 header.fec_flag = false; |
3154 header.entropy_flag = true; | 3152 header.entropy_flag = true; |
3155 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); | 3153 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); |
3156 header.fec_group = 0; | 3154 header.fec_group = 0; |
3157 | 3155 |
3158 QuicAckFrame ack_frame; | 3156 QuicAckFrame ack_frame; |
3159 ack_frame.received_info.entropy_hash = 0x43; | 3157 ack_frame.entropy_hash = 0x43; |
3160 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF); | 3158 ack_frame.largest_observed = GG_UINT64_C(0x770123456789ABF); |
3161 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero(); | 3159 ack_frame.delta_time_largest_observed = QuicTime::Delta::Zero(); |
3162 ack_frame.received_info.missing_packets.insert( | 3160 ack_frame.missing_packets.insert( |
3163 GG_UINT64_C(0x770123456789ABE)); | 3161 GG_UINT64_C(0x770123456789ABE)); |
3164 | 3162 |
3165 QuicFrames frames; | 3163 QuicFrames frames; |
3166 frames.push_back(QuicFrame(&ack_frame)); | 3164 frames.push_back(QuicFrame(&ack_frame)); |
3167 | 3165 |
3168 unsigned char packet[] = { | 3166 unsigned char packet[] = { |
3169 // public flags (8 byte connection_id) | 3167 // public flags (8 byte connection_id) |
3170 0x3C, | 3168 0x3C, |
3171 // connection_id | 3169 // connection_id |
3172 0x10, 0x32, 0x54, 0x76, | 3170 0x10, 0x32, 0x54, 0x76, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3214 header.public_header.version_flag = false; | 3212 header.public_header.version_flag = false; |
3215 header.fec_flag = false; | 3213 header.fec_flag = false; |
3216 header.entropy_flag = true; | 3214 header.entropy_flag = true; |
3217 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); | 3215 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); |
3218 header.fec_group = 0; | 3216 header.fec_group = 0; |
3219 | 3217 |
3220 QuicAckFrame ack_frame; | 3218 QuicAckFrame ack_frame; |
3221 // This entropy hash is different from what shows up in the packet below, | 3219 // This entropy hash is different from what shows up in the packet below, |
3222 // since entropy is recomputed by the framer on ack truncation (by | 3220 // since entropy is recomputed by the framer on ack truncation (by |
3223 // TestEntropyCalculator for this test.) | 3221 // TestEntropyCalculator for this test.) |
3224 ack_frame.received_info.entropy_hash = 0x43; | 3222 ack_frame.entropy_hash = 0x43; |
3225 ack_frame.received_info.largest_observed = 2 * 300; | 3223 ack_frame.largest_observed = 2 * 300; |
3226 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero(); | 3224 ack_frame.delta_time_largest_observed = QuicTime::Delta::Zero(); |
3227 for (size_t i = 1; i < 2 * 300; i += 2) { | 3225 for (size_t i = 1; i < 2 * 300; i += 2) { |
3228 ack_frame.received_info.missing_packets.insert(i); | 3226 ack_frame.missing_packets.insert(i); |
3229 } | 3227 } |
3230 | 3228 |
3231 QuicFrames frames; | 3229 QuicFrames frames; |
3232 frames.push_back(QuicFrame(&ack_frame)); | 3230 frames.push_back(QuicFrame(&ack_frame)); |
3233 | 3231 |
3234 unsigned char packet[] = { | 3232 unsigned char packet[] = { |
3235 // public flags (8 byte connection_id) | 3233 // public flags (8 byte connection_id) |
3236 0x3C, | 3234 0x3C, |
3237 // connection_id | 3235 // connection_id |
3238 0x10, 0x32, 0x54, 0x76, | 3236 0x10, 0x32, 0x54, 0x76, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3327 header.public_header.version_flag = false; | 3325 header.public_header.version_flag = false; |
3328 header.fec_flag = false; | 3326 header.fec_flag = false; |
3329 header.entropy_flag = true; | 3327 header.entropy_flag = true; |
3330 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); | 3328 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); |
3331 header.fec_group = 0; | 3329 header.fec_group = 0; |
3332 | 3330 |
3333 QuicAckFrame ack_frame; | 3331 QuicAckFrame ack_frame; |
3334 // This entropy hash is different from what shows up in the packet below, | 3332 // This entropy hash is different from what shows up in the packet below, |
3335 // since entropy is recomputed by the framer on ack truncation (by | 3333 // since entropy is recomputed by the framer on ack truncation (by |
3336 // TestEntropyCalculator for this test.) | 3334 // TestEntropyCalculator for this test.) |
3337 ack_frame.received_info.entropy_hash = 0x43; | 3335 ack_frame.entropy_hash = 0x43; |
3338 ack_frame.received_info.largest_observed = 2 * 300; | 3336 ack_frame.largest_observed = 2 * 300; |
3339 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero(); | 3337 ack_frame.delta_time_largest_observed = QuicTime::Delta::Zero(); |
3340 for (size_t i = 1; i < 2 * 300; i += 2) { | 3338 for (size_t i = 1; i < 2 * 300; i += 2) { |
3341 ack_frame.received_info.missing_packets.insert(i); | 3339 ack_frame.missing_packets.insert(i); |
3342 } | 3340 } |
3343 | 3341 |
3344 QuicFrames frames; | 3342 QuicFrames frames; |
3345 frames.push_back(QuicFrame(&ack_frame)); | 3343 frames.push_back(QuicFrame(&ack_frame)); |
3346 | 3344 |
3347 unsigned char packet[] = { | 3345 unsigned char packet[] = { |
3348 // public flags (8 byte connection_id) | 3346 // public flags (8 byte connection_id) |
3349 0x3C, | 3347 0x3C, |
3350 // connection_id | 3348 // connection_id |
3351 0x10, 0x32, 0x54, 0x76, | 3349 0x10, 0x32, 0x54, 0x76, |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4097 scoped_ptr<QuicPacket> raw_ack_packet( | 4095 scoped_ptr<QuicPacket> raw_ack_packet( |
4098 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet); | 4096 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet); |
4099 ASSERT_TRUE(raw_ack_packet != NULL); | 4097 ASSERT_TRUE(raw_ack_packet != NULL); |
4100 scoped_ptr<QuicEncryptedPacket> ack_packet( | 4098 scoped_ptr<QuicEncryptedPacket> ack_packet( |
4101 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, | 4099 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, |
4102 *raw_ack_packet)); | 4100 *raw_ack_packet)); |
4103 // Now make sure we can turn our ack packet back into an ack frame. | 4101 // Now make sure we can turn our ack packet back into an ack frame. |
4104 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); | 4102 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); |
4105 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 4103 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
4106 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; | 4104 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; |
4107 EXPECT_TRUE(processed_ack_frame.received_info.is_truncated); | 4105 EXPECT_TRUE(processed_ack_frame.is_truncated); |
4108 EXPECT_EQ(510u, processed_ack_frame.received_info.largest_observed); | 4106 EXPECT_EQ(510u, processed_ack_frame.largest_observed); |
4109 ASSERT_EQ(255u, processed_ack_frame.received_info.missing_packets.size()); | 4107 ASSERT_EQ(255u, processed_ack_frame.missing_packets.size()); |
4110 SequenceNumberSet::const_iterator missing_iter = | 4108 SequenceNumberSet::const_iterator missing_iter = |
4111 processed_ack_frame.received_info.missing_packets.begin(); | 4109 processed_ack_frame.missing_packets.begin(); |
4112 EXPECT_EQ(1u, *missing_iter); | 4110 EXPECT_EQ(1u, *missing_iter); |
4113 SequenceNumberSet::const_reverse_iterator last_missing_iter = | 4111 SequenceNumberSet::const_reverse_iterator last_missing_iter = |
4114 processed_ack_frame.received_info.missing_packets.rbegin(); | 4112 processed_ack_frame.missing_packets.rbegin(); |
4115 EXPECT_EQ(509u, *last_missing_iter); | 4113 EXPECT_EQ(509u, *last_missing_iter); |
4116 } | 4114 } |
4117 | 4115 |
4118 TEST_P(QuicFramerTest, AckTruncationSmallPacket) { | 4116 TEST_P(QuicFramerTest, AckTruncationSmallPacket) { |
4119 QuicPacketHeader header; | 4117 QuicPacketHeader header; |
4120 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); | 4118 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); |
4121 header.public_header.reset_flag = false; | 4119 header.public_header.reset_flag = false; |
4122 header.public_header.version_flag = false; | 4120 header.public_header.version_flag = false; |
4123 header.fec_flag = false; | 4121 header.fec_flag = false; |
4124 header.entropy_flag = false; | 4122 header.entropy_flag = false; |
(...skipping 12 matching lines...) Expand all Loading... |
4137 scoped_ptr<QuicPacket> raw_ack_packet( | 4135 scoped_ptr<QuicPacket> raw_ack_packet( |
4138 framer_.BuildDataPacket(header, frames, 500).packet); | 4136 framer_.BuildDataPacket(header, frames, 500).packet); |
4139 ASSERT_TRUE(raw_ack_packet != NULL); | 4137 ASSERT_TRUE(raw_ack_packet != NULL); |
4140 scoped_ptr<QuicEncryptedPacket> ack_packet( | 4138 scoped_ptr<QuicEncryptedPacket> ack_packet( |
4141 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, | 4139 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, |
4142 *raw_ack_packet)); | 4140 *raw_ack_packet)); |
4143 // Now make sure we can turn our ack packet back into an ack frame. | 4141 // Now make sure we can turn our ack packet back into an ack frame. |
4144 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); | 4142 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); |
4145 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 4143 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
4146 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; | 4144 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; |
4147 EXPECT_TRUE(processed_ack_frame.received_info.is_truncated); | 4145 EXPECT_TRUE(processed_ack_frame.is_truncated); |
4148 EXPECT_EQ(476u, processed_ack_frame.received_info.largest_observed); | 4146 EXPECT_EQ(476u, processed_ack_frame.largest_observed); |
4149 ASSERT_EQ(238u, processed_ack_frame.received_info.missing_packets.size()); | 4147 ASSERT_EQ(238u, processed_ack_frame.missing_packets.size()); |
4150 SequenceNumberSet::const_iterator missing_iter = | 4148 SequenceNumberSet::const_iterator missing_iter = |
4151 processed_ack_frame.received_info.missing_packets.begin(); | 4149 processed_ack_frame.missing_packets.begin(); |
4152 EXPECT_EQ(1u, *missing_iter); | 4150 EXPECT_EQ(1u, *missing_iter); |
4153 SequenceNumberSet::const_reverse_iterator last_missing_iter = | 4151 SequenceNumberSet::const_reverse_iterator last_missing_iter = |
4154 processed_ack_frame.received_info.missing_packets.rbegin(); | 4152 processed_ack_frame.missing_packets.rbegin(); |
4155 EXPECT_EQ(475u, *last_missing_iter); | 4153 EXPECT_EQ(475u, *last_missing_iter); |
4156 } | 4154 } |
4157 | 4155 |
4158 TEST_P(QuicFramerTest, CleanTruncation) { | 4156 TEST_P(QuicFramerTest, CleanTruncation) { |
4159 QuicPacketHeader header; | 4157 QuicPacketHeader header; |
4160 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); | 4158 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); |
4161 header.public_header.reset_flag = false; | 4159 header.public_header.reset_flag = false; |
4162 header.public_header.version_flag = false; | 4160 header.public_header.version_flag = false; |
4163 header.fec_flag = false; | 4161 header.fec_flag = false; |
4164 header.entropy_flag = true; | 4162 header.entropy_flag = true; |
4165 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); | 4163 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); |
4166 header.fec_group = 0; | 4164 header.fec_group = 0; |
4167 | 4165 |
4168 QuicAckFrame ack_frame; | 4166 QuicAckFrame ack_frame; |
4169 ack_frame.received_info.largest_observed = 201; | 4167 ack_frame.largest_observed = 201; |
4170 for (uint64 i = 1; i < ack_frame.received_info.largest_observed; ++i) { | 4168 for (uint64 i = 1; i < ack_frame.largest_observed; ++i) { |
4171 ack_frame.received_info.missing_packets.insert(i); | 4169 ack_frame.missing_packets.insert(i); |
4172 } | 4170 } |
4173 | 4171 |
4174 // Create a packet with just the ack. | 4172 // Create a packet with just the ack. |
4175 QuicFrame frame; | 4173 QuicFrame frame; |
4176 frame.type = ACK_FRAME; | 4174 frame.type = ACK_FRAME; |
4177 frame.ack_frame = &ack_frame; | 4175 frame.ack_frame = &ack_frame; |
4178 QuicFrames frames; | 4176 QuicFrames frames; |
4179 frames.push_back(frame); | 4177 frames.push_back(frame); |
4180 | 4178 |
4181 scoped_ptr<QuicPacket> raw_ack_packet(BuildDataPacket(header, frames)); | 4179 scoped_ptr<QuicPacket> raw_ack_packet(BuildDataPacket(header, frames)); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4329 EXPECT_CALL(visitor, OnPacketComplete()); | 4327 EXPECT_CALL(visitor, OnPacketComplete()); |
4330 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); | 4328 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); |
4331 | 4329 |
4332 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 4330 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
4333 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 4331 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
4334 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 4332 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
4335 } | 4333 } |
4336 | 4334 |
4337 } // namespace test | 4335 } // namespace test |
4338 } // namespace net | 4336 } // namespace net |
OLD | NEW |