OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/core/quic_packet_creator.h" | 5 #include "net/quic/core/quic_packet_creator.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 EXPECT_EQ(stream_id, frame.stream_frame->stream_id); | 171 EXPECT_EQ(stream_id, frame.stream_frame->stream_id); |
172 EXPECT_EQ(data, StringPiece(frame.stream_frame->data_buffer, | 172 EXPECT_EQ(data, StringPiece(frame.stream_frame->data_buffer, |
173 frame.stream_frame->data_length)); | 173 frame.stream_frame->data_length)); |
174 EXPECT_EQ(offset, frame.stream_frame->offset); | 174 EXPECT_EQ(offset, frame.stream_frame->offset); |
175 EXPECT_EQ(fin, frame.stream_frame->fin); | 175 EXPECT_EQ(fin, frame.stream_frame->fin); |
176 } | 176 } |
177 | 177 |
178 // Returns the number of bytes consumed by the header of packet, including | 178 // Returns the number of bytes consumed by the header of packet, including |
179 // the version. | 179 // the version. |
180 size_t GetPacketHeaderOverhead(QuicVersion version) { | 180 size_t GetPacketHeaderOverhead(QuicVersion version) { |
181 if (FLAGS_quic_simple_packet_number_length) { | 181 if (FLAGS_quic_simple_packet_number_length_2) { |
182 return GetPacketHeaderSize( | 182 return GetPacketHeaderSize( |
183 version, creator_.connection_id_length(), kIncludeVersion, | 183 version, creator_.connection_id_length(), kIncludeVersion, |
184 !kIncludePathId, !kIncludeDiversificationNonce, | 184 !kIncludePathId, !kIncludeDiversificationNonce, |
185 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 185 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
186 } else { | 186 } else { |
187 return GetPacketHeaderSize( | 187 return GetPacketHeaderSize( |
188 version, creator_.connection_id_length(), kIncludeVersion, | 188 version, creator_.connection_id_length(), kIncludeVersion, |
189 !kIncludePathId, !kIncludeDiversificationNonce, | 189 !kIncludePathId, !kIncludeDiversificationNonce, |
190 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 190 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
191 } | 191 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 EXPECT_CALL(framer_visitor_, OnAckFrame(_)); | 272 EXPECT_CALL(framer_visitor_, OnAckFrame(_)); |
273 EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); | 273 EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
274 EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); | 274 EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
275 EXPECT_CALL(framer_visitor_, OnPacketComplete()); | 275 EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
276 } | 276 } |
277 ProcessPacket(serialized); | 277 ProcessPacket(serialized); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) { | 281 TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) { |
282 FLAGS_quic_simple_packet_number_length = false; | 282 FLAGS_quic_simple_packet_number_length_2 = false; |
283 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u)))); | 283 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u)))); |
284 creator_.AddSavedFrame(frames_[0]); | 284 creator_.AddSavedFrame(frames_[0]); |
285 QuicPacketCreatorPeer::SetNextPacketNumberLength(&creator_, | 285 QuicPacketCreatorPeer::SetNextPacketNumberLength(&creator_, |
286 PACKET_4BYTE_PACKET_NUMBER); | 286 PACKET_4BYTE_PACKET_NUMBER); |
287 | 287 |
288 EXPECT_CALL(delegate_, OnSerializedPacket(_)) | 288 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
289 .WillRepeatedly( | 289 .WillRepeatedly( |
290 Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); | 290 Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); |
291 creator_.Flush(); | 291 creator_.Flush(); |
292 // The packet number length will not change mid-packet. | 292 // The packet number length will not change mid-packet. |
(...skipping 28 matching lines...) Expand all Loading... |
321 EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); | 321 EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); |
322 EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); | 322 EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); |
323 EXPECT_CALL(framer_visitor_, OnAckFrame(_)); | 323 EXPECT_CALL(framer_visitor_, OnAckFrame(_)); |
324 EXPECT_CALL(framer_visitor_, OnPacketComplete()); | 324 EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
325 } | 325 } |
326 ProcessPacket(serialized_packet_); | 326 ProcessPacket(serialized_packet_); |
327 DeleteSerializedPacket(); | 327 DeleteSerializedPacket(); |
328 } | 328 } |
329 | 329 |
330 TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) { | 330 TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) { |
331 FLAGS_quic_simple_packet_number_length = false; | 331 FLAGS_quic_simple_packet_number_length_2 = false; |
332 // Changing the packet number length with queued frames in the creator | 332 // Changing the packet number length with queued frames in the creator |
333 // should hold the change until after any currently queued frames are | 333 // should hold the change until after any currently queued frames are |
334 // serialized. | 334 // serialized. |
335 | 335 |
336 // Packet 1. | 336 // Packet 1. |
337 // Queue a frame in the creator. | 337 // Queue a frame in the creator. |
338 EXPECT_FALSE(creator_.HasPendingFrames()); | 338 EXPECT_FALSE(creator_.HasPendingFrames()); |
339 QuicFrame ack_frame = QuicFrame(new QuicAckFrame(MakeAckFrame(0u))); | 339 QuicFrame ack_frame = QuicFrame(new QuicAckFrame(MakeAckFrame(0u))); |
340 creator_.AddSavedFrame(ack_frame); | 340 creator_.AddSavedFrame(ack_frame); |
341 | 341 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 ProcessPacket(serialized_packet_); | 405 ProcessPacket(serialized_packet_); |
406 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, | 406 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
407 header.public_header.packet_number_length); | 407 header.public_header.packet_number_length); |
408 | 408 |
409 DeleteSerializedPacket(); | 409 DeleteSerializedPacket(); |
410 delete ack_frame.ack_frame; | 410 delete ack_frame.ack_frame; |
411 } | 411 } |
412 | 412 |
413 TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacketDoesNothing) { | 413 TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacketDoesNothing) { |
414 FLAGS_quic_simple_packet_number_length = true; | 414 FLAGS_quic_simple_packet_number_length_2 = true; |
415 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 415 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
416 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 416 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
417 // Changing the packet number length with queued frames in the creator | 417 // Changing the packet number length with queued frames in the creator |
418 // should do nothing. | 418 // should do nothing. |
419 EXPECT_FALSE(creator_.HasPendingFrames()); | 419 EXPECT_FALSE(creator_.HasPendingFrames()); |
420 QuicFrame ack_frame = QuicFrame(new QuicAckFrame(MakeAckFrame(0u))); | 420 QuicFrame ack_frame = QuicFrame(new QuicAckFrame(MakeAckFrame(0u))); |
421 creator_.AddSavedFrame(ack_frame); | 421 creator_.AddSavedFrame(ack_frame); |
422 | 422 |
423 // Now change packet number length and expect a QUIC_BUG and no change in | 423 // Now change packet number length and expect a QUIC_BUG and no change in |
424 // packet number length. | 424 // packet number length. |
425 EXPECT_QUIC_BUG(creator_.UpdatePacketNumberLength(0, 256), | 425 EXPECT_QUIC_BUG(creator_.UpdatePacketNumberLength(0, 256), |
426 "Called UpdatePacketNumberLength with 1 queued_frames."); | 426 "Called UpdatePacketNumberLength with 1 queued_frames."); |
427 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 427 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
428 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 428 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
429 delete ack_frame.ack_frame; | 429 delete ack_frame.ack_frame; |
430 } | 430 } |
431 | 431 |
432 TEST_P(QuicPacketCreatorTest, ReserializeFramesWithSequenceNumberLength) { | 432 TEST_P(QuicPacketCreatorTest, ReserializeFramesWithSequenceNumberLength) { |
433 // If the original packet number length, the current packet number | 433 // If the original packet number length, the current packet number |
434 // length, and the configured send packet number length are different, the | 434 // length, and the configured send packet number length are different, the |
435 // retransmit must sent with the original length and the others do not change. | 435 // retransmit must sent with the original length and the others do not change. |
436 if (!FLAGS_quic_simple_packet_number_length) { | 436 if (!FLAGS_quic_simple_packet_number_length_2) { |
437 QuicPacketCreatorPeer::SetNextPacketNumberLength( | 437 QuicPacketCreatorPeer::SetNextPacketNumberLength( |
438 &creator_, PACKET_4BYTE_PACKET_NUMBER); | 438 &creator_, PACKET_4BYTE_PACKET_NUMBER); |
439 } | 439 } |
440 QuicPacketCreatorPeer::SetPacketNumberLength(&creator_, | 440 QuicPacketCreatorPeer::SetPacketNumberLength(&creator_, |
441 PACKET_2BYTE_PACKET_NUMBER); | 441 PACKET_2BYTE_PACKET_NUMBER); |
442 QuicStreamFrame* stream_frame = | 442 QuicStreamFrame* stream_frame = |
443 new QuicStreamFrame(kCryptoStreamId, /*fin=*/false, 0u, StringPiece()); | 443 new QuicStreamFrame(kCryptoStreamId, /*fin=*/false, 0u, StringPiece()); |
444 QuicFrames frames; | 444 QuicFrames frames; |
445 frames.push_back(QuicFrame(stream_frame)); | 445 frames.push_back(QuicFrame(stream_frame)); |
446 char buffer[kMaxPacketSize]; | 446 char buffer[kMaxPacketSize]; |
447 PendingRetransmission retransmission(CreateRetransmission( | 447 PendingRetransmission retransmission(CreateRetransmission( |
448 frames, true /* has_crypto_handshake */, -1 /* needs full padding */, | 448 frames, true /* has_crypto_handshake */, -1 /* needs full padding */, |
449 ENCRYPTION_NONE, PACKET_1BYTE_PACKET_NUMBER)); | 449 ENCRYPTION_NONE, PACKET_1BYTE_PACKET_NUMBER)); |
450 EXPECT_CALL(delegate_, OnSerializedPacket(_)) | 450 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
451 .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); | 451 .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); |
452 creator_.ReserializeAllFrames(retransmission, buffer, kMaxPacketSize); | 452 creator_.ReserializeAllFrames(retransmission, buffer, kMaxPacketSize); |
453 if (FLAGS_quic_simple_packet_number_length) { | 453 if (FLAGS_quic_simple_packet_number_length_2) { |
454 // The packet number length is updated after every packet is sent, | 454 // The packet number length is updated after every packet is sent, |
455 // so there is no need to restore the old length after sending. | 455 // so there is no need to restore the old length after sending. |
456 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 456 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
457 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 457 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
458 } else { | 458 } else { |
459 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, | 459 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
460 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 460 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
461 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 461 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
462 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 462 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
463 } | 463 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 542 |
543 const int kNumPaddingBytes1 = 4; | 543 const int kNumPaddingBytes1 = 4; |
544 int packet_size = 0; | 544 int packet_size = 0; |
545 { | 545 { |
546 QuicFrames frames; | 546 QuicFrames frames; |
547 frames.push_back(frame); | 547 frames.push_back(frame); |
548 char buffer[kMaxPacketSize]; | 548 char buffer[kMaxPacketSize]; |
549 PendingRetransmission retransmission(CreateRetransmission( | 549 PendingRetransmission retransmission(CreateRetransmission( |
550 frames, false /* has_crypto_handshake */, | 550 frames, false /* has_crypto_handshake */, |
551 kNumPaddingBytes1 /* padding bytes */, ENCRYPTION_NONE, | 551 kNumPaddingBytes1 /* padding bytes */, ENCRYPTION_NONE, |
552 FLAGS_quic_simple_packet_number_length | 552 FLAGS_quic_simple_packet_number_length_2 |
553 ? QuicPacketCreatorPeer::GetPacketNumberLength(&creator_) | 553 ? QuicPacketCreatorPeer::GetPacketNumberLength(&creator_) |
554 : QuicPacketCreatorPeer::NextPacketNumberLength(&creator_))); | 554 : QuicPacketCreatorPeer::NextPacketNumberLength(&creator_))); |
555 EXPECT_CALL(delegate_, OnSerializedPacket(_)) | 555 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
556 .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); | 556 .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); |
557 creator_.ReserializeAllFrames(retransmission, buffer, kMaxPacketSize); | 557 creator_.ReserializeAllFrames(retransmission, buffer, kMaxPacketSize); |
558 packet_size = serialized_packet_.encrypted_length; | 558 packet_size = serialized_packet_.encrypted_length; |
559 } | 559 } |
560 | 560 |
561 const int kNumPaddingBytes2 = 44; | 561 const int kNumPaddingBytes2 = 44; |
562 QuicFrames frames; | 562 QuicFrames frames; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 InSequence s; | 804 InSequence s; |
805 EXPECT_CALL(framer_visitor_, OnPacket()); | 805 EXPECT_CALL(framer_visitor_, OnPacket()); |
806 EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); | 806 EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); |
807 EXPECT_CALL(framer_visitor_, OnVersionNegotiationPacket(_)); | 807 EXPECT_CALL(framer_visitor_, OnVersionNegotiationPacket(_)); |
808 } | 808 } |
809 QuicFramerPeer::SetPerspective(&client_framer_, Perspective::IS_CLIENT); | 809 QuicFramerPeer::SetPerspective(&client_framer_, Perspective::IS_CLIENT); |
810 client_framer_.ProcessPacket(*encrypted); | 810 client_framer_.ProcessPacket(*encrypted); |
811 } | 811 } |
812 | 812 |
813 TEST_P(QuicPacketCreatorTest, UpdatePacketNumberLengthLeastAwaiting_Old) { | 813 TEST_P(QuicPacketCreatorTest, UpdatePacketNumberLengthLeastAwaiting_Old) { |
814 FLAGS_quic_simple_packet_number_length = false; | 814 FLAGS_quic_simple_packet_number_length_2 = false; |
815 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 815 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
816 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 816 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
817 | 817 |
818 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64); | 818 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64); |
819 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 819 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
820 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 820 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
821 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 821 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
822 | 822 |
823 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256); | 823 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256); |
824 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 824 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
825 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 825 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
826 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 826 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
827 | 827 |
828 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256 * 256); | 828 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256 * 256); |
829 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 829 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
830 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, | 830 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
831 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 831 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
832 | 832 |
833 QuicPacketCreatorPeer::SetPacketNumber(&creator_, | 833 QuicPacketCreatorPeer::SetPacketNumber(&creator_, |
834 UINT64_C(64) * 256 * 256 * 256 * 256); | 834 UINT64_C(64) * 256 * 256 * 256 * 256); |
835 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 835 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
836 EXPECT_EQ(PACKET_6BYTE_PACKET_NUMBER, | 836 EXPECT_EQ(PACKET_6BYTE_PACKET_NUMBER, |
837 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 837 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
838 } | 838 } |
839 | 839 |
840 TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthBandwidth_old) { | 840 TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthBandwidth_old) { |
841 FLAGS_quic_simple_packet_number_length = false; | 841 FLAGS_quic_simple_packet_number_length_2 = false; |
842 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 842 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
843 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 843 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
844 | 844 |
845 creator_.UpdatePacketNumberLength(1, 10000 / kDefaultMaxPacketSize); | 845 creator_.UpdatePacketNumberLength(1, 10000 / kDefaultMaxPacketSize); |
846 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 846 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
847 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 847 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
848 | 848 |
849 creator_.UpdatePacketNumberLength(1, 10000 * 256 / kDefaultMaxPacketSize); | 849 creator_.UpdatePacketNumberLength(1, 10000 * 256 / kDefaultMaxPacketSize); |
850 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 850 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
851 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 851 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
852 | 852 |
853 creator_.UpdatePacketNumberLength(1, | 853 creator_.UpdatePacketNumberLength(1, |
854 10000 * 256 * 256 / kDefaultMaxPacketSize); | 854 10000 * 256 * 256 / kDefaultMaxPacketSize); |
855 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, | 855 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
856 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 856 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
857 | 857 |
858 creator_.UpdatePacketNumberLength( | 858 creator_.UpdatePacketNumberLength( |
859 1, UINT64_C(1000) * 256 * 256 * 256 * 256 / kDefaultMaxPacketSize); | 859 1, UINT64_C(1000) * 256 * 256 * 256 * 256 / kDefaultMaxPacketSize); |
860 EXPECT_EQ(PACKET_6BYTE_PACKET_NUMBER, | 860 EXPECT_EQ(PACKET_6BYTE_PACKET_NUMBER, |
861 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 861 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
862 } | 862 } |
863 | 863 |
864 TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthLeastAwaiting) { | 864 TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthLeastAwaiting) { |
865 FLAGS_quic_simple_packet_number_length = true; | 865 FLAGS_quic_simple_packet_number_length_2 = true; |
866 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 866 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
867 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 867 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
868 | 868 |
869 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64); | 869 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64); |
870 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 870 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
871 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 871 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
872 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 872 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
873 | 873 |
874 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256); | 874 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256); |
875 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 875 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
876 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 876 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
877 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 877 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
878 | 878 |
879 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256 * 256); | 879 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256 * 256); |
880 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 880 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
881 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, | 881 EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
882 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 882 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
883 | 883 |
884 QuicPacketCreatorPeer::SetPacketNumber(&creator_, | 884 QuicPacketCreatorPeer::SetPacketNumber(&creator_, |
885 UINT64_C(64) * 256 * 256 * 256 * 256); | 885 UINT64_C(64) * 256 * 256 * 256 * 256); |
886 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); | 886 creator_.UpdatePacketNumberLength(2, 10000 / kDefaultMaxPacketSize); |
887 EXPECT_EQ(PACKET_6BYTE_PACKET_NUMBER, | 887 EXPECT_EQ(PACKET_6BYTE_PACKET_NUMBER, |
888 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 888 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
889 } | 889 } |
890 | 890 |
891 TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthCwnd) { | 891 TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthCwnd) { |
892 FLAGS_quic_simple_packet_number_length = true; | 892 FLAGS_quic_simple_packet_number_length_2 = true; |
893 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 893 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
894 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 894 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
895 | 895 |
896 creator_.UpdatePacketNumberLength(1, 10000 / kDefaultMaxPacketSize); | 896 creator_.UpdatePacketNumberLength(1, 10000 / kDefaultMaxPacketSize); |
897 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 897 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
898 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 898 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
899 | 899 |
900 creator_.UpdatePacketNumberLength(1, 10000 * 256 / kDefaultMaxPacketSize); | 900 creator_.UpdatePacketNumberLength(1, 10000 * 256 / kDefaultMaxPacketSize); |
901 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 901 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
902 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 902 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 creator_.SetCurrentPath(kDefaultPathId, 2, 0); | 1213 creator_.SetCurrentPath(kDefaultPathId, 2, 0); |
1214 EXPECT_EQ(kDefaultPathId, QuicPacketCreatorPeer::GetCurrentPath(&creator_)); | 1214 EXPECT_EQ(kDefaultPathId, QuicPacketCreatorPeer::GetCurrentPath(&creator_)); |
1215 EXPECT_TRUE(creator_.HasPendingFrames()); | 1215 EXPECT_TRUE(creator_.HasPendingFrames()); |
1216 EXPECT_EQ(1u, creator_.packet_number()); | 1216 EXPECT_EQ(1u, creator_.packet_number()); |
1217 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 1217 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
1218 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 1218 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
1219 } | 1219 } |
1220 | 1220 |
1221 TEST_P(QuicPacketCreatorTest, | 1221 TEST_P(QuicPacketCreatorTest, |
1222 SetCurrentPathAndUpdatePacketSequenceNumberLength) { | 1222 SetCurrentPathAndUpdatePacketSequenceNumberLength) { |
1223 FLAGS_quic_simple_packet_number_length = false; | 1223 FLAGS_quic_simple_packet_number_length_2 = false; |
1224 // Current path is the default path. | 1224 // Current path is the default path. |
1225 EXPECT_EQ(kDefaultPathId, QuicPacketCreatorPeer::GetCurrentPath(&creator_)); | 1225 EXPECT_EQ(kDefaultPathId, QuicPacketCreatorPeer::GetCurrentPath(&creator_)); |
1226 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 1226 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
1227 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); | 1227 QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); |
1228 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, | 1228 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
1229 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 1229 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
1230 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256 - 2); | 1230 QuicPacketCreatorPeer::SetPacketNumber(&creator_, 64 * 256 - 2); |
1231 // Add a stream frame to the creator and send the packet. | 1231 // Add a stream frame to the creator and send the packet. |
1232 QuicFrame frame; | 1232 QuicFrame frame; |
1233 QuicIOVector io_vector(MakeIOVector("test")); | 1233 QuicIOVector io_vector(MakeIOVector("test")); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 EXPECT_CALL(delegate_, | 1327 EXPECT_CALL(delegate_, |
1328 OnUnrecoverableError(QUIC_CRYPTO_CHLO_TOO_LARGE, _, _)); | 1328 OnUnrecoverableError(QUIC_CRYPTO_CHLO_TOO_LARGE, _, _)); |
1329 EXPECT_QUIC_BUG( | 1329 EXPECT_QUIC_BUG( |
1330 creator_.ConsumeData(1u, data_iovec, 0u, 0u, false, false, &frame), | 1330 creator_.ConsumeData(1u, data_iovec, 0u, 0u, false, false, &frame), |
1331 "Client hello won't fit in a single packet."); | 1331 "Client hello won't fit in a single packet."); |
1332 } | 1332 } |
1333 | 1333 |
1334 } // namespace | 1334 } // namespace |
1335 } // namespace test | 1335 } // namespace test |
1336 } // namespace net | 1336 } // namespace net |
OLD | NEW |