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

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

Issue 479463002: Improve QUIC's SentEntropyManagerTest and removing a test from (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delete_include_linked_hash_map_h_73256287
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | net/quic/quic_sent_entropy_manager.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 "net/quic/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 897 }
898 return frame; 898 return frame;
899 } 899 }
900 900
901 const QuicStopWaitingFrame InitStopWaitingFrame( 901 const QuicStopWaitingFrame InitStopWaitingFrame(
902 QuicPacketSequenceNumber least_unacked) { 902 QuicPacketSequenceNumber least_unacked) {
903 QuicStopWaitingFrame frame; 903 QuicStopWaitingFrame frame;
904 frame.least_unacked = least_unacked; 904 frame.least_unacked = least_unacked;
905 return frame; 905 return frame;
906 } 906 }
907
907 // Explicitly nack a packet. 908 // Explicitly nack a packet.
908 void NackPacket(QuicPacketSequenceNumber missing, QuicAckFrame* frame) { 909 void NackPacket(QuicPacketSequenceNumber missing, QuicAckFrame* frame) {
909 frame->missing_packets.insert(missing); 910 frame->missing_packets.insert(missing);
910 frame->entropy_hash ^= 911 frame->entropy_hash ^=
911 QuicConnectionPeer::GetSentEntropyHash(&connection_, missing); 912 QuicConnectionPeer::PacketEntropy(&connection_, missing);
912 if (missing > 1) {
913 frame->entropy_hash ^=
914 QuicConnectionPeer::GetSentEntropyHash(&connection_, missing - 1);
915 }
916 } 913 }
917 914
918 // Undo nacking a packet within the frame. 915 // Undo nacking a packet within the frame.
919 void AckPacket(QuicPacketSequenceNumber arrived, QuicAckFrame* frame) { 916 void AckPacket(QuicPacketSequenceNumber arrived, QuicAckFrame* frame) {
920 EXPECT_THAT(frame->missing_packets, Contains(arrived)); 917 EXPECT_THAT(frame->missing_packets, Contains(arrived));
921 frame->missing_packets.erase(arrived); 918 frame->missing_packets.erase(arrived);
922 frame->entropy_hash ^= 919 frame->entropy_hash ^=
923 QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived); 920 QuicConnectionPeer::PacketEntropy(&connection_, arrived);
924 if (arrived > 1) {
925 frame->entropy_hash ^=
926 QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived - 1);
927 }
928 } 921 }
929 922
930 void TriggerConnectionClose() { 923 void TriggerConnectionClose() {
931 // Send an erroneous packet to close the connection. 924 // Send an erroneous packet to close the connection.
932 EXPECT_CALL(visitor_, 925 EXPECT_CALL(visitor_,
933 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); 926 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
934 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a 927 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a
935 // packet call to the visitor. 928 // packet call to the visitor.
936 ProcessDataPacket(6000, 0, !kEntropyFlag); 929 ProcessDataPacket(6000, 0, !kEntropyFlag);
937 EXPECT_FALSE( 930 EXPECT_FALSE(
(...skipping 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 entropy[i] = entropy[i - 1]; 3235 entropy[i] = entropy[i - 1];
3243 } 3236 }
3244 ProcessDataPacket(i, 1, entropy_flag); 3237 ProcessDataPacket(i, 1, entropy_flag);
3245 } 3238 }
3246 for (int i = 1; i < 50; ++i) { 3239 for (int i = 1; i < 50; ++i) {
3247 EXPECT_EQ(entropy[i], QuicConnectionPeer::ReceivedEntropyHash( 3240 EXPECT_EQ(entropy[i], QuicConnectionPeer::ReceivedEntropyHash(
3248 &connection_, i)); 3241 &connection_, i));
3249 } 3242 }
3250 } 3243 }
3251 3244
3252 TEST_P(QuicConnectionTest, CheckSentEntropyHash) {
3253 peer_creator_.set_sequence_number(1);
3254 SequenceNumberSet missing_packets;
3255 QuicPacketEntropyHash entropy_hash = 0;
3256 QuicPacketSequenceNumber max_sequence_number = 51;
3257 for (QuicPacketSequenceNumber i = 1; i <= max_sequence_number; ++i) {
3258 bool is_missing = i % 10 != 0;
3259 bool entropy_flag = (i & (i - 1)) != 0;
3260 QuicPacketEntropyHash packet_entropy_hash = 0;
3261 if (entropy_flag) {
3262 packet_entropy_hash = 1 << (i % 8);
3263 }
3264 QuicPacket* packet = ConstructDataPacket(i, 0, entropy_flag);
3265 connection_.SendPacket(
3266 ENCRYPTION_NONE, i, packet, packet_entropy_hash,
3267 HAS_RETRANSMITTABLE_DATA);
3268
3269 if (is_missing) {
3270 missing_packets.insert(i);
3271 continue;
3272 }
3273
3274 entropy_hash ^= packet_entropy_hash;
3275 }
3276 EXPECT_TRUE(QuicConnectionPeer::IsValidEntropy(
3277 &connection_, max_sequence_number, missing_packets, entropy_hash))
3278 << "";
3279 }
3280
3281 TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacket) { 3245 TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacket) {
3282 connection_.SetSupportedVersions(QuicSupportedVersions()); 3246 connection_.SetSupportedVersions(QuicSupportedVersions());
3283 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); 3247 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED);
3284 3248
3285 QuicPacketHeader header; 3249 QuicPacketHeader header;
3286 header.public_header.connection_id = connection_id_; 3250 header.public_header.connection_id = connection_id_;
3287 header.public_header.reset_flag = false; 3251 header.public_header.reset_flag = false;
3288 header.public_header.version_flag = true; 3252 header.public_header.version_flag = true;
3289 header.entropy_flag = false; 3253 header.entropy_flag = false;
3290 header.fec_flag = false; 3254 header.fec_flag = false;
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
3987 QuicBlockedFrame blocked; 3951 QuicBlockedFrame blocked;
3988 blocked.stream_id = 3; 3952 blocked.stream_id = 3;
3989 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3953 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3990 ProcessFramePacket(QuicFrame(&blocked)); 3954 ProcessFramePacket(QuicFrame(&blocked));
3991 EXPECT_TRUE(ack_alarm->IsSet()); 3955 EXPECT_TRUE(ack_alarm->IsSet());
3992 } 3956 }
3993 3957
3994 } // namespace 3958 } // namespace
3995 } // namespace test 3959 } // namespace test
3996 } // namespace net 3960 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_sent_entropy_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698