Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: net/quic/quic_framer_test.cc

Issue 14287009: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with Tot Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/port.h" 13 #include "base/port.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.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_framer.h" 17 #include "net/quic/quic_framer.h"
18 #include "net/quic/quic_protocol.h" 18 #include "net/quic/quic_protocol.h"
19 #include "net/quic/quic_utils.h" 19 #include "net/quic/quic_utils.h"
20 #include "net/quic/test_tools/quic_framer_peer.h" 20 #include "net/quic/test_tools/quic_framer_peer.h"
21 #include "net/quic/test_tools/quic_test_utils.h" 21 #include "net/quic/test_tools/quic_test_utils.h"
22 22
23 using base::hash_set; 23 using base::hash_set;
24 using base::StringPiece; 24 using base::StringPiece;
25 using std::make_pair; 25 using std::make_pair;
26 using std::map; 26 using std::map;
27 using std::numeric_limits; 27 using std::numeric_limits;
28 using std::string; 28 using std::string;
29 using std::vector; 29 using std::vector;
30 using testing::Return;
31 using testing::_;
30 32
31 namespace net { 33 namespace net {
32 namespace test { 34 namespace test {
33 35
34 const QuicPacketSequenceNumber kEpoch = GG_UINT64_C(1) << 48; 36 const QuicPacketSequenceNumber kEpoch = GG_UINT64_C(1) << 48;
35 const QuicPacketSequenceNumber kMask = kEpoch - 1; 37 const QuicPacketSequenceNumber kMask = kEpoch - 1;
36 38
37 // Index into the guid offset in the header. 39 // Index into the guid offset in the header.
38 const size_t kGuidOffset = 0; 40 const size_t kGuidOffset = 0;
39 // Index into the flags offset in the header. 41 // Index into the flags offset in the header.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 DCHECK(false); 195 DCHECK(false);
194 return true; 196 return true;
195 } 197 }
196 198
197 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE { 199 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE {
198 packet_count_++; 200 packet_count_++;
199 header_.reset(new QuicPacketHeader(header)); 201 header_.reset(new QuicPacketHeader(header));
200 return accept_packet_; 202 return accept_packet_;
201 } 203 }
202 204
203 virtual void OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE { 205 virtual bool OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE {
204 frame_count_++; 206 frame_count_++;
205 stream_frames_.push_back(new QuicStreamFrame(frame)); 207 stream_frames_.push_back(new QuicStreamFrame(frame));
208 return true;
206 } 209 }
207 210
208 virtual void OnFecProtectedPayload(StringPiece payload) OVERRIDE { 211 virtual void OnFecProtectedPayload(StringPiece payload) OVERRIDE {
209 fec_protected_payload_ = payload.as_string(); 212 fec_protected_payload_ = payload.as_string();
210 } 213 }
211 214
212 virtual void OnAckFrame(const QuicAckFrame& frame) OVERRIDE { 215 virtual bool OnAckFrame(const QuicAckFrame& frame) OVERRIDE {
213 frame_count_++; 216 frame_count_++;
214 ack_frames_.push_back(new QuicAckFrame(frame)); 217 ack_frames_.push_back(new QuicAckFrame(frame));
218 return true;
215 } 219 }
216 220
217 virtual void OnCongestionFeedbackFrame( 221 virtual bool OnCongestionFeedbackFrame(
218 const QuicCongestionFeedbackFrame& frame) OVERRIDE { 222 const QuicCongestionFeedbackFrame& frame) OVERRIDE {
219 frame_count_++; 223 frame_count_++;
220 congestion_feedback_frames_.push_back( 224 congestion_feedback_frames_.push_back(
221 new QuicCongestionFeedbackFrame(frame)); 225 new QuicCongestionFeedbackFrame(frame));
226 return true;
222 } 227 }
223 228
224 virtual void OnFecData(const QuicFecData& fec) OVERRIDE { 229 virtual void OnFecData(const QuicFecData& fec) OVERRIDE {
225 fec_count_++; 230 fec_count_++;
226 fec_data_.push_back(new QuicFecData(fec)); 231 fec_data_.push_back(new QuicFecData(fec));
227 } 232 }
228 233
229 virtual void OnPacketComplete() OVERRIDE { 234 virtual void OnPacketComplete() OVERRIDE {
230 complete_packets_++; 235 complete_packets_++;
231 } 236 }
232 237
233 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE { 238 virtual bool OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE {
234 rst_stream_frame_ = frame; 239 rst_stream_frame_ = frame;
240 return true;
235 } 241 }
236 242
237 virtual void OnConnectionCloseFrame( 243 virtual bool OnConnectionCloseFrame(
238 const QuicConnectionCloseFrame& frame) OVERRIDE { 244 const QuicConnectionCloseFrame& frame) OVERRIDE {
239 connection_close_frame_ = frame; 245 connection_close_frame_ = frame;
246 return true;
240 } 247 }
241 248
242 virtual void OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE { 249 virtual bool OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE {
243 goaway_frame_ = frame; 250 goaway_frame_ = frame;
251 return true;
244 } 252 }
245 253
246 // Counters from the visitor_ callbacks. 254 // Counters from the visitor_ callbacks.
247 int error_count_; 255 int error_count_;
248 int packet_count_; 256 int packet_count_;
249 int frame_count_; 257 int frame_count_;
250 int fec_count_; 258 int fec_count_;
251 int complete_packets_; 259 int complete_packets_;
252 int revived_packets_; 260 int revived_packets_;
253 bool accept_packet_; 261 bool accept_packet_;
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // entropy hash of sent packets till least awaiting - 1. 1059 // entropy hash of sent packets till least awaiting - 1.
1052 0xAB, 1060 0xAB,
1053 // least packet sequence number awaiting an ack 1061 // least packet sequence number awaiting an ack
1054 0xA0, 0x9A, 0x78, 0x56, 1062 0xA0, 0x9A, 0x78, 0x56,
1055 0x34, 0x12, 1063 0x34, 0x12,
1056 // entropy hash of all received packets. 1064 // entropy hash of all received packets.
1057 0xBA, 1065 0xBA,
1058 // largest observed packet sequence number 1066 // largest observed packet sequence number
1059 0xBF, 0x9A, 0x78, 0x56, 1067 0xBF, 0x9A, 0x78, 0x56,
1060 0x34, 0x12, 1068 0x34, 0x12,
1069 // Infinite delta time.
1070 0xFF, 0xFF, 0xFF, 0xFF,
1061 // num missing packets 1071 // num missing packets
1062 0x01, 1072 0x01,
1063 // missing packet 1073 // missing packet
1064 0xBE, 0x9A, 0x78, 0x56, 1074 0xBE, 0x9A, 0x78, 0x56,
1065 0x34, 0x12, 1075 0x34, 0x12,
1066 }; 1076 };
1067 1077
1068 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1078 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1069 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1079 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1070 1080
(...skipping 12 matching lines...) Expand all
1083 frame.received_info.missing_packets.begin(); 1093 frame.received_info.missing_packets.begin();
1084 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); 1094 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter);
1085 EXPECT_EQ(GG_UINT64_C(0x0123456789AA0), frame.sent_info.least_unacked); 1095 EXPECT_EQ(GG_UINT64_C(0x0123456789AA0), frame.sent_info.least_unacked);
1086 1096
1087 const size_t kSentEntropyOffset = kQuicFrameTypeSize; 1097 const size_t kSentEntropyOffset = kQuicFrameTypeSize;
1088 const size_t kLeastUnackedOffset = kSentEntropyOffset + kQuicEntropyHashSize; 1098 const size_t kLeastUnackedOffset = kSentEntropyOffset + kQuicEntropyHashSize;
1089 const size_t kReceivedEntropyOffset = kLeastUnackedOffset + 1099 const size_t kReceivedEntropyOffset = kLeastUnackedOffset +
1090 kSequenceNumberSize; 1100 kSequenceNumberSize;
1091 const size_t kLargestObservedOffset = kReceivedEntropyOffset + 1101 const size_t kLargestObservedOffset = kReceivedEntropyOffset +
1092 kQuicEntropyHashSize; 1102 kQuicEntropyHashSize;
1093 const size_t kNumMissingPacketOffset = kLargestObservedOffset + 1103 const size_t kMissingDeltaTimeOffset = kLargestObservedOffset +
1094 kSequenceNumberSize; 1104 kSequenceNumberSize;
1105 const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset +
1106 kQuicDeltaTimeLargestObservedSize;
1095 const size_t kMissingPacketsOffset = kNumMissingPacketOffset + 1107 const size_t kMissingPacketsOffset = kNumMissingPacketOffset +
1096 kNumberOfMissingPacketsSize; 1108 kNumberOfMissingPacketsSize;
1097 // Now test framing boundaries 1109 // Now test framing boundaries
1098 const size_t missing_packets_size = 1 * kSequenceNumberSize; 1110 const size_t missing_packets_size = 1 * kSequenceNumberSize;
1099 for (size_t i = 0; 1111 for (size_t i = 0;
1100 i < QuicFramer::GetMinAckFrameSize() + missing_packets_size; ++i) { 1112 i < QuicFramer::GetMinAckFrameSize() + missing_packets_size; ++i) {
1101 string expected_error; 1113 string expected_error;
1102 if (i < kSentEntropyOffset) { 1114 if (i < kSentEntropyOffset) {
1103 expected_error = "Unable to read frame type."; 1115 expected_error = "Unable to read frame type.";
1104 } else if (i < kLeastUnackedOffset) { 1116 } else if (i < kLeastUnackedOffset) {
1105 expected_error = "Unable to read entropy hash for sent packets."; 1117 expected_error = "Unable to read entropy hash for sent packets.";
1106 } else if (i < kReceivedEntropyOffset) { 1118 } else if (i < kReceivedEntropyOffset) {
1107 expected_error = "Unable to read least unacked."; 1119 expected_error = "Unable to read least unacked.";
1108 } else if (i < kLargestObservedOffset) { 1120 } else if (i < kLargestObservedOffset) {
1109 expected_error = "Unable to read entropy hash for received packets."; 1121 expected_error = "Unable to read entropy hash for received packets.";
1122 } else if (i < kMissingDeltaTimeOffset) {
1123 expected_error = "Unable to read largest observed.";
1110 } else if (i < kNumMissingPacketOffset) { 1124 } else if (i < kNumMissingPacketOffset) {
1111 expected_error = "Unable to read largest observed."; 1125 expected_error = "Unable to read delta time largest observed.";
1112 } else if (i < kMissingPacketsOffset) { 1126 } else if (i < kMissingPacketsOffset) {
1113 expected_error = "Unable to read num missing packets."; 1127 expected_error = "Unable to read num missing packets.";
1114 } else { 1128 } else {
1115 expected_error = "Unable to read sequence number in missing packets."; 1129 expected_error = "Unable to read sequence number in missing packets.";
1116 } 1130 }
1117 CheckProcessingFails(packet, i + GetPacketHeaderSize(!kIncludeVersion), 1131 CheckProcessingFails(packet, i + GetPacketHeaderSize(!kIncludeVersion),
1118 expected_error, QUIC_INVALID_FRAME_DATA); 1132 expected_error, QUIC_INVALID_FRAME_DATA);
1119 } 1133 }
1120 } 1134 }
1121 1135
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 // entropy hash of sent packets till least awaiting - 1. 1459 // entropy hash of sent packets till least awaiting - 1.
1446 0xBF, 1460 0xBF,
1447 // least packet sequence number awaiting an ack 1461 // least packet sequence number awaiting an ack
1448 0xA0, 0x9A, 0x78, 0x56, 1462 0xA0, 0x9A, 0x78, 0x56,
1449 0x34, 0x12, 1463 0x34, 0x12,
1450 // entropy hash of all received packets. 1464 // entropy hash of all received packets.
1451 0xEB, 1465 0xEB,
1452 // largest observed packet sequence number 1466 // largest observed packet sequence number
1453 0xBF, 0x9A, 0x78, 0x56, 1467 0xBF, 0x9A, 0x78, 0x56,
1454 0x34, 0x12, 1468 0x34, 0x12,
1469 // Infinite delta time.
1470 0xFF, 0xFF, 0xFF, 0xFF,
1455 // num missing packets 1471 // num missing packets
1456 0x01, 1472 0x01,
1457 // missing packet 1473 // missing packet
1458 0xBE, 0x9A, 0x78, 0x56, 1474 0xBE, 0x9A, 0x78, 0x56,
1459 0x34, 0x12, 1475 0x34, 0x12,
1460 }; 1476 };
1461 1477
1462 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1478 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1463 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1479 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1464 1480
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 unsigned char packet[] = { 1869 unsigned char packet[] = {
1854 0x10, 0x32, 0x54, 0x76, 1870 0x10, 0x32, 0x54, 0x76,
1855 0x98, 0xBA, 0xDC, 0xFE, 1871 0x98, 0xBA, 0xDC, 0xFE,
1856 // public flags (version) 1872 // public flags (version)
1857 0x01, 1873 0x01,
1858 // version tag 1874 // version tag
1859 'Q', '1', '.', '0', 1875 'Q', '1', '.', '0',
1860 'Q', '2', '.', '0', 1876 'Q', '2', '.', '0',
1861 }; 1877 };
1862 1878
1863 const int kQuicVersion2 = MAKE_TAG('Q', '2', '.', '0'); 1879 const int kQuicVersion2 = MakeQuicTag('Q', '2', '.', '0');
1864 QuicVersionTagList versions; 1880 QuicVersionTagList versions;
1865 versions.push_back(kQuicVersion1); 1881 versions.push_back(kQuicVersion1);
1866 versions.push_back(kQuicVersion2); 1882 versions.push_back(kQuicVersion2);
1867 scoped_ptr<QuicEncryptedPacket> data( 1883 scoped_ptr<QuicEncryptedPacket> data(
1868 framer_.ConstructVersionNegotiationPacket(header, versions)); 1884 framer_.ConstructVersionNegotiationPacket(header, versions));
1869 1885
1870 test::CompareCharArraysWithHexError("constructed packet", 1886 test::CompareCharArraysWithHexError("constructed packet",
1871 data->data(), data->length(), 1887 data->data(), data->length(),
1872 AsChars(packet), arraysize(packet)); 1888 AsChars(packet), arraysize(packet));
1873 } 1889 }
1874 1890
1875 TEST_F(QuicFramerTest, ConstructAckFramePacket) { 1891 TEST_F(QuicFramerTest, ConstructAckFramePacket) {
1876 QuicPacketHeader header; 1892 QuicPacketHeader header;
1877 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1893 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1878 header.public_header.reset_flag = false; 1894 header.public_header.reset_flag = false;
1879 header.public_header.version_flag = false; 1895 header.public_header.version_flag = false;
1880 header.fec_flag = false; 1896 header.fec_flag = false;
1881 header.entropy_flag = true; 1897 header.entropy_flag = true;
1882 header.fec_entropy_flag = true; 1898 header.fec_entropy_flag = true;
1883 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1899 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1884 header.fec_group = 0; 1900 header.fec_group = 0;
1885 1901
1886 QuicAckFrame ack_frame; 1902 QuicAckFrame ack_frame;
1887 ack_frame.received_info.entropy_hash = 0x43; 1903 ack_frame.received_info.entropy_hash = 0x43;
1888 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF); 1904 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF);
1905 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero();
1889 ack_frame.received_info.missing_packets.insert( 1906 ack_frame.received_info.missing_packets.insert(
1890 GG_UINT64_C(0x770123456789ABE)); 1907 GG_UINT64_C(0x770123456789ABE));
1891 ack_frame.sent_info.entropy_hash = 0x14; 1908 ack_frame.sent_info.entropy_hash = 0x14;
1892 ack_frame.sent_info.least_unacked = GG_UINT64_C(0x770123456789AA0); 1909 ack_frame.sent_info.least_unacked = GG_UINT64_C(0x770123456789AA0);
1893 1910
1894 QuicFrames frames; 1911 QuicFrames frames;
1895 frames.push_back(QuicFrame(&ack_frame)); 1912 frames.push_back(QuicFrame(&ack_frame));
1896 1913
1897 unsigned char packet[] = { 1914 unsigned char packet[] = {
1898 // guid 1915 // guid
(...skipping 14 matching lines...) Expand all
1913 // entropy hash of sent packets till least awaiting - 1. 1930 // entropy hash of sent packets till least awaiting - 1.
1914 0x14, 1931 0x14,
1915 // least packet sequence number awaiting an ack 1932 // least packet sequence number awaiting an ack
1916 0xA0, 0x9A, 0x78, 0x56, 1933 0xA0, 0x9A, 0x78, 0x56,
1917 0x34, 0x12, 1934 0x34, 0x12,
1918 // entropy hash of all received packets. 1935 // entropy hash of all received packets.
1919 0x43, 1936 0x43,
1920 // largest observed packet sequence number 1937 // largest observed packet sequence number
1921 0xBF, 0x9A, 0x78, 0x56, 1938 0xBF, 0x9A, 0x78, 0x56,
1922 0x34, 0x12, 1939 0x34, 0x12,
1940 // Zero delta time.
1941 0x0, 0x0, 0x0, 0x0,
1923 // num missing packets 1942 // num missing packets
1924 0x01, 1943 0x01,
1925 // missing packet 1944 // missing packet
1926 0xBE, 0x9A, 0x78, 0x56, 1945 0xBE, 0x9A, 0x78, 0x56,
1927 0x34, 0x12, 1946 0x34, 0x12,
1928 }; 1947 };
1929 1948
1930 scoped_ptr<QuicPacket> data( 1949 scoped_ptr<QuicPacket> data(
1931 framer_.ConstructFrameDataPacket(header, frames).packet); 1950 framer_.ConstructFrameDataPacket(header, frames).packet);
1932 ASSERT_TRUE(data != NULL); 1951 ASSERT_TRUE(data != NULL);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 // entropy hash of sent packets till least awaiting - 1. 2268 // entropy hash of sent packets till least awaiting - 1.
2250 0xE0, 2269 0xE0,
2251 // least packet sequence number awaiting an ack 2270 // least packet sequence number awaiting an ack
2252 0xA0, 0x9A, 0x78, 0x56, 2271 0xA0, 0x9A, 0x78, 0x56,
2253 0x34, 0x12, 2272 0x34, 0x12,
2254 // entropy hash of all received packets. 2273 // entropy hash of all received packets.
2255 0x43, 2274 0x43,
2256 // largest observed packet sequence number 2275 // largest observed packet sequence number
2257 0xBF, 0x9A, 0x78, 0x56, 2276 0xBF, 0x9A, 0x78, 0x56,
2258 0x34, 0x12, 2277 0x34, 0x12,
2278 // Infinite delta time.
2279 0xFF, 0xFF, 0xFF, 0xFF,
2259 // num missing packets 2280 // num missing packets
2260 0x01, 2281 0x01,
2261 // missing packet 2282 // missing packet
2262 0xBE, 0x9A, 0x78, 0x56, 2283 0xBE, 0x9A, 0x78, 0x56,
2263 0x34, 0x12, 2284 0x34, 0x12,
2264 }; 2285 };
2265 2286
2266 scoped_ptr<QuicPacket> data( 2287 scoped_ptr<QuicPacket> data(
2267 framer_.ConstructFrameDataPacket(header, frames).packet); 2288 framer_.ConstructFrameDataPacket(header, frames).packet);
2268 ASSERT_TRUE(data != NULL); 2289 ASSERT_TRUE(data != NULL);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 2726 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
2706 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 2727 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
2707 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 2728 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
2708 ASSERT_TRUE(visitor_.header_.get()); 2729 ASSERT_TRUE(visitor_.header_.get());
2709 EXPECT_TRUE(visitor_.header_->fec_flag); 2730 EXPECT_TRUE(visitor_.header_->fec_flag);
2710 EXPECT_TRUE(visitor_.header_->entropy_flag); 2731 EXPECT_TRUE(visitor_.header_->entropy_flag);
2711 EXPECT_TRUE(visitor_.header_->fec_entropy_flag); 2732 EXPECT_TRUE(visitor_.header_->fec_entropy_flag);
2712 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash); 2733 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash);
2713 }; 2734 };
2714 2735
2736 TEST_F(QuicFramerTest, StopPacketProcessing) {
2737 unsigned char packet[] = {
2738 // guid
2739 0x10, 0x32, 0x54, 0x76,
2740 0x98, 0xBA, 0xDC, 0xFE,
2741 // public flags
2742 0x00,
2743 // packet sequence number
2744 0xBC, 0x9A, 0x78, 0x56,
2745 0x34, 0x12,
2746 // Entropy
2747 0x02,
2748 // first fec protected packet offset
2749 0xFF,
2750
2751 // frame type (stream frame)
2752 0x01,
2753 // stream id
2754 0x04, 0x03, 0x02, 0x01,
2755 // fin
2756 0x01,
2757 // offset
2758 0x54, 0x76, 0x10, 0x32,
2759 0xDC, 0xFE, 0x98, 0xBA,
2760 // data length
2761 0x0c, 0x00,
2762 // data
2763 'h', 'e', 'l', 'l',
2764 'o', ' ', 'w', 'o',
2765 'r', 'l', 'd', '!',
2766
2767 // frame type (ack frame)
2768 0x02,
2769 // entropy hash of sent packets till least awaiting - 1.
2770 0x14,
2771 // least packet sequence number awaiting an ack
2772 0xA0, 0x9A, 0x78, 0x56,
2773 0x34, 0x12,
2774 // entropy hash of all received packets.
2775 0x43,
2776 // largest observed packet sequence number
2777 0xBF, 0x9A, 0x78, 0x56,
2778 0x34, 0x12,
2779 // num missing packets
2780 0x01,
2781 // missing packet
2782 0xBE, 0x9A, 0x78, 0x56,
2783 0x34, 0x12,
2784 };
2785
2786 MockFramerVisitor visitor;
2787 framer_.set_visitor(&visitor);
2788 EXPECT_CALL(visitor, OnPacket());
2789 EXPECT_CALL(visitor, OnPacketHeader(_));
2790 EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false));
2791 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0);
2792 EXPECT_CALL(visitor, OnPacketComplete());
2793
2794 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
2795 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
2796 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
2797 }
2798
2715 } // namespace test 2799 } // namespace test
2716 } // namespace net 2800 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698