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

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

Issue 11377096: Change from re-transmitting an packet with a retransmit number to sending a new packet with a new s… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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.h » ('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 <vector> 6 #include <vector>
7 7
8 #include "base/hash_tables.h" 8 #include "base/hash_tables.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 TEST_F(QuicFramerTest, LargePacket) { 225 TEST_F(QuicFramerTest, LargePacket) {
226 unsigned char packet[kMaxPacketSize + 1] = { 226 unsigned char packet[kMaxPacketSize + 1] = {
227 // guid 227 // guid
228 0x10, 0x32, 0x54, 0x76, 228 0x10, 0x32, 0x54, 0x76,
229 0x98, 0xBA, 0xDC, 0xFE, 229 0x98, 0xBA, 0xDC, 0xFE,
230 // packet id 230 // packet id
231 0xBC, 0x9A, 0x78, 0x56, 231 0xBC, 0x9A, 0x78, 0x56,
232 0x34, 0x12, 232 0x34, 0x12,
233 // retransmission count
234 0x01,
235 // transmission time 233 // transmission time
236 0x87, 0x96, 0xA5, 0xB4, 234 0x87, 0x96, 0xA5, 0xB4,
237 0xC3, 0xD2, 0xE1, 0xF0, 235 0xC3, 0xD2, 0xE1, 0xF0,
238 // flags 236 // flags
239 0x00, 237 0x00,
240 // fec group 238 // fec group
241 0x00, 239 0x00,
242 // frame count 240 // frame count
243 0x01, 241 0x01,
244 }; 242 };
(...skipping 11 matching lines...) Expand all
256 } 254 }
257 255
258 TEST_F(QuicFramerTest, PacketHeader) { 256 TEST_F(QuicFramerTest, PacketHeader) {
259 unsigned char packet[] = { 257 unsigned char packet[] = {
260 // guid 258 // guid
261 0x10, 0x32, 0x54, 0x76, 259 0x10, 0x32, 0x54, 0x76,
262 0x98, 0xBA, 0xDC, 0xFE, 260 0x98, 0xBA, 0xDC, 0xFE,
263 // packet id 261 // packet id
264 0xBC, 0x9A, 0x78, 0x56, 262 0xBC, 0x9A, 0x78, 0x56,
265 0x34, 0x12, 263 0x34, 0x12,
266 // retransmission count
267 0x01,
268 // transmission time 264 // transmission time
269 0x87, 0x96, 0xA5, 0xB4, 265 0x87, 0x96, 0xA5, 0xB4,
270 0xC3, 0xD2, 0xE1, 0xF0, 266 0xC3, 0xD2, 0xE1, 0xF0,
271 // flags 267 // flags
272 0x00, 268 0x00,
273 // fec group 269 // fec group
274 0x00, 270 0x00,
275 }; 271 };
276 272
277 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 273 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
278 EXPECT_FALSE(framer_.ProcessPacket(self_address_, peer_address_, encrypted)); 274 EXPECT_FALSE(framer_.ProcessPacket(self_address_, peer_address_, encrypted));
279 275
280 EXPECT_EQ(QUIC_INVALID_FRAME_DATA, framer_.error()); 276 EXPECT_EQ(QUIC_INVALID_FRAME_DATA, framer_.error());
281 ASSERT_TRUE(visitor_.header_.get()); 277 ASSERT_TRUE(visitor_.header_.get());
282 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), visitor_.header_->guid); 278 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), visitor_.header_->guid);
283 EXPECT_EQ(0x1, visitor_.header_->retransmission_count);
284 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 279 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
285 visitor_.header_->packet_sequence_number); 280 visitor_.header_->packet_sequence_number);
286 EXPECT_EQ(GG_UINT64_C(0xF0E1D2C3B4A59687), 281 EXPECT_EQ(GG_UINT64_C(0xF0E1D2C3B4A59687),
287 visitor_.header_->transmission_time); 282 visitor_.header_->transmission_time);
288 EXPECT_EQ(0x00, visitor_.header_->flags); 283 EXPECT_EQ(0x00, visitor_.header_->flags);
289 EXPECT_EQ(0x00, visitor_.header_->fec_group); 284 EXPECT_EQ(0x00, visitor_.header_->fec_group);
290 285
291 // Now test framing boundaries 286 // Now test framing boundaries
292 for (int i = 0; i < 25; ++i) { 287 for (int i = 0; i < 24; ++i) {
293 string expected_error; 288 string expected_error;
294 if (i < 8) { 289 if (i < 8) {
295 expected_error = "Unable to read GUID."; 290 expected_error = "Unable to read GUID.";
296 } else if (i < 14) { 291 } else if (i < 14) {
297 expected_error = "Unable to read sequence number."; 292 expected_error = "Unable to read sequence number.";
298 } else if (i < 15) { 293 } else if (i < 22) {
299 expected_error = "Unable to read retransmission count."; 294 expected_error = "Unable to read transmission time.";
300 } else if (i < 23) { 295 } else if (i < 23) {
301 expected_error = "Unable to read transmission time."; 296 expected_error = "Unable to read flags.";
302 } else if (i < 24) { 297 } else if (i < 24) {
303 expected_error = "Unable to read flags.";
304 } else if (i < 25) {
305 expected_error = "Unable to read fec group."; 298 expected_error = "Unable to read fec group.";
306 } 299 }
307 300
308 QuicEncryptedPacket encrypted(AsChars(packet), i, false); 301 QuicEncryptedPacket encrypted(AsChars(packet), i, false);
309 EXPECT_FALSE(framer_.ProcessPacket(self_address_, peer_address_, 302 EXPECT_FALSE(framer_.ProcessPacket(self_address_, peer_address_,
310 encrypted)); 303 encrypted));
311 EXPECT_EQ(expected_error, framer_.detailed_error()); 304 EXPECT_EQ(expected_error, framer_.detailed_error());
312 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error()); 305 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error());
313 } 306 }
314 } 307 }
315 308
316 TEST_F(QuicFramerTest, StreamFrame) { 309 TEST_F(QuicFramerTest, StreamFrame) {
317 unsigned char packet[] = { 310 unsigned char packet[] = {
318 // guid 311 // guid
319 0x10, 0x32, 0x54, 0x76, 312 0x10, 0x32, 0x54, 0x76,
320 0x98, 0xBA, 0xDC, 0xFE, 313 0x98, 0xBA, 0xDC, 0xFE,
321 // packet id 314 // packet id
322 0xBC, 0x9A, 0x78, 0x56, 315 0xBC, 0x9A, 0x78, 0x56,
323 0x34, 0x12, 316 0x34, 0x12,
324 // retransmission count
325 0x01,
326 // transmission time 317 // transmission time
327 0x87, 0x96, 0xA5, 0xB4, 318 0x87, 0x96, 0xA5, 0xB4,
328 0xC3, 0xD2, 0xE1, 0xF0, 319 0xC3, 0xD2, 0xE1, 0xF0,
329 // flags 320 // flags
330 0x00, 321 0x00,
331 // fec group 322 // fec group
332 0x00, 323 0x00,
333 324
334 // frame count 325 // frame count
335 0x01, 326 0x01,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 TEST_F(QuicFramerTest, RejectPacket) { 387 TEST_F(QuicFramerTest, RejectPacket) {
397 visitor_.accept_packet_ = false; 388 visitor_.accept_packet_ = false;
398 389
399 unsigned char packet[] = { 390 unsigned char packet[] = {
400 // guid 391 // guid
401 0x10, 0x32, 0x54, 0x76, 392 0x10, 0x32, 0x54, 0x76,
402 0x98, 0xBA, 0xDC, 0xFE, 393 0x98, 0xBA, 0xDC, 0xFE,
403 // packet id 394 // packet id
404 0xBC, 0x9A, 0x78, 0x56, 395 0xBC, 0x9A, 0x78, 0x56,
405 0x34, 0x12, 396 0x34, 0x12,
406 // retransmission count
407 0x01,
408 // transmission time 397 // transmission time
409 0x87, 0x96, 0xA5, 0xB4, 398 0x87, 0x96, 0xA5, 0xB4,
410 0xC3, 0xD2, 0xE1, 0xF0, 399 0xC3, 0xD2, 0xE1, 0xF0,
411 // flags 400 // flags
412 0x00, 401 0x00,
413 // fec group 402 // fec group
414 0x00, 403 0x00,
415 404
416 // frame count 405 // frame count
417 0x01, 406 0x01,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // data length 449 // data length
461 0x0c, 0x00, 450 0x0c, 0x00,
462 // data 451 // data
463 'h', 'e', 'l', 'l', 452 'h', 'e', 'l', 'l',
464 'o', ' ', 'w', 'o', 453 'o', ' ', 'w', 'o',
465 'r', 'l', 'd', '!', 454 'r', 'l', 'd', '!',
466 }; 455 };
467 456
468 QuicPacketHeader header; 457 QuicPacketHeader header;
469 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 458 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
470 header.retransmission_count = 0x01;
471 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 459 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
472 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 460 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
473 header.flags = PACKET_FLAGS_NONE; 461 header.flags = PACKET_FLAGS_NONE;
474 header.fec_group = 0; 462 header.fec_group = 0;
475 463
476 // Do not encrypt the payload because the revived payload is post-encryption. 464 // Do not encrypt the payload because the revived payload is post-encryption.
477 EXPECT_TRUE(framer_.ProcessRevivedPacket(header, 465 EXPECT_TRUE(framer_.ProcessRevivedPacket(header,
478 StringPiece(AsChars(payload), 466 StringPiece(AsChars(payload),
479 arraysize(payload)))); 467 arraysize(payload))));
480 468
481 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 469 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
482 ASSERT_EQ(1, visitor_.revived_packets_); 470 ASSERT_EQ(1, visitor_.revived_packets_);
483 ASSERT_TRUE(visitor_.header_.get()); 471 ASSERT_TRUE(visitor_.header_.get());
484 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), visitor_.header_->guid); 472 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), visitor_.header_->guid);
485 EXPECT_EQ(0x1, visitor_.header_->retransmission_count);
486 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 473 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
487 visitor_.header_->packet_sequence_number); 474 visitor_.header_->packet_sequence_number);
488 EXPECT_EQ(GG_UINT64_C(0xF0E1D2C3B4A59687), 475 EXPECT_EQ(GG_UINT64_C(0xF0E1D2C3B4A59687),
489 visitor_.header_->transmission_time); 476 visitor_.header_->transmission_time);
490 EXPECT_EQ(0x00, visitor_.header_->flags); 477 EXPECT_EQ(0x00, visitor_.header_->flags);
491 EXPECT_EQ(0x00, visitor_.header_->fec_group); 478 EXPECT_EQ(0x00, visitor_.header_->fec_group);
492 479
493 480
494 ASSERT_EQ(1u, visitor_.stream_frames_.size()); 481 ASSERT_EQ(1u, visitor_.stream_frames_.size());
495 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 482 EXPECT_EQ(0u, visitor_.ack_frames_.size());
496 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.stream_frames_[0]->stream_id); 483 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.stream_frames_[0]->stream_id);
497 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); 484 EXPECT_TRUE(visitor_.stream_frames_[0]->fin);
498 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), 485 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654),
499 visitor_.stream_frames_[0]->offset); 486 visitor_.stream_frames_[0]->offset);
500 EXPECT_EQ("hello world!", visitor_.stream_frames_[0]->data); 487 EXPECT_EQ("hello world!", visitor_.stream_frames_[0]->data);
501 } 488 }
502 489
503 TEST_F(QuicFramerTest, StreamFrameInFecGroup) { 490 TEST_F(QuicFramerTest, StreamFrameInFecGroup) {
504 unsigned char packet[] = { 491 unsigned char packet[] = {
505 // guid 492 // guid
506 0x10, 0x32, 0x54, 0x76, 493 0x10, 0x32, 0x54, 0x76,
507 0x98, 0xBA, 0xDC, 0xFE, 494 0x98, 0xBA, 0xDC, 0xFE,
508 // packet id 495 // packet id
509 0xBC, 0x9A, 0x78, 0x56, 496 0xBC, 0x9A, 0x78, 0x56,
510 0x12, 0x34, 497 0x12, 0x34,
511 // retransmission count
512 0x01,
513 // transmission time 498 // transmission time
514 0x87, 0x96, 0xA5, 0xB4, 499 0x87, 0x96, 0xA5, 0xB4,
515 0xC3, 0xD2, 0xE1, 0xF0, 500 0xC3, 0xD2, 0xE1, 0xF0,
516 // flags 501 // flags
517 0x00, 502 0x00,
518 // fec group 503 // fec group
519 0x02, 504 0x02,
520 505
521 // frame count 506 // frame count
522 0x01, 507 0x01,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 544 }
560 545
561 TEST_F(QuicFramerTest, AckFrame) { 546 TEST_F(QuicFramerTest, AckFrame) {
562 unsigned char packet[] = { 547 unsigned char packet[] = {
563 // guid 548 // guid
564 0x10, 0x32, 0x54, 0x76, 549 0x10, 0x32, 0x54, 0x76,
565 0x98, 0xBA, 0xDC, 0xFE, 550 0x98, 0xBA, 0xDC, 0xFE,
566 // packet id 551 // packet id
567 0xBC, 0x9A, 0x78, 0x56, 552 0xBC, 0x9A, 0x78, 0x56,
568 0x34, 0x12, 553 0x34, 0x12,
569 // retransmission count
570 0x01,
571 // transmission time 554 // transmission time
572 0x87, 0x96, 0xA5, 0xB4, 555 0x87, 0x96, 0xA5, 0xB4,
573 0xC3, 0xD2, 0xE1, 0xF0, 556 0xC3, 0xD2, 0xE1, 0xF0,
574 // flags 557 // flags
575 0x00, 558 0x00,
576 // fec group 559 // fec group
577 0x00, 560 0x00,
578 561
579 // frame count 562 // frame count
580 0x01, 563 0x01,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 658 }
676 659
677 TEST_F(QuicFramerTest, AckFrameTCP) { 660 TEST_F(QuicFramerTest, AckFrameTCP) {
678 unsigned char packet[] = { 661 unsigned char packet[] = {
679 // guid 662 // guid
680 0x10, 0x32, 0x54, 0x76, 663 0x10, 0x32, 0x54, 0x76,
681 0x98, 0xBA, 0xDC, 0xFE, 664 0x98, 0xBA, 0xDC, 0xFE,
682 // packet id 665 // packet id
683 0xBC, 0x9A, 0x78, 0x56, 666 0xBC, 0x9A, 0x78, 0x56,
684 0x34, 0x12, 667 0x34, 0x12,
685 // retransmission count
686 0x01,
687 // transmission time 668 // transmission time
688 0x87, 0x96, 0xA5, 0xB4, 669 0x87, 0x96, 0xA5, 0xB4,
689 0xC3, 0xD2, 0xE1, 0xF0, 670 0xC3, 0xD2, 0xE1, 0xF0,
690 // flags 671 // flags
691 0x00, 672 0x00,
692 // fec group 673 // fec group
693 0x00, 674 0x00,
694 675
695 // frame count 676 // frame count
696 0x01, 677 0x01,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } 765 }
785 766
786 TEST_F(QuicFramerTest, AckFrameInterArrival) { 767 TEST_F(QuicFramerTest, AckFrameInterArrival) {
787 unsigned char packet[] = { 768 unsigned char packet[] = {
788 // guid 769 // guid
789 0x10, 0x32, 0x54, 0x76, 770 0x10, 0x32, 0x54, 0x76,
790 0x98, 0xBA, 0xDC, 0xFE, 771 0x98, 0xBA, 0xDC, 0xFE,
791 // packet id 772 // packet id
792 0xBC, 0x9A, 0x78, 0x56, 773 0xBC, 0x9A, 0x78, 0x56,
793 0x34, 0x12, 774 0x34, 0x12,
794 // retransmission count
795 0x01,
796 // transmission time 775 // transmission time
797 0x87, 0x96, 0xA5, 0xB4, 776 0x87, 0x96, 0xA5, 0xB4,
798 0xC3, 0xD2, 0xE1, 0xF0, 777 0xC3, 0xD2, 0xE1, 0xF0,
799 // flags 778 // flags
800 0x00, 779 0x00,
801 // fec group 780 // fec group
802 0x00, 781 0x00,
803 782
804 // frame count 783 // frame count
805 0x01, 784 0x01,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 876 }
898 877
899 TEST_F(QuicFramerTest, AckFrameFixRate) { 878 TEST_F(QuicFramerTest, AckFrameFixRate) {
900 unsigned char packet[] = { 879 unsigned char packet[] = {
901 // guid 880 // guid
902 0x10, 0x32, 0x54, 0x76, 881 0x10, 0x32, 0x54, 0x76,
903 0x98, 0xBA, 0xDC, 0xFE, 882 0x98, 0xBA, 0xDC, 0xFE,
904 // packet id 883 // packet id
905 0xBC, 0x9A, 0x78, 0x56, 884 0xBC, 0x9A, 0x78, 0x56,
906 0x34, 0x12, 885 0x34, 0x12,
907 // retransmission count
908 0x01,
909 // transmission time 886 // transmission time
910 0x87, 0x96, 0xA5, 0xB4, 887 0x87, 0x96, 0xA5, 0xB4,
911 0xC3, 0xD2, 0xE1, 0xF0, 888 0xC3, 0xD2, 0xE1, 0xF0,
912 // flags 889 // flags
913 0x00, 890 0x00,
914 // fec group 891 // fec group
915 0x00, 892 0x00,
916 893
917 // frame count 894 // frame count
918 0x01, 895 0x01,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 978
1002 979
1003 TEST_F(QuicFramerTest, AckFrameInvalidFeedback) { 980 TEST_F(QuicFramerTest, AckFrameInvalidFeedback) {
1004 unsigned char packet[] = { 981 unsigned char packet[] = {
1005 // guid 982 // guid
1006 0x10, 0x32, 0x54, 0x76, 983 0x10, 0x32, 0x54, 0x76,
1007 0x98, 0xBA, 0xDC, 0xFE, 984 0x98, 0xBA, 0xDC, 0xFE,
1008 // packet id 985 // packet id
1009 0xBC, 0x9A, 0x78, 0x56, 986 0xBC, 0x9A, 0x78, 0x56,
1010 0x34, 0x12, 987 0x34, 0x12,
1011 // retransmission count
1012 0x01,
1013 // transmission time 988 // transmission time
1014 0x87, 0x96, 0xA5, 0xB4, 989 0x87, 0x96, 0xA5, 0xB4,
1015 0xC3, 0xD2, 0xE1, 0xF0, 990 0xC3, 0xD2, 0xE1, 0xF0,
1016 // flags 991 // flags
1017 0x00, 992 0x00,
1018 // fec group 993 // fec group
1019 0x00, 994 0x00,
1020 995
1021 // frame count 996 // frame count
1022 0x01, 997 0x01,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } 1036 }
1062 1037
1063 TEST_F(QuicFramerTest, RstStreamFrame) { 1038 TEST_F(QuicFramerTest, RstStreamFrame) {
1064 unsigned char packet[] = { 1039 unsigned char packet[] = {
1065 // guid 1040 // guid
1066 0x10, 0x32, 0x54, 0x76, 1041 0x10, 0x32, 0x54, 0x76,
1067 0x98, 0xBA, 0xDC, 0xFE, 1042 0x98, 0xBA, 0xDC, 0xFE,
1068 // packet id 1043 // packet id
1069 0xBC, 0x9A, 0x78, 0x56, 1044 0xBC, 0x9A, 0x78, 0x56,
1070 0x34, 0x12, 1045 0x34, 0x12,
1071 // retransmission count
1072 0x01,
1073 // transmission time 1046 // transmission time
1074 0x87, 0x96, 0xA5, 0xB4, 1047 0x87, 0x96, 0xA5, 0xB4,
1075 0xC3, 0xD2, 0xE1, 0xF0, 1048 0xC3, 0xD2, 0xE1, 0xF0,
1076 // flags 1049 // flags
1077 0x00, 1050 0x00,
1078 // fec group 1051 // fec group
1079 0x00, 1052 0x00,
1080 1053
1081 // frame count 1054 // frame count
1082 0x01, 1055 0x01,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 } 1107 }
1135 1108
1136 TEST_F(QuicFramerTest, ConnectionCloseFrame) { 1109 TEST_F(QuicFramerTest, ConnectionCloseFrame) {
1137 unsigned char packet[] = { 1110 unsigned char packet[] = {
1138 // guid 1111 // guid
1139 0x10, 0x32, 0x54, 0x76, 1112 0x10, 0x32, 0x54, 0x76,
1140 0x98, 0xBA, 0xDC, 0xFE, 1113 0x98, 0xBA, 0xDC, 0xFE,
1141 // packet id 1114 // packet id
1142 0xBC, 0x9A, 0x78, 0x56, 1115 0xBC, 0x9A, 0x78, 0x56,
1143 0x34, 0x12, 1116 0x34, 0x12,
1144 // retransmission count
1145 0x01,
1146 // transmission time 1117 // transmission time
1147 0x87, 0x96, 0xA5, 0xB4, 1118 0x87, 0x96, 0xA5, 0xB4,
1148 0xC3, 0xD2, 0xE1, 0xF0, 1119 0xC3, 0xD2, 0xE1, 0xF0,
1149 // flags 1120 // flags
1150 0x00, 1121 0x00,
1151 // fec group 1122 // fec group
1152 0x00, 1123 0x00,
1153 1124
1154 1125
1155 // frame count 1126 // frame count
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 } 1235 }
1265 1236
1266 TEST_F(QuicFramerTest, FecPacket) { 1237 TEST_F(QuicFramerTest, FecPacket) {
1267 unsigned char packet[] = { 1238 unsigned char packet[] = {
1268 // guid 1239 // guid
1269 0x10, 0x32, 0x54, 0x76, 1240 0x10, 0x32, 0x54, 0x76,
1270 0x98, 0xBA, 0xDC, 0xFE, 1241 0x98, 0xBA, 0xDC, 0xFE,
1271 // packet id 1242 // packet id
1272 0xBC, 0x9A, 0x78, 0x56, 1243 0xBC, 0x9A, 0x78, 0x56,
1273 0x34, 0x12, 1244 0x34, 0x12,
1274 // retransmission count
1275 0x01,
1276 // transmission time 1245 // transmission time
1277 0x87, 0x96, 0xA5, 0xB4, 1246 0x87, 0x96, 0xA5, 0xB4,
1278 0xC3, 0xD2, 0xE1, 0xF0, 1247 0xC3, 0xD2, 0xE1, 0xF0,
1279 // flags (FEC) 1248 // flags (FEC)
1280 0x01, 1249 0x01,
1281 // fec group 1250 // fec group
1282 0x01, 1251 0x01,
1283 1252
1284 // first protected packet 1253 // first protected packet
1285 0xBB, 0x9A, 0x78, 0x56, 1254 0xBB, 0x9A, 0x78, 0x56,
(...skipping 17 matching lines...) Expand all
1303 ASSERT_EQ(1, visitor_.fec_count_); 1272 ASSERT_EQ(1, visitor_.fec_count_);
1304 const QuicFecData& fec_data = *visitor_.fec_data_[0]; 1273 const QuicFecData& fec_data = *visitor_.fec_data_[0];
1305 EXPECT_EQ(GG_UINT64_C(0x0123456789ABB), 1274 EXPECT_EQ(GG_UINT64_C(0x0123456789ABB),
1306 fec_data.min_protected_packet_sequence_number); 1275 fec_data.min_protected_packet_sequence_number);
1307 EXPECT_EQ("abcdefghijklmnop", fec_data.redundancy); 1276 EXPECT_EQ("abcdefghijklmnop", fec_data.redundancy);
1308 } 1277 }
1309 1278
1310 TEST_F(QuicFramerTest, ConstructStreamFramePacket) { 1279 TEST_F(QuicFramerTest, ConstructStreamFramePacket) {
1311 QuicPacketHeader header; 1280 QuicPacketHeader header;
1312 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1281 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1313 header.retransmission_count = 0x01;
1314 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1282 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1315 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1283 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1316 header.flags = PACKET_FLAGS_NONE; 1284 header.flags = PACKET_FLAGS_NONE;
1317 header.fec_group = 0; 1285 header.fec_group = 0;
1318 1286
1319 QuicStreamFrame stream_frame; 1287 QuicStreamFrame stream_frame;
1320 stream_frame.stream_id = 0x01020304; 1288 stream_frame.stream_id = 0x01020304;
1321 stream_frame.fin = true; 1289 stream_frame.fin = true;
1322 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654); 1290 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654);
1323 stream_frame.data = "hello world!"; 1291 stream_frame.data = "hello world!";
1324 1292
1325 QuicFrame frame; 1293 QuicFrame frame;
1326 frame.type = STREAM_FRAME; 1294 frame.type = STREAM_FRAME;
1327 frame.stream_frame = &stream_frame; 1295 frame.stream_frame = &stream_frame;
1328 1296
1329 QuicFrames frames; 1297 QuicFrames frames;
1330 frames.push_back(frame); 1298 frames.push_back(frame);
1331 1299
1332 unsigned char packet[] = { 1300 unsigned char packet[] = {
1333 // guid 1301 // guid
1334 0x10, 0x32, 0x54, 0x76, 1302 0x10, 0x32, 0x54, 0x76,
1335 0x98, 0xBA, 0xDC, 0xFE, 1303 0x98, 0xBA, 0xDC, 0xFE,
1336 // packet id 1304 // packet id
1337 0xBC, 0x9A, 0x78, 0x56, 1305 0xBC, 0x9A, 0x78, 0x56,
1338 0x34, 0x12, 1306 0x34, 0x12,
1339 // retransmission count
1340 0x01,
1341 // transmission time 1307 // transmission time
1342 0x87, 0x96, 0xA5, 0xB4, 1308 0x87, 0x96, 0xA5, 0xB4,
1343 0xC3, 0xD2, 0xE1, 0xF0, 1309 0xC3, 0xD2, 0xE1, 0xF0,
1344 // flags 1310 // flags
1345 0x00, 1311 0x00,
1346 // fec group 1312 // fec group
1347 0x00, 1313 0x00,
1348 1314
1349 // frame count 1315 // frame count
1350 0x01, 1316 0x01,
1351 // frame type (stream frame) 1317 // frame type (stream frame)
1352 0x00, 1318 0x00,
1353 // stream id 1319 // stream id
1354 0x04, 0x03, 0x02, 0x01, 1320 0x04, 0x03, 0x02, 0x01,
1355 // fin 1321 // fin
1356 0x01, 1322 0x01,
1357 // offset 1323 // offset
1358 0x54, 0x76, 0x10, 0x32, 1324 0x54, 0x76, 0x10, 0x32,
1359 0xDC, 0xFE, 0x98, 0xBA, 1325 0xDC, 0xFE, 0x98, 0xBA,
1360 // data length 1326 // data length
1361 0x0c, 0x00, 1327 0x0c, 0x00,
1362 // data 1328 // data
1363 'h', 'e', 'l', 'l', 1329 'h', 'e', 'l', 'l',
1364 'o', ' ', 'w', 'o', 1330 'o', ' ', 'w', 'o',
1365 'r', 'l', 'd', '!', 1331 'r', 'l', 'd', '!',
1366 }; 1332 };
1367 1333
1368 QuicPacket* data; 1334 QuicPacket* data;
1369 ASSERT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1335 ASSERT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
1370 1336
1371 test::CompareCharArraysWithHexError("constructed packet", 1337 test::CompareCharArraysWithHexError("constructed packet",
1372 data->data(), data->length(), 1338 data->data(), data->length(),
1373 AsChars(packet), arraysize(packet)); 1339 AsChars(packet), arraysize(packet));
1374 1340
1375 delete data; 1341 delete data;
1376 } 1342 }
1377 1343
1378 TEST_F(QuicFramerTest, ConstructAckFramePacket) { 1344 TEST_F(QuicFramerTest, ConstructAckFramePacket) {
1379 QuicPacketHeader header; 1345 QuicPacketHeader header;
1380 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1346 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1381 header.retransmission_count = 0x01;
1382 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1347 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1383 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1348 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1384 header.flags = PACKET_FLAGS_NONE; 1349 header.flags = PACKET_FLAGS_NONE;
1385 header.fec_group = 0; 1350 header.fec_group = 0;
1386 1351
1387 QuicAckFrame ack_frame; 1352 QuicAckFrame ack_frame;
1388 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC); 1353 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC);
1389 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687); 1354 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687);
1390 ack_frame.received_info.missing_packets.insert( 1355 ack_frame.received_info.missing_packets.insert(
1391 GG_UINT64_C(0x0123456789ABB)); 1356 GG_UINT64_C(0x0123456789ABB));
(...skipping 15 matching lines...) Expand all
1407 QuicFrames frames; 1372 QuicFrames frames;
1408 frames.push_back(frame); 1373 frames.push_back(frame);
1409 1374
1410 unsigned char packet[] = { 1375 unsigned char packet[] = {
1411 // guid 1376 // guid
1412 0x10, 0x32, 0x54, 0x76, 1377 0x10, 0x32, 0x54, 0x76,
1413 0x98, 0xBA, 0xDC, 0xFE, 1378 0x98, 0xBA, 0xDC, 0xFE,
1414 // packet id 1379 // packet id
1415 0xBC, 0x9A, 0x78, 0x56, 1380 0xBC, 0x9A, 0x78, 0x56,
1416 0x34, 0x12, 1381 0x34, 0x12,
1417 // retransmission count
1418 0x01,
1419 // transmission time 1382 // transmission time
1420 0x87, 0x96, 0xA5, 0xB4, 1383 0x87, 0x96, 0xA5, 0xB4,
1421 0xC3, 0xD2, 0xE1, 0xF0, 1384 0xC3, 0xD2, 0xE1, 0xF0,
1422 // flags 1385 // flags
1423 0x00, 1386 0x00,
1424 // fec group 1387 // fec group
1425 0x00, 1388 0x00,
1426 1389
1427 // frame count 1390 // frame count
1428 0x01, 1391 0x01,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 0x34, 0x12, 1438 0x34, 0x12,
1476 // non retransmitting packet sequence number 1439 // non retransmitting packet sequence number
1477 0xB0, 0x9A, 0x78, 0x56, 1440 0xB0, 0x9A, 0x78, 0x56,
1478 0x34, 0x12, 1441 0x34, 0x12,
1479 #endif 1442 #endif
1480 // congestion feedback type (none) 1443 // congestion feedback type (none)
1481 0x00, 1444 0x00,
1482 }; 1445 };
1483 1446
1484 QuicPacket* data; 1447 QuicPacket* data;
1485 EXPECT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1448 EXPECT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
1486 1449
1487 test::CompareCharArraysWithHexError("constructed packet", 1450 test::CompareCharArraysWithHexError("constructed packet",
1488 data->data(), data->length(), 1451 data->data(), data->length(),
1489 AsChars(packet), arraysize(packet)); 1452 AsChars(packet), arraysize(packet));
1490 1453
1491 delete data; 1454 delete data;
1492 } 1455 }
1493 1456
1494 TEST_F(QuicFramerTest, ConstructAckFramePacketTCP) { 1457 TEST_F(QuicFramerTest, ConstructAckFramePacketTCP) {
1495 QuicPacketHeader header; 1458 QuicPacketHeader header;
1496 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1459 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1497 header.retransmission_count = 0x01;
1498 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1460 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1499 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1461 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1500 header.flags = PACKET_FLAGS_NONE; 1462 header.flags = PACKET_FLAGS_NONE;
1501 header.fec_group = 0; 1463 header.fec_group = 0;
1502 1464
1503 QuicAckFrame ack_frame; 1465 QuicAckFrame ack_frame;
1504 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC); 1466 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC);
1505 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687); 1467 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687);
1506 ack_frame.received_info.missing_packets.insert( 1468 ack_frame.received_info.missing_packets.insert(
1507 GG_UINT64_C(0x0123456789ABB)); 1469 GG_UINT64_C(0x0123456789ABB));
(...skipping 17 matching lines...) Expand all
1525 QuicFrames frames; 1487 QuicFrames frames;
1526 frames.push_back(frame); 1488 frames.push_back(frame);
1527 1489
1528 unsigned char packet[] = { 1490 unsigned char packet[] = {
1529 // guid 1491 // guid
1530 0x10, 0x32, 0x54, 0x76, 1492 0x10, 0x32, 0x54, 0x76,
1531 0x98, 0xBA, 0xDC, 0xFE, 1493 0x98, 0xBA, 0xDC, 0xFE,
1532 // packet id 1494 // packet id
1533 0xBC, 0x9A, 0x78, 0x56, 1495 0xBC, 0x9A, 0x78, 0x56,
1534 0x34, 0x12, 1496 0x34, 0x12,
1535 // retransmission count
1536 0x01,
1537 // transmission time 1497 // transmission time
1538 0x87, 0x96, 0xA5, 0xB4, 1498 0x87, 0x96, 0xA5, 0xB4,
1539 0xC3, 0xD2, 0xE1, 0xF0, 1499 0xC3, 0xD2, 0xE1, 0xF0,
1540 // flags 1500 // flags
1541 0x00, 1501 0x00,
1542 // fec group 1502 // fec group
1543 0x00, 1503 0x00,
1544 1504
1545 // frame count 1505 // frame count
1546 0x01, 1506 0x01,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 #endif 1557 #endif
1598 // congestion feedback type (tcp) 1558 // congestion feedback type (tcp)
1599 0x01, 1559 0x01,
1600 // ack_frame.congestion_info.tcp.accumulated_number_of_lost_packets 1560 // ack_frame.congestion_info.tcp.accumulated_number_of_lost_packets
1601 0x01, 0x02, 1561 0x01, 0x02,
1602 // ack_frame.congestion_info.tcp.receive_window 1562 // ack_frame.congestion_info.tcp.receive_window
1603 0x03, 0x04, 1563 0x03, 0x04,
1604 }; 1564 };
1605 1565
1606 QuicPacket* data; 1566 QuicPacket* data;
1607 EXPECT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1567 EXPECT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
1608 1568
1609 test::CompareCharArraysWithHexError("constructed packet", 1569 test::CompareCharArraysWithHexError("constructed packet",
1610 data->data(), data->length(), 1570 data->data(), data->length(),
1611 AsChars(packet), arraysize(packet)); 1571 AsChars(packet), arraysize(packet));
1612 1572
1613 delete data; 1573 delete data;
1614 } 1574 }
1615 1575
1616 TEST_F(QuicFramerTest, ConstructAckFramePacketInterArrival) { 1576 TEST_F(QuicFramerTest, ConstructAckFramePacketInterArrival) {
1617 QuicPacketHeader header; 1577 QuicPacketHeader header;
1618 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1578 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1619 header.retransmission_count = 0x01;
1620 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1579 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1621 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1580 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1622 header.flags = PACKET_FLAGS_NONE; 1581 header.flags = PACKET_FLAGS_NONE;
1623 header.fec_group = 0; 1582 header.fec_group = 0;
1624 1583
1625 QuicAckFrame ack_frame; 1584 QuicAckFrame ack_frame;
1626 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC); 1585 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC);
1627 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687); 1586 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687);
1628 ack_frame.received_info.missing_packets.insert( 1587 ack_frame.received_info.missing_packets.insert(
1629 GG_UINT64_C(0x0123456789ABB)); 1588 GG_UINT64_C(0x0123456789ABB));
(...skipping 19 matching lines...) Expand all
1649 QuicFrames frames; 1608 QuicFrames frames;
1650 frames.push_back(frame); 1609 frames.push_back(frame);
1651 1610
1652 unsigned char packet[] = { 1611 unsigned char packet[] = {
1653 // guid 1612 // guid
1654 0x10, 0x32, 0x54, 0x76, 1613 0x10, 0x32, 0x54, 0x76,
1655 0x98, 0xBA, 0xDC, 0xFE, 1614 0x98, 0xBA, 0xDC, 0xFE,
1656 // packet id 1615 // packet id
1657 0xBC, 0x9A, 0x78, 0x56, 1616 0xBC, 0x9A, 0x78, 0x56,
1658 0x34, 0x12, 1617 0x34, 0x12,
1659 // retransmission count
1660 0x01,
1661 // transmission time 1618 // transmission time
1662 0x87, 0x96, 0xA5, 0xB4, 1619 0x87, 0x96, 0xA5, 0xB4,
1663 0xC3, 0xD2, 0xE1, 0xF0, 1620 0xC3, 0xD2, 0xE1, 0xF0,
1664 // flags 1621 // flags
1665 0x00, 1622 0x00,
1666 // fec group 1623 // fec group
1667 0x00, 1624 0x00,
1668 1625
1669 // frame count 1626 // frame count
1670 0x01, 1627 0x01,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 0x02, 1680 0x02,
1724 // accumulated_number_of_lost_packets 1681 // accumulated_number_of_lost_packets
1725 0x02, 0x03, 1682 0x02, 0x03,
1726 // offset_time 1683 // offset_time
1727 0x04, 0x05, 1684 0x04, 0x05,
1728 // delta_time 1685 // delta_time
1729 0x06, 0x07, 1686 0x06, 0x07,
1730 }; 1687 };
1731 1688
1732 QuicPacket* data; 1689 QuicPacket* data;
1733 EXPECT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1690 EXPECT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
1734 1691
1735 test::CompareCharArraysWithHexError("constructed packet", 1692 test::CompareCharArraysWithHexError("constructed packet",
1736 data->data(), data->length(), 1693 data->data(), data->length(),
1737 AsChars(packet), arraysize(packet)); 1694 AsChars(packet), arraysize(packet));
1738 1695
1739 delete data; 1696 delete data;
1740 } 1697 }
1741 1698
1742 TEST_F(QuicFramerTest, ConstructAckFramePacketFixRate) { 1699 TEST_F(QuicFramerTest, ConstructAckFramePacketFixRate) {
1743 QuicPacketHeader header; 1700 QuicPacketHeader header;
1744 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1701 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1745 header.retransmission_count = 0x01;
1746 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1702 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1747 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1703 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1748 header.flags = PACKET_FLAGS_NONE; 1704 header.flags = PACKET_FLAGS_NONE;
1749 header.fec_group = 0; 1705 header.fec_group = 0;
1750 1706
1751 QuicAckFrame ack_frame; 1707 QuicAckFrame ack_frame;
1752 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC); 1708 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC);
1753 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687); 1709 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687);
1754 ack_frame.received_info.missing_packets.insert( 1710 ack_frame.received_info.missing_packets.insert(
1755 GG_UINT64_C(0x0123456789ABB)); 1711 GG_UINT64_C(0x0123456789ABB));
(...skipping 17 matching lines...) Expand all
1773 QuicFrames frames; 1729 QuicFrames frames;
1774 frames.push_back(frame); 1730 frames.push_back(frame);
1775 1731
1776 unsigned char packet[] = { 1732 unsigned char packet[] = {
1777 // guid 1733 // guid
1778 0x10, 0x32, 0x54, 0x76, 1734 0x10, 0x32, 0x54, 0x76,
1779 0x98, 0xBA, 0xDC, 0xFE, 1735 0x98, 0xBA, 0xDC, 0xFE,
1780 // packet id 1736 // packet id
1781 0xBC, 0x9A, 0x78, 0x56, 1737 0xBC, 0x9A, 0x78, 0x56,
1782 0x34, 0x12, 1738 0x34, 0x12,
1783 // retransmission count
1784 0x01,
1785 // transmission time 1739 // transmission time
1786 0x87, 0x96, 0xA5, 0xB4, 1740 0x87, 0x96, 0xA5, 0xB4,
1787 0xC3, 0xD2, 0xE1, 0xF0, 1741 0xC3, 0xD2, 0xE1, 0xF0,
1788 // flags 1742 // flags
1789 0x00, 1743 0x00,
1790 // fec group 1744 // fec group
1791 0x00, 1745 0x00,
1792 1746
1793 // frame count 1747 // frame count
1794 0x01, 1748 0x01,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 0xB0, 0x9A, 0x78, 0x56, 1797 0xB0, 0x9A, 0x78, 0x56,
1844 0x34, 0x12, 1798 0x34, 0x12,
1845 #endif 1799 #endif
1846 // congestion feedback type (fix rate) 1800 // congestion feedback type (fix rate)
1847 0x03, 1801 0x03,
1848 // bitrate_in_bytes_per_second; 1802 // bitrate_in_bytes_per_second;
1849 0x01, 0x02, 0x03, 0x04, 1803 0x01, 0x02, 0x03, 0x04,
1850 }; 1804 };
1851 1805
1852 QuicPacket* data; 1806 QuicPacket* data;
1853 EXPECT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1807 EXPECT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
1854 1808
1855 test::CompareCharArraysWithHexError("constructed packet", 1809 test::CompareCharArraysWithHexError("constructed packet",
1856 data->data(), data->length(), 1810 data->data(), data->length(),
1857 AsChars(packet), arraysize(packet)); 1811 AsChars(packet), arraysize(packet));
1858 1812
1859 delete data; 1813 delete data;
1860 } 1814 }
1861 1815
1862 TEST_F(QuicFramerTest, ConstructAckFramePacketInvalidFeedback) { 1816 TEST_F(QuicFramerTest, ConstructAckFramePacketInvalidFeedback) {
1863 QuicPacketHeader header; 1817 QuicPacketHeader header;
1864 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1818 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1865 header.retransmission_count = 0x01;
1866 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1819 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1867 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1820 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1868 header.flags = PACKET_FLAGS_NONE; 1821 header.flags = PACKET_FLAGS_NONE;
1869 header.fec_group = 0; 1822 header.fec_group = 0;
1870 1823
1871 QuicAckFrame ack_frame; 1824 QuicAckFrame ack_frame;
1872 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC); 1825 ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABC);
1873 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687); 1826 ack_frame.received_info.time_received = GG_UINT64_C(0xF0E1D2C3B4A59687);
1874 ack_frame.received_info.missing_packets.insert( 1827 ack_frame.received_info.missing_packets.insert(
1875 GG_UINT64_C(0x0123456789ABB)); 1828 GG_UINT64_C(0x0123456789ABB));
(...skipping 10 matching lines...) Expand all
1886 static_cast<CongestionFeedbackType>(kFixRate + 1); 1839 static_cast<CongestionFeedbackType>(kFixRate + 1);
1887 1840
1888 QuicFrame frame; 1841 QuicFrame frame;
1889 frame.type = ACK_FRAME; 1842 frame.type = ACK_FRAME;
1890 frame.ack_frame = &ack_frame; 1843 frame.ack_frame = &ack_frame;
1891 1844
1892 QuicFrames frames; 1845 QuicFrames frames;
1893 frames.push_back(frame); 1846 frames.push_back(frame);
1894 1847
1895 QuicPacket* data; 1848 QuicPacket* data;
1896 EXPECT_FALSE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1849 EXPECT_FALSE(framer_.ConstructFrameDataPacket(header, frames, &data));
1897 } 1850 }
1898 1851
1899 TEST_F(QuicFramerTest, ConstructRstFramePacket) { 1852 TEST_F(QuicFramerTest, ConstructRstFramePacket) {
1900 QuicPacketHeader header; 1853 QuicPacketHeader header;
1901 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1854 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1902 header.retransmission_count = 0x01;
1903 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1855 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1904 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1856 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1905 header.flags = PACKET_FLAGS_NONE; 1857 header.flags = PACKET_FLAGS_NONE;
1906 header.fec_group = 0; 1858 header.fec_group = 0;
1907 1859
1908 QuicRstStreamFrame rst_frame; 1860 QuicRstStreamFrame rst_frame;
1909 rst_frame.stream_id = 0x01020304; 1861 rst_frame.stream_id = 0x01020304;
1910 rst_frame.error_code = static_cast<QuicErrorCode>(0x05060708); 1862 rst_frame.error_code = static_cast<QuicErrorCode>(0x05060708);
1911 rst_frame.offset = GG_UINT64_C(0xBA98FEDC32107654); 1863 rst_frame.offset = GG_UINT64_C(0xBA98FEDC32107654);
1912 rst_frame.error_details = "because I can"; 1864 rst_frame.error_details = "because I can";
1913 1865
1914 unsigned char packet[] = { 1866 unsigned char packet[] = {
1915 // guid 1867 // guid
1916 0x10, 0x32, 0x54, 0x76, 1868 0x10, 0x32, 0x54, 0x76,
1917 0x98, 0xBA, 0xDC, 0xFE, 1869 0x98, 0xBA, 0xDC, 0xFE,
1918 // packet id 1870 // packet id
1919 0xBC, 0x9A, 0x78, 0x56, 1871 0xBC, 0x9A, 0x78, 0x56,
1920 0x34, 0x12, 1872 0x34, 0x12,
1921 // retransmission count
1922 0x01,
1923 // transmission time 1873 // transmission time
1924 0x87, 0x96, 0xA5, 0xB4, 1874 0x87, 0x96, 0xA5, 0xB4,
1925 0xC3, 0xD2, 0xE1, 0xF0, 1875 0xC3, 0xD2, 0xE1, 0xF0,
1926 // flags 1876 // flags
1927 0x00, 1877 0x00,
1928 // fec group 1878 // fec group
1929 0x00, 1879 0x00,
1930 1880
1931 // frame count 1881 // frame count
1932 0x01, 1882 0x01,
(...skipping 14 matching lines...) Expand all
1947 'I', ' ', 'c', 'a', 1897 'I', ' ', 'c', 'a',
1948 'n', 1898 'n',
1949 }; 1899 };
1950 1900
1951 QuicFrame frame(&rst_frame); 1901 QuicFrame frame(&rst_frame);
1952 1902
1953 QuicFrames frames; 1903 QuicFrames frames;
1954 frames.push_back(frame); 1904 frames.push_back(frame);
1955 1905
1956 QuicPacket* data; 1906 QuicPacket* data;
1957 EXPECT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 1907 EXPECT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
1958 1908
1959 test::CompareCharArraysWithHexError("constructed packet", 1909 test::CompareCharArraysWithHexError("constructed packet",
1960 data->data(), data->length(), 1910 data->data(), data->length(),
1961 AsChars(packet), arraysize(packet)); 1911 AsChars(packet), arraysize(packet));
1962 1912
1963 delete data; 1913 delete data;
1964 } 1914 }
1965 1915
1966 TEST_F(QuicFramerTest, ConstructCloseFramePacket) { 1916 TEST_F(QuicFramerTest, ConstructCloseFramePacket) {
1967 QuicPacketHeader header; 1917 QuicPacketHeader header;
1968 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1918 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1969 header.retransmission_count = 0x01;
1970 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1919 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1971 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 1920 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
1972 header.flags = PACKET_FLAGS_NONE; 1921 header.flags = PACKET_FLAGS_NONE;
1973 header.fec_group = 0; 1922 header.fec_group = 0;
1974 1923
1975 QuicConnectionCloseFrame close_frame; 1924 QuicConnectionCloseFrame close_frame;
1976 close_frame.error_code = static_cast<QuicErrorCode>(0x05060708); 1925 close_frame.error_code = static_cast<QuicErrorCode>(0x05060708);
1977 close_frame.error_details = "because I can"; 1926 close_frame.error_details = "because I can";
1978 1927
1979 QuicAckFrame* ack_frame = &close_frame.ack_frame; 1928 QuicAckFrame* ack_frame = &close_frame.ack_frame;
(...skipping 21 matching lines...) Expand all
2001 QuicFrames frames; 1950 QuicFrames frames;
2002 frames.push_back(frame); 1951 frames.push_back(frame);
2003 1952
2004 unsigned char packet[] = { 1953 unsigned char packet[] = {
2005 // guid 1954 // guid
2006 0x10, 0x32, 0x54, 0x76, 1955 0x10, 0x32, 0x54, 0x76,
2007 0x98, 0xBA, 0xDC, 0xFE, 1956 0x98, 0xBA, 0xDC, 0xFE,
2008 // packet id 1957 // packet id
2009 0xBC, 0x9A, 0x78, 0x56, 1958 0xBC, 0x9A, 0x78, 0x56,
2010 0x34, 0x12, 1959 0x34, 0x12,
2011 // retransmission count
2012 0x01,
2013 // transmission time 1960 // transmission time
2014 0x87, 0x96, 0xA5, 0xB4, 1961 0x87, 0x96, 0xA5, 0xB4,
2015 0xC3, 0xD2, 0xE1, 0xF0, 1962 0xC3, 0xD2, 0xE1, 0xF0,
2016 // flags 1963 // flags
2017 0x00, 1964 0x00,
2018 // fec group 1965 // fec group
2019 0x00, 1966 0x00,
2020 1967
2021 // frame count 1968 // frame count
2022 0x01, 1969 0x01,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 0x02, 2034 0x02,
2088 // accumulated_number_of_lost_packets 2035 // accumulated_number_of_lost_packets
2089 0x02, 0x03, 2036 0x02, 0x03,
2090 // offset_time 2037 // offset_time
2091 0x04, 0x05, 2038 0x04, 0x05,
2092 // delta_time 2039 // delta_time
2093 0x06, 0x07, 2040 0x06, 0x07,
2094 }; 2041 };
2095 2042
2096 QuicPacket* data; 2043 QuicPacket* data;
2097 EXPECT_TRUE(framer_.ConstructFragementDataPacket(header, frames, &data)); 2044 EXPECT_TRUE(framer_.ConstructFrameDataPacket(header, frames, &data));
2098 2045
2099 test::CompareCharArraysWithHexError("constructed packet", 2046 test::CompareCharArraysWithHexError("constructed packet",
2100 data->data(), data->length(), 2047 data->data(), data->length(),
2101 AsChars(packet), arraysize(packet)); 2048 AsChars(packet), arraysize(packet));
2102 2049
2103 delete data; 2050 delete data;
2104 } 2051 }
2105 2052
2106 TEST_F(QuicFramerTest, ConstructFecPacket) { 2053 TEST_F(QuicFramerTest, ConstructFecPacket) {
2107 QuicPacketHeader header; 2054 QuicPacketHeader header;
2108 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 2055 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
2109 header.retransmission_count = 0x01;
2110 header.packet_sequence_number = (GG_UINT64_C(0x123456789ABC)); 2056 header.packet_sequence_number = (GG_UINT64_C(0x123456789ABC));
2111 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687); 2057 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
2112 header.flags = PACKET_FLAGS_FEC; 2058 header.flags = PACKET_FLAGS_FEC;
2113 header.fec_group = 1; 2059 header.fec_group = 1;
2114 2060
2115 QuicFecData fec_data; 2061 QuicFecData fec_data;
2116 fec_data.fec_group = 1; 2062 fec_data.fec_group = 1;
2117 fec_data.min_protected_packet_sequence_number = 2063 fec_data.min_protected_packet_sequence_number =
2118 GG_UINT64_C(0x123456789ABB); 2064 GG_UINT64_C(0x123456789ABB);
2119 fec_data.redundancy = "abcdefghijklmnop"; 2065 fec_data.redundancy = "abcdefghijklmnop";
2120 2066
2121 unsigned char packet[] = { 2067 unsigned char packet[] = {
2122 // guid 2068 // guid
2123 0x10, 0x32, 0x54, 0x76, 2069 0x10, 0x32, 0x54, 0x76,
2124 0x98, 0xBA, 0xDC, 0xFE, 2070 0x98, 0xBA, 0xDC, 0xFE,
2125 // packet id 2071 // packet id
2126 0xBC, 0x9A, 0x78, 0x56, 2072 0xBC, 0x9A, 0x78, 0x56,
2127 0x34, 0x12, 2073 0x34, 0x12,
2128 // retransmission count
2129 0x01,
2130 // transmission time 2074 // transmission time
2131 0x87, 0x96, 0xA5, 0xB4, 2075 0x87, 0x96, 0xA5, 0xB4,
2132 0xC3, 0xD2, 0xE1, 0xF0, 2076 0xC3, 0xD2, 0xE1, 0xF0,
2133 // flags 2077 // flags
2134 0x01, 2078 0x01,
2135 // fec group 2079 // fec group
2136 0x01, 2080 0x01,
2137 // first protected packet 2081 // first protected packet
2138 0xBB, 0x9A, 0x78, 0x56, 2082 0xBB, 0x9A, 0x78, 0x56,
2139 0x34, 0x12, 2083 0x34, 0x12,
2140 // redundancy 2084 // redundancy
2141 'a', 'b', 'c', 'd', 2085 'a', 'b', 'c', 'd',
2142 'e', 'f', 'g', 'h', 2086 'e', 'f', 'g', 'h',
2143 'i', 'j', 'k', 'l', 2087 'i', 'j', 'k', 'l',
2144 'm', 'n', 'o', 'p', 2088 'm', 'n', 'o', 'p',
2145 }; 2089 };
2146 2090
2147 QuicPacket* data; 2091 QuicPacket* data;
2148 EXPECT_TRUE(framer_.ConstructFecPacket(header, fec_data, &data)); 2092 EXPECT_TRUE(framer_.ConstructFecPacket(header, fec_data, &data));
2149 2093
2150 test::CompareCharArraysWithHexError("constructed packet", 2094 test::CompareCharArraysWithHexError("constructed packet",
2151 data->data(), data->length(), 2095 data->data(), data->length(),
2152 AsChars(packet), arraysize(packet)); 2096 AsChars(packet), arraysize(packet));
2153 2097
2154 delete data; 2098 delete data;
2155 } 2099 }
2156 2100
2157 TEST_F(QuicFramerTest, IncrementRetransmitCount) {
2158 QuicPacketHeader header;
2159 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
2160 header.retransmission_count = 1;
2161 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
2162 header.transmission_time = GG_UINT64_C(0xF0E1D2C3B4A59687);
2163 header.flags = PACKET_FLAGS_NONE;
2164 header.fec_group = 0;
2165
2166 QuicStreamFrame stream_frame;
2167 stream_frame.stream_id = 0x01020304;
2168 stream_frame.fin = true;
2169 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654);
2170 stream_frame.data = "hello world!";
2171
2172 QuicFrame frame;
2173 frame.type = STREAM_FRAME;
2174 frame.stream_frame = &stream_frame;
2175
2176 QuicFrames frames;
2177 frames.push_back(frame);
2178
2179 QuicPacket *original;
2180 ASSERT_TRUE(framer_.ConstructFragementDataPacket(
2181 header, frames, &original));
2182 EXPECT_EQ(header.retransmission_count, framer_.GetRetransmitCount(original));
2183
2184 header.retransmission_count = 2;
2185 QuicPacket *retransmitted;
2186 ASSERT_TRUE(framer_.ConstructFragementDataPacket(
2187 header, frames, &retransmitted));
2188
2189 framer_.IncrementRetransmitCount(original);
2190 EXPECT_EQ(header.retransmission_count, framer_.GetRetransmitCount(original));
2191
2192 test::CompareCharArraysWithHexError(
2193 "constructed packet", original->data(), original->length(),
2194 retransmitted->data(), retransmitted->length());
2195 delete original;
2196 delete retransmitted;
2197 }
2198
2199 TEST_F(QuicFramerTest, EncryptPacket) { 2101 TEST_F(QuicFramerTest, EncryptPacket) {
2200 unsigned char packet[] = { 2102 unsigned char packet[] = {
2201 // guid 2103 // guid
2202 0x10, 0x32, 0x54, 0x76, 2104 0x10, 0x32, 0x54, 0x76,
2203 0x98, 0xBA, 0xDC, 0xFE, 2105 0x98, 0xBA, 0xDC, 0xFE,
2204 // packet id 2106 // packet id
2205 0xBC, 0x9A, 0x78, 0x56, 2107 0xBC, 0x9A, 0x78, 0x56,
2206 0x34, 0x12, 2108 0x34, 0x12,
2207 // retransmission count
2208 0x01,
2209 // transmission time 2109 // transmission time
2210 0x87, 0x96, 0xA5, 0xB4, 2110 0x87, 0x96, 0xA5, 0xB4,
2211 0xC3, 0xD2, 0xE1, 0xF0, 2111 0xC3, 0xD2, 0xE1, 0xF0,
2212 // flags 2112 // flags
2213 0x01, 2113 0x01,
2214 // fec group 2114 // fec group
2215 0x01, 2115 0x01,
2216 // first protected packet 2116 // first protected packet
2217 0xBB, 0x9A, 0x78, 0x56, 2117 0xBB, 0x9A, 0x78, 0x56,
2218 0x34, 0x12, 2118 0x34, 0x12,
2219 // redundancy 2119 // redundancy
2220 'a', 'b', 'c', 'd', 2120 'a', 'b', 'c', 'd',
2221 'e', 'f', 'g', 'h', 2121 'e', 'f', 'g', 'h',
2222 'i', 'j', 'k', 'l', 2122 'i', 'j', 'k', 'l',
2223 'm', 'n', 'o', 'p', 2123 'm', 'n', 'o', 'p',
2224 }; 2124 };
2225 2125
2226 QuicPacket raw(AsChars(packet), arraysize(packet), false); 2126 QuicPacket raw(AsChars(packet), arraysize(packet), false, PACKET_FLAGS_NONE);
2227 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(raw)); 2127 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(raw));
2228 2128
2229 ASSERT_TRUE(encrypted.get() != NULL); 2129 ASSERT_TRUE(encrypted.get() != NULL);
2230 EXPECT_TRUE(CheckEncryption(StringPiece(AsChars(packet), arraysize(packet)))); 2130 EXPECT_TRUE(CheckEncryption(StringPiece(AsChars(packet), arraysize(packet))));
2231 } 2131 }
2232 2132
2233 } // namespace test 2133 } // namespace test
2234 2134
2235 } // namespace net 2135 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698