OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 } | 482 } |
483 | 483 |
484 // Return true if the approprite parts of the expected Result, based | 484 // Return true if the approprite parts of the expected Result, based |
485 // on the local and remote candidate of ep2_ch1, match. This can be | 485 // on the local and remote candidate of ep2_ch1, match. This can be |
486 // used in an EXPECT_TRUE_WAIT. | 486 // used in an EXPECT_TRUE_WAIT. |
487 bool CheckCandidate2(const Result& expected) { | 487 bool CheckCandidate2(const Result& expected) { |
488 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); | 488 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); |
489 // const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); | 489 // const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); |
490 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | 490 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); |
491 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); | 491 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); |
492 // Removed remote_type comparision aginst best connection remote | 492 // Removed remote_type comparision aginst selected connection remote |
493 // candidate. This is done to handle remote type discrepancy from | 493 // candidate. This is done to handle remote type discrepancy from |
494 // local to stun based on the test type. | 494 // local to stun based on the test type. |
495 // For example in case of Open -> NAT, ep2 channels will have LULU | 495 // For example in case of Open -> NAT, ep2 channels will have LULU |
496 // and in other cases like NAT -> NAT it will be LUSU. To avoid these | 496 // and in other cases like NAT -> NAT it will be LUSU. To avoid these |
497 // mismatches and we are doing comparision in different way. | 497 // mismatches and we are doing comparision in different way. |
498 // i.e. when don't match its remote type is either local or stun. | 498 // i.e. when don't match its remote type is either local or stun. |
499 // TODO(ronghuawu): Refine the test criteria. | 499 // TODO(ronghuawu): Refine the test criteria. |
500 // https://code.google.com/p/webrtc/issues/detail?id=1953 | 500 // https://code.google.com/p/webrtc/issues/detail?id=1953 |
501 return ((local_proto == expected.local_proto2 && | 501 return ((local_proto == expected.local_proto2 && |
502 remote_proto == expected.remote_proto2) && | 502 remote_proto == expected.remote_proto2) && |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 expected.connect_wait, | 542 expected.connect_wait, |
543 1000); | 543 1000); |
544 connect_time = rtc::TimeMillis() - connect_start; | 544 connect_time = rtc::TimeMillis() - connect_start; |
545 if (connect_time < expected.connect_wait) { | 545 if (connect_time < expected.connect_wait) { |
546 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; | 546 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; |
547 } else { | 547 } else { |
548 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" | 548 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" |
549 << expected.connect_wait << " ms)"; | 549 << expected.connect_wait << " ms)"; |
550 } | 550 } |
551 | 551 |
552 // Allow a few turns of the crank for the best connections to emerge. | 552 // Allow a few turns of the crank for the selected connections to emerge. |
553 // This may take up to 2 seconds. | 553 // This may take up to 2 seconds. |
554 if (ep1_ch1()->best_connection() && | 554 if (ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection()) { |
555 ep2_ch1()->best_connection()) { | |
556 int64_t converge_start = rtc::TimeMillis(); | 555 int64_t converge_start = rtc::TimeMillis(); |
557 int64_t converge_time; | 556 int64_t converge_time; |
558 int64_t converge_wait = 2000; | 557 int64_t converge_wait = 2000; |
559 // Verifying local and remote channel best connection information. This is | 558 // Verifying local and remote channel selected connection information. |
560 // done only for the RFC 5245 as controlled agent will use USE-CANDIDATE | 559 // This is done only for the RFC 5245 as controlled agent will use |
561 // from controlling (ep1) agent. We can easily predict from EP1 result | 560 // USE-CANDIDATE from controlling (ep1) agent. We can easily predict from |
562 // matrix. | 561 // EP1 result matrix. |
563 EXPECT_TRUE_WAIT_MARGIN( | 562 EXPECT_TRUE_WAIT_MARGIN( |
564 CheckCandidate1(expected) && CheckCandidate2(expected), converge_wait, | 563 CheckCandidate1(expected) && CheckCandidate2(expected), converge_wait, |
565 converge_wait); | 564 converge_wait); |
566 // Also do EXPECT_EQ on each part so that failures are more verbose. | 565 // Also do EXPECT_EQ on each part so that failures are more verbose. |
567 ExpectCandidate1(expected); | 566 ExpectCandidate1(expected); |
568 ExpectCandidate2(expected); | 567 ExpectCandidate2(expected); |
569 | 568 |
570 converge_time = rtc::TimeMillis() - converge_start; | 569 converge_time = rtc::TimeMillis() - converge_start; |
571 if (converge_time < converge_wait) { | 570 if (converge_time < converge_wait) { |
572 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; | 571 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. | 652 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. |
654 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); | 653 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); |
655 EXPECT_FALSE(GetRoleConflict(1)); | 654 EXPECT_FALSE(GetRoleConflict(1)); |
656 | 655 |
657 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && | 656 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && |
658 ep1_ch1()->writable() && | 657 ep1_ch1()->writable() && |
659 ep2_ch1()->receiving() && | 658 ep2_ch1()->receiving() && |
660 ep2_ch1()->writable(), | 659 ep2_ch1()->writable(), |
661 1000); | 660 1000); |
662 | 661 |
663 EXPECT_TRUE(ep1_ch1()->best_connection() && | 662 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
664 ep2_ch1()->best_connection()); | 663 ep2_ch1()->selected_connection()); |
665 | 664 |
666 TestSendRecv(1); | 665 TestSendRecv(1); |
667 } | 666 } |
668 | 667 |
669 void OnReadyToSend(TransportChannel* ch) { | 668 void OnReadyToSend(TransportChannel* ch) { |
670 GetEndpoint(ch)->ready_to_send_ = true; | 669 GetEndpoint(ch)->ready_to_send_ = true; |
671 } | 670 } |
672 | 671 |
673 // We pass the candidates directly to the other side. | 672 // We pass the candidates directly to the other side. |
674 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { | 673 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 int SendData(TransportChannel* channel, const char* data, size_t len) { | 774 int SendData(TransportChannel* channel, const char* data, size_t len) { |
776 rtc::PacketOptions options; | 775 rtc::PacketOptions options; |
777 return channel->SendPacket(data, len, options, 0); | 776 return channel->SendPacket(data, len, options, 0); |
778 } | 777 } |
779 bool CheckDataOnChannel(TransportChannel* channel, | 778 bool CheckDataOnChannel(TransportChannel* channel, |
780 const char* data, | 779 const char* data, |
781 int len) { | 780 int len) { |
782 return GetChannelData(channel)->CheckData(data, len); | 781 return GetChannelData(channel)->CheckData(data, len); |
783 } | 782 } |
784 static const Candidate* LocalCandidate(P2PTransportChannel* ch) { | 783 static const Candidate* LocalCandidate(P2PTransportChannel* ch) { |
785 return (ch && ch->best_connection()) ? | 784 return (ch && ch->selected_connection()) |
786 &ch->best_connection()->local_candidate() : NULL; | 785 ? &ch->selected_connection()->local_candidate() |
| 786 : NULL; |
787 } | 787 } |
788 static const Candidate* RemoteCandidate(P2PTransportChannel* ch) { | 788 static const Candidate* RemoteCandidate(P2PTransportChannel* ch) { |
789 return (ch && ch->best_connection()) ? | 789 return (ch && ch->selected_connection()) |
790 &ch->best_connection()->remote_candidate() : NULL; | 790 ? &ch->selected_connection()->remote_candidate() |
| 791 : NULL; |
791 } | 792 } |
792 Endpoint* GetEndpoint(TransportChannel* ch) { | 793 Endpoint* GetEndpoint(TransportChannel* ch) { |
793 if (ep1_.HasChannel(ch)) { | 794 if (ep1_.HasChannel(ch)) { |
794 return &ep1_; | 795 return &ep1_; |
795 } else if (ep2_.HasChannel(ch)) { | 796 } else if (ep2_.HasChannel(ch)) { |
796 return &ep2_; | 797 return &ep2_; |
797 } else { | 798 } else { |
798 return NULL; | 799 return NULL; |
799 } | 800 } |
800 } | 801 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 // Emulate no remote credentials coming in. | 1147 // Emulate no remote credentials coming in. |
1147 set_remote_ice_credential_source(FROM_CANDIDATE); | 1148 set_remote_ice_credential_source(FROM_CANDIDATE); |
1148 CreateChannels(1); | 1149 CreateChannels(1); |
1149 // Only have remote credentials come in for ep2, not ep1. | 1150 // Only have remote credentials come in for ep2, not ep1. |
1150 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1151 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
1151 | 1152 |
1152 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1153 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1153 // candidate. | 1154 // candidate. |
1154 PauseCandidates(1); | 1155 PauseCandidates(1); |
1155 | 1156 |
1156 // The caller should have the best connection connected to the peer reflexive | 1157 // The caller should have the selected connection connected to the peer |
1157 // candidate. | 1158 // reflexive candidate. |
1158 const Connection* best_connection = NULL; | 1159 const Connection* selected_connection = NULL; |
1159 WAIT((best_connection = ep1_ch1()->best_connection()) != NULL, 2000); | 1160 WAIT((selected_connection = ep1_ch1()->selected_connection()) != NULL, 2000); |
1160 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); | 1161 EXPECT_EQ("prflx", |
| 1162 ep1_ch1()->selected_connection()->remote_candidate().type()); |
1161 | 1163 |
1162 // Because we don't have a remote pwd, we don't ping yet. | 1164 // Because we don't have a remote pwd, we don't ping yet. |
1163 EXPECT_EQ(kIceUfrag[1], | 1165 EXPECT_EQ(kIceUfrag[1], |
1164 ep1_ch1()->best_connection()->remote_candidate().username()); | 1166 ep1_ch1()->selected_connection()->remote_candidate().username()); |
1165 EXPECT_EQ("", ep1_ch1()->best_connection()->remote_candidate().password()); | 1167 EXPECT_EQ("", |
| 1168 ep1_ch1()->selected_connection()->remote_candidate().password()); |
1166 // Because we don't have ICE credentials yet, we don't know the generation. | 1169 // Because we don't have ICE credentials yet, we don't know the generation. |
1167 EXPECT_EQ(0u, ep1_ch1()->best_connection()->remote_candidate().generation()); | 1170 EXPECT_EQ(0u, |
| 1171 ep1_ch1()->selected_connection()->remote_candidate().generation()); |
1168 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); | 1172 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); |
1169 | 1173 |
1170 // Add two sets of remote ICE credentials, so that the ones used by the | 1174 // Add two sets of remote ICE credentials, so that the ones used by the |
1171 // candidate will be generation 1 instead of 0. | 1175 // candidate will be generation 1 instead of 0. |
1172 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1176 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
1173 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1177 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
1174 // After setting the remote ICE credentials, the password and generation | 1178 // After setting the remote ICE credentials, the password and generation |
1175 // of the peer reflexive candidate should be updated. | 1179 // of the peer reflexive candidate should be updated. |
1176 EXPECT_EQ(kIcePwd[1], | 1180 EXPECT_EQ(kIcePwd[1], |
1177 ep1_ch1()->best_connection()->remote_candidate().password()); | 1181 ep1_ch1()->selected_connection()->remote_candidate().password()); |
1178 EXPECT_EQ(1u, ep1_ch1()->best_connection()->remote_candidate().generation()); | 1182 EXPECT_EQ(1u, |
| 1183 ep1_ch1()->selected_connection()->remote_candidate().generation()); |
1179 EXPECT_TRUE(nullptr != ep1_ch1()->FindNextPingableConnection()); | 1184 EXPECT_TRUE(nullptr != ep1_ch1()->FindNextPingableConnection()); |
1180 | 1185 |
1181 ResumeCandidates(1); | 1186 ResumeCandidates(1); |
1182 | 1187 |
1183 WAIT(ep2_ch1()->best_connection() != NULL, 2000); | 1188 WAIT(ep2_ch1()->selected_connection() != NULL, 2000); |
1184 // Verify ep1's best connection is updated to use the 'local' candidate. | 1189 // Verify ep1's selected connection is updated to use the 'local' candidate. |
1185 EXPECT_EQ_WAIT( | 1190 EXPECT_EQ_WAIT("local", |
1186 "local", | 1191 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1187 ep1_ch1()->best_connection()->remote_candidate().type(), | 1192 2000); |
1188 2000); | 1193 EXPECT_EQ(selected_connection, ep1_ch1()->selected_connection()); |
1189 EXPECT_EQ(best_connection, ep1_ch1()->best_connection()); | |
1190 DestroyChannels(); | 1194 DestroyChannels(); |
1191 } | 1195 } |
1192 | 1196 |
1193 // Test that we properly create a connection on a STUN ping from unknown address | 1197 // Test that we properly create a connection on a STUN ping from unknown address |
1194 // when the signaling is slow and the end points are behind NAT. | 1198 // when the signaling is slow and the end points are behind NAT. |
1195 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { | 1199 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
1196 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1200 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1197 kDefaultPortAllocatorFlags); | 1201 kDefaultPortAllocatorFlags); |
1198 // Emulate no remote credentials coming in. | 1202 // Emulate no remote credentials coming in. |
1199 set_remote_ice_credential_source(FROM_CANDIDATE); | 1203 set_remote_ice_credential_source(FROM_CANDIDATE); |
1200 CreateChannels(1); | 1204 CreateChannels(1); |
1201 // Only have remote credentials come in for ep2, not ep1. | 1205 // Only have remote credentials come in for ep2, not ep1. |
1202 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1206 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
1203 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1207 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1204 // candidate. | 1208 // candidate. |
1205 PauseCandidates(1); | 1209 PauseCandidates(1); |
1206 | 1210 |
1207 // The caller should have the best connection connected to the peer reflexive | 1211 // The caller should have the selected connection connected to the peer |
1208 // candidate. | 1212 // reflexive candidate. |
1209 WAIT(ep1_ch1()->best_connection() != NULL, 2000); | 1213 WAIT(ep1_ch1()->selected_connection() != NULL, 2000); |
1210 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); | 1214 EXPECT_EQ("prflx", |
| 1215 ep1_ch1()->selected_connection()->remote_candidate().type()); |
1211 | 1216 |
1212 // Because we don't have a remote pwd, we don't ping yet. | 1217 // Because we don't have a remote pwd, we don't ping yet. |
1213 EXPECT_EQ(kIceUfrag[1], | 1218 EXPECT_EQ(kIceUfrag[1], |
1214 ep1_ch1()->best_connection()->remote_candidate().username()); | 1219 ep1_ch1()->selected_connection()->remote_candidate().username()); |
1215 EXPECT_EQ("", ep1_ch1()->best_connection()->remote_candidate().password()); | 1220 EXPECT_EQ("", |
| 1221 ep1_ch1()->selected_connection()->remote_candidate().password()); |
1216 // Because we don't have ICE credentials yet, we don't know the generation. | 1222 // Because we don't have ICE credentials yet, we don't know the generation. |
1217 EXPECT_EQ(0u, ep1_ch1()->best_connection()->remote_candidate().generation()); | 1223 EXPECT_EQ(0u, |
| 1224 ep1_ch1()->selected_connection()->remote_candidate().generation()); |
1218 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); | 1225 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); |
1219 | 1226 |
1220 // Add two sets of remote ICE credentials, so that the ones used by the | 1227 // Add two sets of remote ICE credentials, so that the ones used by the |
1221 // candidate will be generation 1 instead of 0. | 1228 // candidate will be generation 1 instead of 0. |
1222 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1229 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
1223 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1230 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
1224 // After setting the remote ICE credentials, the password and generation | 1231 // After setting the remote ICE credentials, the password and generation |
1225 // of the peer reflexive candidate should be updated. | 1232 // of the peer reflexive candidate should be updated. |
1226 EXPECT_EQ(kIcePwd[1], | 1233 EXPECT_EQ(kIcePwd[1], |
1227 ep1_ch1()->best_connection()->remote_candidate().password()); | 1234 ep1_ch1()->selected_connection()->remote_candidate().password()); |
1228 EXPECT_EQ(1u, ep1_ch1()->best_connection()->remote_candidate().generation()); | 1235 EXPECT_EQ(1u, |
| 1236 ep1_ch1()->selected_connection()->remote_candidate().generation()); |
1229 | 1237 |
1230 ResumeCandidates(1); | 1238 ResumeCandidates(1); |
1231 | 1239 |
1232 const Connection* best_connection = NULL; | 1240 const Connection* selected_connection = NULL; |
1233 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 2000); | 1241 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 2000); |
1234 | 1242 |
1235 // Wait to verify the connection is not culled. | 1243 // Wait to verify the connection is not culled. |
1236 WAIT(ep1_ch1()->writable(), 2000); | 1244 WAIT(ep1_ch1()->writable(), 2000); |
1237 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection); | 1245 EXPECT_EQ(ep2_ch1()->selected_connection(), selected_connection); |
1238 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); | 1246 EXPECT_EQ("prflx", |
| 1247 ep1_ch1()->selected_connection()->remote_candidate().type()); |
1239 DestroyChannels(); | 1248 DestroyChannels(); |
1240 } | 1249 } |
1241 | 1250 |
1242 // Test that we properly create a connection on a STUN ping from unknown address | 1251 // Test that we properly create a connection on a STUN ping from unknown address |
1243 // when the signaling is slow, even if the new candidate is created due to the | 1252 // when the signaling is slow, even if the new candidate is created due to the |
1244 // remote peer doing an ICE restart, pairing this candidate across generations. | 1253 // remote peer doing an ICE restart, pairing this candidate across generations. |
1245 // | 1254 // |
1246 // Previously this wasn't working due to a bug where the peer reflexive | 1255 // Previously this wasn't working due to a bug where the peer reflexive |
1247 // candidate was only updated for the newest generation candidate pairs, and | 1256 // candidate was only updated for the newest generation candidate pairs, and |
1248 // not older-generation candidate pairs created by pairing candidates across | 1257 // not older-generation candidate pairs created by pairing candidates across |
(...skipping 17 matching lines...) Expand all Loading... |
1266 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1275 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1267 kDefaultTimeout); | 1276 kDefaultTimeout); |
1268 | 1277 |
1269 // Simulate an ICE restart on ep2, but don't signal the candidate or new | 1278 // Simulate an ICE restart on ep2, but don't signal the candidate or new |
1270 // ICE credentials until after a prflx connection has been made. | 1279 // ICE credentials until after a prflx connection has been made. |
1271 PauseCandidates(1); | 1280 PauseCandidates(1); |
1272 ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1281 ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); |
1273 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1282 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
1274 ep2_ch1()->MaybeStartGathering(); | 1283 ep2_ch1()->MaybeStartGathering(); |
1275 | 1284 |
1276 // The caller should have the best connection connected to the peer reflexive | 1285 // The caller should have the selected connection connected to the peer |
1277 // candidate. | 1286 // reflexive candidate. |
1278 EXPECT_EQ_WAIT("prflx", | 1287 EXPECT_EQ_WAIT("prflx", |
1279 ep1_ch1()->best_connection()->remote_candidate().type(), | 1288 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1280 kDefaultTimeout); | 1289 kDefaultTimeout); |
1281 const Connection* prflx_best_connection = ep1_ch1()->best_connection(); | 1290 const Connection* prflx_selected_connection = |
| 1291 ep1_ch1()->selected_connection(); |
1282 | 1292 |
1283 // Now simulate the ICE restart on ep1. | 1293 // Now simulate the ICE restart on ep1. |
1284 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); | 1294 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); |
1285 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 1295 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); |
1286 ep1_ch1()->MaybeStartGathering(); | 1296 ep1_ch1()->MaybeStartGathering(); |
1287 | 1297 |
1288 // Finally send the candidates from ep2's ICE restart and verify that ep1 uses | 1298 // Finally send the candidates from ep2's ICE restart and verify that ep1 uses |
1289 // their information to update the peer reflexive candidate. | 1299 // their information to update the peer reflexive candidate. |
1290 ResumeCandidates(1); | 1300 ResumeCandidates(1); |
1291 | 1301 |
1292 EXPECT_EQ_WAIT("relay", | 1302 EXPECT_EQ_WAIT("relay", |
1293 ep1_ch1()->best_connection()->remote_candidate().type(), | 1303 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1294 kDefaultTimeout); | 1304 kDefaultTimeout); |
1295 EXPECT_EQ(prflx_best_connection, ep1_ch1()->best_connection()); | 1305 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); |
1296 DestroyChannels(); | 1306 DestroyChannels(); |
1297 } | 1307 } |
1298 | 1308 |
1299 // Test that if remote candidates don't have ufrag and pwd, we still work. | 1309 // Test that if remote candidates don't have ufrag and pwd, we still work. |
1300 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { | 1310 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
1301 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1311 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); |
1302 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1312 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1303 kDefaultPortAllocatorFlags); | 1313 kDefaultPortAllocatorFlags); |
1304 CreateChannels(1); | 1314 CreateChannels(1); |
1305 const Connection* best_connection = NULL; | 1315 const Connection* selected_connection = NULL; |
1306 // Wait until the callee's connections are created. | 1316 // Wait until the callee's connections are created. |
1307 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 1000); | 1317 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); |
1308 // Wait to see if they get culled; they shouldn't. | 1318 // Wait to see if they get culled; they shouldn't. |
1309 WAIT(ep2_ch1()->best_connection() != best_connection, 1000); | 1319 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); |
1310 EXPECT_TRUE(ep2_ch1()->best_connection() == best_connection); | 1320 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); |
1311 DestroyChannels(); | 1321 DestroyChannels(); |
1312 } | 1322 } |
1313 | 1323 |
1314 // Test that a host behind NAT cannot be reached when incoming_only | 1324 // Test that a host behind NAT cannot be reached when incoming_only |
1315 // is set to true. | 1325 // is set to true. |
1316 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { | 1326 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { |
1317 ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags, | 1327 ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags, |
1318 kDefaultPortAllocatorFlags); | 1328 kDefaultPortAllocatorFlags); |
1319 | 1329 |
1320 SetAllocatorFlags(0, kOnlyLocalPorts); | 1330 SetAllocatorFlags(0, kOnlyLocalPorts); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); | 1391 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); |
1382 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); | 1392 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); |
1383 | 1393 |
1384 // Resume candidates. | 1394 // Resume candidates. |
1385 ResumeCandidates(0); | 1395 ResumeCandidates(0); |
1386 ResumeCandidates(1); | 1396 ResumeCandidates(1); |
1387 | 1397 |
1388 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1398 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1389 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1399 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1390 1000); | 1400 1000); |
1391 EXPECT_TRUE( | 1401 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
1392 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1402 ep2_ch1()->selected_connection() && |
1393 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1403 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1394 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1404 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1395 | 1405 |
1396 TestSendRecv(1); | 1406 TestSendRecv(1); |
1397 DestroyChannels(); | 1407 DestroyChannels(); |
1398 } | 1408 } |
1399 | 1409 |
1400 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { | 1410 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { |
1401 AddAddress(0, kPublicAddrs[0]); | 1411 AddAddress(0, kPublicAddrs[0]); |
1402 AddAddress(1, kPublicAddrs[1]); | 1412 AddAddress(1, kPublicAddrs[1]); |
1403 TestSignalRoleConflict(); | 1413 TestSignalRoleConflict(); |
1404 } | 1414 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 // original value. | 1452 // original value. |
1443 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); | 1453 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); |
1444 } | 1454 } |
1445 | 1455 |
1446 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && | 1456 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && |
1447 ep1_ch1()->writable() && | 1457 ep1_ch1()->writable() && |
1448 ep2_ch1()->receiving() && | 1458 ep2_ch1()->receiving() && |
1449 ep2_ch1()->writable(), | 1459 ep2_ch1()->writable(), |
1450 1000); | 1460 1000); |
1451 | 1461 |
1452 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1462 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
1453 ep2_ch1()->best_connection()); | 1463 ep2_ch1()->selected_connection()); |
1454 | 1464 |
1455 TestSendRecv(1); | 1465 TestSendRecv(1); |
1456 DestroyChannels(); | 1466 DestroyChannels(); |
1457 } | 1467 } |
1458 | 1468 |
1459 // Verify that we can set DSCP value and retrieve properly from P2PTC. | 1469 // Verify that we can set DSCP value and retrieve properly from P2PTC. |
1460 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { | 1470 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { |
1461 AddAddress(0, kPublicAddrs[0]); | 1471 AddAddress(0, kPublicAddrs[0]); |
1462 AddAddress(1, kPublicAddrs[1]); | 1472 AddAddress(1, kPublicAddrs[1]); |
1463 | 1473 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 // Enable IPv6 | 1507 // Enable IPv6 |
1498 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); | 1508 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); |
1499 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); | 1509 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); |
1500 | 1510 |
1501 CreateChannels(1); | 1511 CreateChannels(1); |
1502 | 1512 |
1503 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1513 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1504 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1514 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1505 1000); | 1515 1000); |
1506 EXPECT_TRUE( | 1516 EXPECT_TRUE( |
1507 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1517 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
1508 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && | 1518 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && |
1509 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); | 1519 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); |
1510 | 1520 |
1511 TestSendRecv(1); | 1521 TestSendRecv(1); |
1512 DestroyChannels(); | 1522 DestroyChannels(); |
1513 } | 1523 } |
1514 | 1524 |
1515 // Testing forceful TURN connections. | 1525 // Testing forceful TURN connections. |
1516 TEST_F(P2PTransportChannelTest, TestForceTurn) { | 1526 TEST_F(P2PTransportChannelTest, TestForceTurn) { |
1517 ConfigureEndpoints( | 1527 ConfigureEndpoints( |
1518 NAT_PORT_RESTRICTED, NAT_SYMMETRIC, | 1528 NAT_PORT_RESTRICTED, NAT_SYMMETRIC, |
1519 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET, | 1529 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET, |
1520 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1530 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
1521 set_force_relay(true); | 1531 set_force_relay(true); |
1522 | 1532 |
1523 SetAllocationStepDelay(0, kMinimumStepDelay); | 1533 SetAllocationStepDelay(0, kMinimumStepDelay); |
1524 SetAllocationStepDelay(1, kMinimumStepDelay); | 1534 SetAllocationStepDelay(1, kMinimumStepDelay); |
1525 | 1535 |
1526 CreateChannels(1); | 1536 CreateChannels(1); |
1527 | 1537 |
1528 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1538 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1529 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1539 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1530 2000); | 1540 2000); |
1531 | 1541 |
1532 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1542 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
1533 ep2_ch1()->best_connection()); | 1543 ep2_ch1()->selected_connection()); |
1534 | 1544 |
1535 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); | 1545 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); |
1536 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); | 1546 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); |
1537 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); | 1547 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); |
1538 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); | 1548 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); |
1539 | 1549 |
1540 TestSendRecv(1); | 1550 TestSendRecv(1); |
1541 DestroyChannels(); | 1551 DestroyChannels(); |
1542 } | 1552 } |
1543 | 1553 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1608 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1599 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1609 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1600 1000, 1000); | 1610 1000, 1000); |
1601 TestSendRecv(1); | 1611 TestSendRecv(1); |
1602 // Make sure the P2PTransportChannels are actually using ports from the | 1612 // Make sure the P2PTransportChannels are actually using ports from the |
1603 // pooled sessions. | 1613 // pooled sessions. |
1604 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); | 1614 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); |
1605 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); | 1615 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); |
1606 EXPECT_NE(pooled_ports_1.end(), | 1616 EXPECT_NE(pooled_ports_1.end(), |
1607 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1617 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
1608 ep1_ch1()->best_connection()->port())); | 1618 ep1_ch1()->selected_connection()->port())); |
1609 EXPECT_NE(pooled_ports_2.end(), | 1619 EXPECT_NE(pooled_ports_2.end(), |
1610 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1620 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
1611 ep2_ch1()->best_connection()->port())); | 1621 ep2_ch1()->selected_connection()->port())); |
1612 } | 1622 } |
1613 | 1623 |
1614 // Test that a connection succeeds when the P2PTransportChannel uses a pooled | 1624 // Test that a connection succeeds when the P2PTransportChannel uses a pooled |
1615 // PortAllocatorSession that already finished gathering candidates. | 1625 // PortAllocatorSession that already finished gathering candidates. |
1616 TEST_F(P2PTransportChannelTest, TestUsingPooledSessionAfterDoneGathering) { | 1626 TEST_F(P2PTransportChannelTest, TestUsingPooledSessionAfterDoneGathering) { |
1617 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1627 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1618 kDefaultPortAllocatorFlags); | 1628 kDefaultPortAllocatorFlags); |
1619 // First create a pooled session for each endpoint. | 1629 // First create a pooled session for each endpoint. |
1620 auto& allocator_1 = GetEndpoint(0)->allocator_; | 1630 auto& allocator_1 = GetEndpoint(0)->allocator_; |
1621 auto& allocator_2 = GetEndpoint(1)->allocator_; | 1631 auto& allocator_2 = GetEndpoint(1)->allocator_; |
(...skipping 19 matching lines...) Expand all Loading... |
1641 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1651 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1642 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1652 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1643 1000, 1000); | 1653 1000, 1000); |
1644 TestSendRecv(1); | 1654 TestSendRecv(1); |
1645 // Make sure the P2PTransportChannels are actually using ports from the | 1655 // Make sure the P2PTransportChannels are actually using ports from the |
1646 // pooled sessions. | 1656 // pooled sessions. |
1647 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); | 1657 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); |
1648 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); | 1658 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); |
1649 EXPECT_NE(pooled_ports_1.end(), | 1659 EXPECT_NE(pooled_ports_1.end(), |
1650 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1660 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
1651 ep1_ch1()->best_connection()->port())); | 1661 ep1_ch1()->selected_connection()->port())); |
1652 EXPECT_NE(pooled_ports_2.end(), | 1662 EXPECT_NE(pooled_ports_2.end(), |
1653 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1663 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
1654 ep2_ch1()->best_connection()->port())); | 1664 ep2_ch1()->selected_connection()->port())); |
1655 } | 1665 } |
1656 | 1666 |
1657 // Test that when the "presume_writable_when_fully_relayed" flag is set to | 1667 // Test that when the "presume_writable_when_fully_relayed" flag is set to |
1658 // false and there's a TURN-TURN candidate pair, it's presume to be writable | 1668 // false and there's a TURN-TURN candidate pair, it's presume to be writable |
1659 // as soon as it's created. | 1669 // as soon as it's created. |
1660 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { | 1670 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { |
1661 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1671 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1662 kDefaultPortAllocatorFlags); | 1672 kDefaultPortAllocatorFlags); |
1663 // Only configure one channel so we can control when the remote candidate | 1673 // Only configure one channel so we can control when the remote candidate |
1664 // is added. | 1674 // is added. |
1665 GetEndpoint(0)->cd1_.ch_.reset( | 1675 GetEndpoint(0)->cd1_.ch_.reset( |
1666 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1676 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], |
1667 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | 1677 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); |
1668 IceConfig config; | 1678 IceConfig config; |
1669 config.presume_writable_when_fully_relayed = true; | 1679 config.presume_writable_when_fully_relayed = true; |
1670 ep1_ch1()->SetIceConfig(config); | 1680 ep1_ch1()->SetIceConfig(config); |
1671 ep1_ch1()->MaybeStartGathering(); | 1681 ep1_ch1()->MaybeStartGathering(); |
1672 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, | 1682 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, |
1673 ep1_ch1()->gathering_state(), kDefaultTimeout); | 1683 ep1_ch1()->gathering_state(), kDefaultTimeout); |
1674 // Add two remote candidates; a host candidate (with higher priority) | 1684 // Add two remote candidates; a host candidate (with higher priority) |
1675 // and TURN candidate. | 1685 // and TURN candidate. |
1676 ep1_ch1()->AddRemoteCandidate( | 1686 ep1_ch1()->AddRemoteCandidate( |
1677 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 1687 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
1678 ep1_ch1()->AddRemoteCandidate( | 1688 ep1_ch1()->AddRemoteCandidate( |
1679 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); | 1689 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); |
1680 // Expect that the TURN-TURN candidate pair will be prioritized since it's | 1690 // Expect that the TURN-TURN candidate pair will be prioritized since it's |
1681 // "probably writable". | 1691 // "probably writable". |
1682 EXPECT_TRUE(ep1_ch1()->best_connection() != nullptr); | 1692 EXPECT_TRUE(ep1_ch1()->selected_connection() != nullptr); |
1683 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); | 1693 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); |
1684 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); | 1694 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); |
1685 // Also expect that the channel instantly indicates that it's writable since | 1695 // Also expect that the channel instantly indicates that it's writable since |
1686 // it has a TURN-TURN pair. | 1696 // it has a TURN-TURN pair. |
1687 EXPECT_TRUE(ep1_ch1()->writable()); | 1697 EXPECT_TRUE(ep1_ch1()->writable()); |
1688 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); | 1698 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); |
1689 } | 1699 } |
1690 | 1700 |
1691 // Test that a presumed-writable TURN<->TURN connection is preferred above an | 1701 // Test that a presumed-writable TURN<->TURN connection is preferred above an |
1692 // unreliable connection (one that has failed to be pinged for some time). | 1702 // unreliable connection (one that has failed to be pinged for some time). |
1693 TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { | 1703 TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { |
1694 rtc::ScopedFakeClock fake_clock; | 1704 rtc::ScopedFakeClock fake_clock; |
1695 | 1705 |
1696 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1706 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1697 kDefaultPortAllocatorFlags); | 1707 kDefaultPortAllocatorFlags); |
1698 IceConfig config; | 1708 IceConfig config; |
1699 config.presume_writable_when_fully_relayed = true; | 1709 config.presume_writable_when_fully_relayed = true; |
1700 GetEndpoint(0)->cd1_.ch_.reset( | 1710 GetEndpoint(0)->cd1_.ch_.reset( |
1701 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1711 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], |
1702 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | 1712 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); |
1703 GetEndpoint(1)->cd1_.ch_.reset( | 1713 GetEndpoint(1)->cd1_.ch_.reset( |
1704 CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], | 1714 CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], |
1705 kIcePwd[1], kIceUfrag[0], kIcePwd[0])); | 1715 kIcePwd[1], kIceUfrag[0], kIcePwd[0])); |
1706 ep1_ch1()->SetIceConfig(config); | 1716 ep1_ch1()->SetIceConfig(config); |
1707 ep2_ch1()->SetIceConfig(config); | 1717 ep2_ch1()->SetIceConfig(config); |
1708 ep1_ch1()->MaybeStartGathering(); | 1718 ep1_ch1()->MaybeStartGathering(); |
1709 ep2_ch1()->MaybeStartGathering(); | 1719 ep2_ch1()->MaybeStartGathering(); |
1710 // Wait for initial connection as usual. | 1720 // Wait for initial connection as usual. |
1711 EXPECT_TRUE_SIMULATED_WAIT( | 1721 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1712 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1722 ep1_ch1()->selected_connection()->writable() && |
1713 ep1_ch1()->best_connection()->writable() && ep2_ch1()->receiving() && | 1723 ep2_ch1()->receiving() && |
1714 ep2_ch1()->writable() && ep2_ch1()->best_connection()->writable(), | 1724 ep2_ch1()->writable() && |
1715 1000, fake_clock); | 1725 ep2_ch1()->selected_connection()->writable(), |
1716 const Connection* old_best_connection = ep1_ch1()->best_connection(); | 1726 1000, fake_clock); |
| 1727 const Connection* old_selected_connection = ep1_ch1()->selected_connection(); |
1717 // Destroy the second channel and wait for the current connection on the | 1728 // Destroy the second channel and wait for the current connection on the |
1718 // first channel to become "unreliable", making it no longer writable. | 1729 // first channel to become "unreliable", making it no longer writable. |
1719 GetEndpoint(1)->cd1_.ch_.reset(); | 1730 GetEndpoint(1)->cd1_.ch_.reset(); |
1720 EXPECT_TRUE_SIMULATED_WAIT(!ep1_ch1()->writable(), 10000, fake_clock); | 1731 EXPECT_TRUE_SIMULATED_WAIT(!ep1_ch1()->writable(), 10000, fake_clock); |
1721 EXPECT_NE(nullptr, ep1_ch1()->best_connection()); | 1732 EXPECT_NE(nullptr, ep1_ch1()->selected_connection()); |
1722 // Add a remote TURN candidate. The first channel should still have a TURN | 1733 // Add a remote TURN candidate. The first channel should still have a TURN |
1723 // port available to make a TURN<->TURN pair that's presumed writable. | 1734 // port available to make a TURN<->TURN pair that's presumed writable. |
1724 ep1_ch1()->AddRemoteCandidate( | 1735 ep1_ch1()->AddRemoteCandidate( |
1725 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); | 1736 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); |
1726 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); | 1737 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); |
1727 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); | 1738 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); |
1728 EXPECT_TRUE(ep1_ch1()->writable()); | 1739 EXPECT_TRUE(ep1_ch1()->writable()); |
1729 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); | 1740 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); |
1730 EXPECT_NE(old_best_connection, ep1_ch1()->best_connection()); | 1741 EXPECT_NE(old_selected_connection, ep1_ch1()->selected_connection()); |
1731 // Explitly destroy channels, before fake clock is destroyed. | 1742 // Explitly destroy channels, before fake clock is destroyed. |
1732 DestroyChannels(); | 1743 DestroyChannels(); |
1733 } | 1744 } |
1734 | 1745 |
1735 // Test what happens when we have 2 users behind the same NAT. This can lead | 1746 // Test what happens when we have 2 users behind the same NAT. This can lead |
1736 // to interesting behavior because the STUN server will only give out the | 1747 // to interesting behavior because the STUN server will only give out the |
1737 // address of the outermost NAT. | 1748 // address of the outermost NAT. |
1738 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { | 1749 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { |
1739 protected: | 1750 protected: |
1740 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { | 1751 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 // Use only local ports for simplicity. | 1805 // Use only local ports for simplicity. |
1795 SetAllocatorFlags(0, kOnlyLocalPorts); | 1806 SetAllocatorFlags(0, kOnlyLocalPorts); |
1796 SetAllocatorFlags(1, kOnlyLocalPorts); | 1807 SetAllocatorFlags(1, kOnlyLocalPorts); |
1797 | 1808 |
1798 // Create channels and let them go writable, as usual. | 1809 // Create channels and let them go writable, as usual. |
1799 CreateChannels(1); | 1810 CreateChannels(1); |
1800 | 1811 |
1801 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1812 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1802 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1813 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1803 1000, 1000); | 1814 1000, 1000); |
1804 EXPECT_TRUE( | 1815 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
1805 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1816 ep2_ch1()->selected_connection() && |
1806 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1817 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1807 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1818 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1808 | 1819 |
1809 // Make the receiving timeout shorter for testing. | 1820 // Make the receiving timeout shorter for testing. |
1810 IceConfig config = CreateIceConfig(1000, false); | 1821 IceConfig config = CreateIceConfig(1000, false); |
1811 ep1_ch1()->SetIceConfig(config); | 1822 ep1_ch1()->SetIceConfig(config); |
1812 ep2_ch1()->SetIceConfig(config); | 1823 ep2_ch1()->SetIceConfig(config); |
1813 | 1824 |
1814 // Blackhole any traffic to or from the public addrs. | 1825 // Blackhole any traffic to or from the public addrs. |
1815 LOG(LS_INFO) << "Failing over..."; | 1826 LOG(LS_INFO) << "Failing over..."; |
1816 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); | 1827 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); |
1817 // The best connections will switch, so keep references to them. | 1828 // The selected connections will switch, so keep references to them. |
1818 const Connection* best_connection1 = ep1_ch1()->best_connection(); | 1829 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
1819 const Connection* best_connection2 = ep2_ch1()->best_connection(); | 1830 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); |
1820 // We should detect loss of receiving within 1 second or so. | 1831 // We should detect loss of receiving within 1 second or so. |
1821 EXPECT_TRUE_WAIT( | 1832 EXPECT_TRUE_WAIT( |
1822 !best_connection1->receiving() && !best_connection2->receiving(), 3000); | 1833 !selected_connection1->receiving() && !selected_connection2->receiving(), |
| 1834 3000); |
1823 | 1835 |
1824 // We should switch over to use the alternate addr immediately on both sides | 1836 // We should switch over to use the alternate addr immediately on both sides |
1825 // when we are not receiving. | 1837 // when we are not receiving. |
1826 EXPECT_TRUE_WAIT( | 1838 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection()->receiving() && |
1827 ep1_ch1()->best_connection()->receiving() && | 1839 ep2_ch1()->selected_connection()->receiving(), |
1828 ep2_ch1()->best_connection()->receiving(), 1000); | 1840 1000); |
1829 EXPECT_TRUE(LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0])); | 1841 EXPECT_TRUE(LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0])); |
1830 EXPECT_TRUE( | 1842 EXPECT_TRUE( |
1831 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1])); | 1843 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1])); |
1832 EXPECT_TRUE( | 1844 EXPECT_TRUE( |
1833 LocalCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[1])); | 1845 LocalCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[1])); |
1834 | 1846 |
1835 DestroyChannels(); | 1847 DestroyChannels(); |
1836 } | 1848 } |
1837 | 1849 |
1838 // Test that we can quickly switch links if an interface goes down. | 1850 // Test that we can quickly switch links if an interface goes down. |
1839 // The controlling side has two interfaces and one will die. | 1851 // The controlling side has two interfaces and one will die. |
1840 TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) { | 1852 TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) { |
1841 // Adding alternate address will make sure |kPublicAddrs| has the higher | 1853 // Adding alternate address will make sure |kPublicAddrs| has the higher |
1842 // priority than others. This is due to FakeNetwork::AddInterface method. | 1854 // priority than others. This is due to FakeNetwork::AddInterface method. |
1843 AddAddress(0, kAlternateAddrs[0]); | 1855 AddAddress(0, kAlternateAddrs[0]); |
1844 AddAddress(0, kPublicAddrs[0]); | 1856 AddAddress(0, kPublicAddrs[0]); |
1845 AddAddress(1, kPublicAddrs[1]); | 1857 AddAddress(1, kPublicAddrs[1]); |
1846 | 1858 |
1847 // Use only local ports for simplicity. | 1859 // Use only local ports for simplicity. |
1848 SetAllocatorFlags(0, kOnlyLocalPorts); | 1860 SetAllocatorFlags(0, kOnlyLocalPorts); |
1849 SetAllocatorFlags(1, kOnlyLocalPorts); | 1861 SetAllocatorFlags(1, kOnlyLocalPorts); |
1850 | 1862 |
1851 // Create channels and let them go writable, as usual. | 1863 // Create channels and let them go writable, as usual. |
1852 CreateChannels(1); | 1864 CreateChannels(1); |
1853 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1865 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1854 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1866 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1855 1000, 1000); | 1867 1000, 1000); |
1856 EXPECT_TRUE( | 1868 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
1857 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1869 ep2_ch1()->selected_connection() && |
1858 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1870 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1859 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1871 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1860 | 1872 |
1861 // Make the receiving timeout shorter for testing. | 1873 // Make the receiving timeout shorter for testing. |
1862 IceConfig config = CreateIceConfig(1000, false); | 1874 IceConfig config = CreateIceConfig(1000, false); |
1863 ep1_ch1()->SetIceConfig(config); | 1875 ep1_ch1()->SetIceConfig(config); |
1864 ep2_ch1()->SetIceConfig(config); | 1876 ep2_ch1()->SetIceConfig(config); |
1865 | 1877 |
1866 // Blackhole any traffic to or from the public addrs. | 1878 // Blackhole any traffic to or from the public addrs. |
1867 LOG(LS_INFO) << "Failing over..."; | 1879 LOG(LS_INFO) << "Failing over..."; |
1868 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); | 1880 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); |
1869 // The best connections will switch, so keep references to them. | 1881 // The selected connections will switch, so keep references to them. |
1870 const Connection* best_connection1 = ep1_ch1()->best_connection(); | 1882 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
1871 const Connection* best_connection2 = ep2_ch1()->best_connection(); | 1883 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); |
1872 // We should detect loss of receiving within 1 second or so. | 1884 // We should detect loss of receiving within 1 second or so. |
1873 EXPECT_TRUE_WAIT( | 1885 EXPECT_TRUE_WAIT( |
1874 !best_connection1->receiving() && !best_connection2->receiving(), 3000); | 1886 !selected_connection1->receiving() && !selected_connection2->receiving(), |
| 1887 3000); |
1875 | 1888 |
1876 // We should switch over to use the alternate addr immediately on both sides | 1889 // We should switch over to use the alternate addr immediately on both sides |
1877 // when we are not receiving. | 1890 // when we are not receiving. |
1878 EXPECT_TRUE_WAIT( | 1891 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection()->receiving() && |
1879 ep1_ch1()->best_connection()->receiving() && | 1892 ep2_ch1()->selected_connection()->receiving(), |
1880 ep2_ch1()->best_connection()->receiving(), 1000); | 1893 1000); |
1881 EXPECT_TRUE( | 1894 EXPECT_TRUE( |
1882 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); | 1895 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); |
1883 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1896 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1884 EXPECT_TRUE( | 1897 EXPECT_TRUE( |
1885 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); | 1898 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); |
1886 | 1899 |
1887 DestroyChannels(); | 1900 DestroyChannels(); |
1888 } | 1901 } |
1889 | 1902 |
1890 // Tests that a Wifi-Wifi connection has the highest precedence. | 1903 // Tests that a Wifi-Wifi connection has the highest precedence. |
(...skipping 11 matching lines...) Expand all Loading... |
1902 SetAllocatorFlags(0, kOnlyLocalPorts); | 1915 SetAllocatorFlags(0, kOnlyLocalPorts); |
1903 SetAllocatorFlags(1, kOnlyLocalPorts); | 1916 SetAllocatorFlags(1, kOnlyLocalPorts); |
1904 | 1917 |
1905 // Create channels and let them go writable, as usual. | 1918 // Create channels and let them go writable, as usual. |
1906 CreateChannels(1); | 1919 CreateChannels(1); |
1907 | 1920 |
1908 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1921 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1909 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1922 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1910 1000, 1000); | 1923 1000, 1000); |
1911 // Need to wait to make sure the connections on both networks are writable. | 1924 // Need to wait to make sure the connections on both networks are writable. |
1912 EXPECT_TRUE_WAIT(ep1_ch1()->best_connection() && | 1925 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection() && |
1913 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 1926 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
1914 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | 1927 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), |
1915 1000); | 1928 1000); |
1916 EXPECT_TRUE_WAIT(ep2_ch1()->best_connection() && | 1929 EXPECT_TRUE_WAIT(ep2_ch1()->selected_connection() && |
1917 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]) && | 1930 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]) && |
1918 RemoteCandidate(ep2_ch1())->address().EqualIPs(wifi[0]), | 1931 RemoteCandidate(ep2_ch1())->address().EqualIPs(wifi[0]), |
1919 1000); | 1932 1000); |
1920 } | 1933 } |
1921 | 1934 |
1922 // Tests that a Wifi-Cellular connection has higher precedence than | 1935 // Tests that a Wifi-Cellular connection has higher precedence than |
1923 // a Cellular-Cellular connection. | 1936 // a Cellular-Cellular connection. |
1924 TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) { | 1937 TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) { |
1925 // The interface names are chosen so that |cellular| would have higher | 1938 // The interface names are chosen so that |cellular| would have higher |
1926 // candidate priority if it is not for the network type. | 1939 // candidate priority if it is not for the network type. |
1927 auto& wifi = kAlternateAddrs; | 1940 auto& wifi = kAlternateAddrs; |
1928 auto& cellular = kPublicAddrs; | 1941 auto& cellular = kPublicAddrs; |
1929 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 1942 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
1930 AddAddress(1, wifi[1], "test0", rtc::ADAPTER_TYPE_WIFI); | 1943 AddAddress(1, wifi[1], "test0", rtc::ADAPTER_TYPE_WIFI); |
1931 AddAddress(1, cellular[1], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 1944 AddAddress(1, cellular[1], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
1932 | 1945 |
1933 // Use only local ports for simplicity. | 1946 // Use only local ports for simplicity. |
1934 SetAllocatorFlags(0, kOnlyLocalPorts); | 1947 SetAllocatorFlags(0, kOnlyLocalPorts); |
1935 SetAllocatorFlags(1, kOnlyLocalPorts); | 1948 SetAllocatorFlags(1, kOnlyLocalPorts); |
1936 | 1949 |
1937 // Create channels and let them go writable, as usual. | 1950 // Create channels and let them go writable, as usual. |
1938 CreateChannels(1); | 1951 CreateChannels(1); |
1939 | 1952 |
1940 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1953 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1941 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1954 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1942 1000, 1000); | 1955 1000, 1000); |
1943 // Need to wait to make sure the connections on both networks are writable. | 1956 // Need to wait to make sure the connections on both networks are writable. |
1944 EXPECT_TRUE_WAIT(ep1_ch1()->best_connection() && | 1957 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection() && |
1945 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | 1958 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), |
1946 1000); | 1959 1000); |
1947 EXPECT_TRUE_WAIT(ep2_ch1()->best_connection() && | 1960 EXPECT_TRUE_WAIT(ep2_ch1()->selected_connection() && |
1948 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]), | 1961 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]), |
1949 1000); | 1962 1000); |
1950 } | 1963 } |
1951 | 1964 |
1952 // Test that the backup connection is pinged at a rate no faster than | 1965 // Test that the backup connection is pinged at a rate no faster than |
1953 // what was configured. | 1966 // what was configured. |
1954 TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) { | 1967 TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) { |
1955 AddAddress(0, kPublicAddrs[0]); | 1968 AddAddress(0, kPublicAddrs[0]); |
1956 // Adding alternate address will make sure |kPublicAddrs| has the higher | 1969 // Adding alternate address will make sure |kPublicAddrs| has the higher |
1957 // priority than others. This is due to FakeNetwork::AddInterface method. | 1970 // priority than others. This is due to FakeNetwork::AddInterface method. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 // Use only local ports for simplicity. | 2064 // Use only local ports for simplicity. |
2052 SetAllocatorFlags(0, kOnlyLocalPorts); | 2065 SetAllocatorFlags(0, kOnlyLocalPorts); |
2053 SetAllocatorFlags(1, kOnlyLocalPorts); | 2066 SetAllocatorFlags(1, kOnlyLocalPorts); |
2054 | 2067 |
2055 // Create channels and let them go writable, as usual. | 2068 // Create channels and let them go writable, as usual. |
2056 CreateChannels(1); | 2069 CreateChannels(1); |
2057 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2070 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
2058 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2071 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
2059 1000); | 2072 1000); |
2060 EXPECT_TRUE( | 2073 EXPECT_TRUE( |
2061 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 2074 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
2062 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 2075 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
2063 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 2076 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
2064 | 2077 |
2065 | 2078 |
2066 // Remove the public interface, add the alternate interface, and allocate | 2079 // Remove the public interface, add the alternate interface, and allocate |
2067 // a new generation of candidates for the new interface (via | 2080 // a new generation of candidates for the new interface (via |
2068 // MaybeStartGathering()). | 2081 // MaybeStartGathering()). |
2069 LOG(LS_INFO) << "Draining..."; | 2082 LOG(LS_INFO) << "Draining..."; |
2070 AddAddress(1, kAlternateAddrs[1]); | 2083 AddAddress(1, kAlternateAddrs[1]); |
2071 RemoveAddress(1, kPublicAddrs[1]); | 2084 RemoveAddress(1, kPublicAddrs[1]); |
2072 ep2_ch1()->MaybeStartGathering(); | 2085 ep2_ch1()->MaybeStartGathering(); |
2073 | 2086 |
2074 // We should switch over to use the alternate address after | 2087 // We should switch over to use the alternate address after |
2075 // an exchange of pings. | 2088 // an exchange of pings. |
2076 EXPECT_TRUE_WAIT( | 2089 EXPECT_TRUE_WAIT( |
2077 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 2090 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
2078 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 2091 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
2079 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 2092 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), |
2080 3000); | 2093 3000); |
2081 | 2094 |
2082 DestroyChannels(); | 2095 DestroyChannels(); |
2083 } | 2096 } |
2084 | 2097 |
2085 */ | 2098 */ |
2086 | 2099 |
2087 // A collection of tests which tests a single P2PTransportChannel by sending | 2100 // A collection of tests which tests a single P2PTransportChannel by sending |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 | 2154 |
2142 int SendData(TransportChannel& channel, | 2155 int SendData(TransportChannel& channel, |
2143 const char* data, | 2156 const char* data, |
2144 size_t len, | 2157 size_t len, |
2145 int packet_id) { | 2158 int packet_id) { |
2146 rtc::PacketOptions options; | 2159 rtc::PacketOptions options; |
2147 options.packet_id = packet_id; | 2160 options.packet_id = packet_id; |
2148 return channel.SendPacket(data, len, options, 0); | 2161 return channel.SendPacket(data, len, options, 0); |
2149 } | 2162 } |
2150 | 2163 |
| 2164 Connection* CreateConnectionWithCandidate(P2PTransportChannel& channel, |
| 2165 rtc::ScopedFakeClock& clock, |
| 2166 const std::string& ip_addr, |
| 2167 int port, |
| 2168 int priority, |
| 2169 bool writable) { |
| 2170 channel.AddRemoteCandidate( |
| 2171 CreateUdpCandidate(LOCAL_PORT_TYPE, ip_addr, port, priority)); |
| 2172 EXPECT_TRUE_SIMULATED_WAIT( |
| 2173 GetConnectionTo(&channel, ip_addr, port) != nullptr, 3000, clock); |
| 2174 Connection* conn = GetConnectionTo(&channel, ip_addr, port); |
| 2175 |
| 2176 if (conn && writable) { |
| 2177 conn->ReceivedPingResponse(LOW_RTT); // make it writable |
| 2178 } |
| 2179 return conn; |
| 2180 } |
| 2181 |
| 2182 void NominateConnection(Connection* conn) { |
| 2183 conn->set_nominated(true); |
| 2184 conn->SignalNominated(conn); |
| 2185 } |
| 2186 |
2151 void OnSelectedCandidatePairChanged( | 2187 void OnSelectedCandidatePairChanged( |
2152 TransportChannel* transport_channel, | 2188 TransportChannel* transport_channel, |
2153 CandidatePairInterface* selected_candidate_pair, | 2189 CandidatePairInterface* selected_candidate_pair, |
2154 int last_sent_packet_id) { | 2190 int last_sent_packet_id) { |
2155 last_selected_candidate_pair_ = selected_candidate_pair; | 2191 last_selected_candidate_pair_ = selected_candidate_pair; |
2156 last_sent_packet_id_ = last_sent_packet_id; | 2192 last_sent_packet_id_ = last_sent_packet_id; |
| 2193 ++selected_candidate_pair_switches_; |
2157 } | 2194 } |
2158 | 2195 |
2159 void ReceivePingOnConnection(Connection* conn, | 2196 void ReceivePingOnConnection(Connection* conn, |
2160 const std::string& remote_ufrag, | 2197 const std::string& remote_ufrag, |
2161 int priority) { | 2198 int priority) { |
2162 IceMessage msg; | 2199 IceMessage msg; |
2163 msg.SetType(STUN_BINDING_REQUEST); | 2200 msg.SetType(STUN_BINDING_REQUEST); |
2164 msg.AddAttribute(new StunByteStringAttribute( | 2201 msg.AddAttribute(new StunByteStringAttribute( |
2165 STUN_ATTR_USERNAME, | 2202 STUN_ATTR_USERNAME, |
2166 conn->local_candidate().username() + ":" + remote_ufrag)); | 2203 conn->local_candidate().username() + ":" + remote_ufrag)); |
(...skipping 13 matching lines...) Expand all Loading... |
2180 channel_state_ = channel->GetState(); | 2217 channel_state_ = channel->GetState(); |
2181 } | 2218 } |
2182 | 2219 |
2183 CandidatePairInterface* last_selected_candidate_pair() { | 2220 CandidatePairInterface* last_selected_candidate_pair() { |
2184 return last_selected_candidate_pair_; | 2221 return last_selected_candidate_pair_; |
2185 } | 2222 } |
2186 int last_sent_packet_id() { return last_sent_packet_id_; } | 2223 int last_sent_packet_id() { return last_sent_packet_id_; } |
2187 bool channel_ready_to_send() { return channel_ready_to_send_; } | 2224 bool channel_ready_to_send() { return channel_ready_to_send_; } |
2188 void reset_channel_ready_to_send() { channel_ready_to_send_ = false; } | 2225 void reset_channel_ready_to_send() { channel_ready_to_send_ = false; } |
2189 TransportChannelState channel_state() { return channel_state_; } | 2226 TransportChannelState channel_state() { return channel_state_; } |
| 2227 int get_and_reset_selected_candidate_pair_switches() { |
| 2228 int switches = selected_candidate_pair_switches_; |
| 2229 selected_candidate_pair_switches_ = 0; |
| 2230 return switches; |
| 2231 } |
2190 | 2232 |
2191 private: | 2233 private: |
2192 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 2234 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
2193 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 2235 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
2194 rtc::SocketServerScope ss_scope_; | 2236 rtc::SocketServerScope ss_scope_; |
2195 CandidatePairInterface* last_selected_candidate_pair_ = nullptr; | 2237 CandidatePairInterface* last_selected_candidate_pair_ = nullptr; |
| 2238 int selected_candidate_pair_switches_ = 0; |
2196 int last_sent_packet_id_ = -1; | 2239 int last_sent_packet_id_ = -1; |
2197 bool channel_ready_to_send_ = false; | 2240 bool channel_ready_to_send_ = false; |
2198 TransportChannelState channel_state_ = STATE_INIT; | 2241 TransportChannelState channel_state_ = STATE_INIT; |
2199 }; | 2242 }; |
2200 | 2243 |
2201 TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { | 2244 TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { |
2202 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2245 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2203 P2PTransportChannel ch("trigger checks", 1, &pa); | 2246 P2PTransportChannel ch("trigger checks", 1, &pa); |
2204 PrepareChannel(&ch); | 2247 PrepareChannel(&ch); |
2205 ch.Connect(); | 2248 ch.Connect(); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 EXPECT_EQ(500, ch.receiving_timeout()); | 2556 EXPECT_EQ(500, ch.receiving_timeout()); |
2514 EXPECT_EQ(50, ch.check_receiving_interval()); | 2557 EXPECT_EQ(50, ch.check_receiving_interval()); |
2515 ch.Connect(); | 2558 ch.Connect(); |
2516 ch.MaybeStartGathering(); | 2559 ch.MaybeStartGathering(); |
2517 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 2560 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
2518 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2561 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2519 ASSERT_TRUE(conn1 != nullptr); | 2562 ASSERT_TRUE(conn1 != nullptr); |
2520 | 2563 |
2521 conn1->ReceivedPing(); | 2564 conn1->ReceivedPing(); |
2522 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); | 2565 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); |
2523 EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000); | 2566 EXPECT_TRUE_WAIT(ch.selected_connection() != nullptr, 1000); |
2524 EXPECT_TRUE_WAIT(ch.receiving(), 1000); | 2567 EXPECT_TRUE_WAIT(ch.receiving(), 1000); |
2525 EXPECT_TRUE_WAIT(!ch.receiving(), 1000); | 2568 EXPECT_TRUE_WAIT(!ch.receiving(), 1000); |
2526 } | 2569 } |
2527 | 2570 |
2528 // The controlled side will select a connection as the "best connection" based | 2571 // The controlled side will select a connection as the "selected connection" |
2529 // on priority until the controlling side nominates a connection, at which | 2572 // based on priority until the controlling side nominates a connection, at which |
2530 // point the controlled side will select that connection as the | 2573 // point the controlled side will select that connection as the |
2531 // "best connection". Plus, SignalSelectedCandidatePair will be fired if the | 2574 // "selected connection". Plus, SignalSelectedCandidatePair will be fired if the |
2532 // best connection changes and SignalReadyToSend will be fired if the new best | 2575 // selected connection changes and SignalReadyToSend will be fired if the new |
2533 // connection is writable. | 2576 // selected connection is writable. |
2534 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { | 2577 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { |
2535 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2578 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2536 P2PTransportChannel ch("receiving state change", 1, &pa); | 2579 P2PTransportChannel ch("receiving state change", 1, &pa); |
2537 PrepareChannel(&ch); | 2580 PrepareChannel(&ch); |
2538 ch.SetIceRole(ICEROLE_CONTROLLED); | 2581 ch.SetIceRole(ICEROLE_CONTROLLED); |
2539 ch.Connect(); | 2582 ch.Connect(); |
2540 ch.MaybeStartGathering(); | 2583 ch.MaybeStartGathering(); |
2541 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 2584 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
2542 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2585 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2543 ASSERT_TRUE(conn1 != nullptr); | 2586 ASSERT_TRUE(conn1 != nullptr); |
2544 EXPECT_EQ(conn1, ch.best_connection()); | 2587 EXPECT_EQ(conn1, ch.selected_connection()); |
2545 EXPECT_EQ(conn1, last_selected_candidate_pair()); | 2588 EXPECT_EQ(conn1, last_selected_candidate_pair()); |
2546 EXPECT_EQ(-1, last_sent_packet_id()); | 2589 EXPECT_EQ(-1, last_sent_packet_id()); |
2547 // Channel is not ready to send because it is not writable. | 2590 // Channel is not ready to send because it is not writable. |
2548 EXPECT_FALSE(channel_ready_to_send()); | 2591 EXPECT_FALSE(channel_ready_to_send()); |
2549 | 2592 |
2550 int last_packet_id = 0; | 2593 int last_packet_id = 0; |
2551 const char* data = "ABCDEFGH"; | 2594 const char* data = "ABCDEFGH"; |
2552 int len = static_cast<int>(strlen(data)); | 2595 int len = static_cast<int>(strlen(data)); |
2553 SendData(ch, data, len, ++last_packet_id); | 2596 SendData(ch, data, len, ++last_packet_id); |
2554 // When a higher priority candidate comes in, the new connection is chosen | 2597 // When a higher priority candidate comes in, the new connection is chosen |
2555 // as the best connection. | 2598 // as the selected connection. |
2556 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 10)); | 2599 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 10)); |
2557 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2600 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2558 ASSERT_TRUE(conn2 != nullptr); | 2601 ASSERT_TRUE(conn2 != nullptr); |
2559 EXPECT_EQ(conn2, ch.best_connection()); | 2602 EXPECT_EQ(conn2, ch.selected_connection()); |
2560 EXPECT_EQ(conn2, last_selected_candidate_pair()); | 2603 EXPECT_EQ(conn2, last_selected_candidate_pair()); |
2561 EXPECT_EQ(last_packet_id, last_sent_packet_id()); | 2604 EXPECT_EQ(last_packet_id, last_sent_packet_id()); |
2562 EXPECT_FALSE(channel_ready_to_send()); | 2605 EXPECT_FALSE(channel_ready_to_send()); |
2563 | 2606 |
2564 // If a stun request with use-candidate attribute arrives, the receiving | 2607 // If a stun request with use-candidate attribute arrives, the receiving |
2565 // connection will be set as the best connection, even though | 2608 // connection will be set as the selected connection, even though |
2566 // its priority is lower. | 2609 // its priority is lower. |
2567 SendData(ch, data, len, ++last_packet_id); | 2610 SendData(ch, data, len, ++last_packet_id); |
2568 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 1)); | 2611 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 1)); |
2569 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 2612 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); |
2570 ASSERT_TRUE(conn3 != nullptr); | 2613 ASSERT_TRUE(conn3 != nullptr); |
2571 // Because it has a lower priority, the best connection is still conn2. | 2614 // Because it has a lower priority, the selected connection is still conn2. |
2572 EXPECT_EQ(conn2, ch.best_connection()); | 2615 EXPECT_EQ(conn2, ch.selected_connection()); |
2573 conn3->ReceivedPingResponse(LOW_RTT); // Become writable. | 2616 conn3->ReceivedPingResponse(LOW_RTT); // Become writable. |
2574 // But if it is nominated via use_candidate, it is chosen as the best | 2617 // But if it is nominated via use_candidate, it is chosen as the selected |
2575 // connection. | 2618 // connection. |
2576 conn3->set_nominated(true); | 2619 conn3->set_nominated(true); |
2577 conn3->SignalNominated(conn3); | 2620 conn3->SignalNominated(conn3); |
2578 EXPECT_EQ(conn3, ch.best_connection()); | 2621 EXPECT_EQ(conn3, ch.selected_connection()); |
2579 EXPECT_EQ(conn3, last_selected_candidate_pair()); | 2622 EXPECT_EQ(conn3, last_selected_candidate_pair()); |
2580 EXPECT_EQ(last_packet_id, last_sent_packet_id()); | 2623 EXPECT_EQ(last_packet_id, last_sent_packet_id()); |
2581 EXPECT_TRUE(channel_ready_to_send()); | 2624 EXPECT_TRUE(channel_ready_to_send()); |
2582 | 2625 |
2583 // Even if another higher priority candidate arrives, | 2626 // Even if another higher priority candidate arrives, it will not be set as |
2584 // it will not be set as the best connection because the best connection | 2627 // the selected connection because the selected connection is nominated by |
2585 // is nominated by the controlling side. | 2628 // the controlling side. |
2586 SendData(ch, data, len, ++last_packet_id); | 2629 SendData(ch, data, len, ++last_packet_id); |
2587 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "4.4.4.4", 4, 100)); | 2630 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "4.4.4.4", 4, 100)); |
2588 Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4); | 2631 Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4); |
2589 ASSERT_TRUE(conn4 != nullptr); | 2632 ASSERT_TRUE(conn4 != nullptr); |
2590 EXPECT_EQ(conn3, ch.best_connection()); | 2633 EXPECT_EQ(conn3, ch.selected_connection()); |
2591 // But if it is nominated via use_candidate and writable, it will be set as | 2634 // But if it is nominated via use_candidate and writable, it will be set as |
2592 // the best connection. | 2635 // the selected connection. |
2593 conn4->set_nominated(true); | 2636 conn4->set_nominated(true); |
2594 conn4->SignalNominated(conn4); | 2637 conn4->SignalNominated(conn4); |
2595 // Not switched yet because conn4 is not writable. | 2638 // Not switched yet because conn4 is not writable. |
2596 EXPECT_EQ(conn3, ch.best_connection()); | 2639 EXPECT_EQ(conn3, ch.selected_connection()); |
2597 reset_channel_ready_to_send(); | 2640 reset_channel_ready_to_send(); |
2598 // The best connection switches after conn4 becomes writable. | 2641 // The selected connection switches after conn4 becomes writable. |
2599 conn4->ReceivedPingResponse(LOW_RTT); | 2642 conn4->ReceivedPingResponse(LOW_RTT); |
2600 EXPECT_EQ(conn4, ch.best_connection()); | 2643 EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout); |
2601 EXPECT_EQ(conn4, last_selected_candidate_pair()); | 2644 EXPECT_EQ(conn4, last_selected_candidate_pair()); |
2602 EXPECT_EQ(last_packet_id, last_sent_packet_id()); | 2645 EXPECT_EQ(last_packet_id, last_sent_packet_id()); |
2603 // SignalReadyToSend is fired again because conn4 is writable. | 2646 // SignalReadyToSend is fired again because conn4 is writable. |
2604 EXPECT_TRUE(channel_ready_to_send()); | 2647 EXPECT_TRUE(channel_ready_to_send()); |
2605 } | 2648 } |
2606 | 2649 |
2607 // The controlled side will select a connection as the "best connection" based | 2650 // The controlled side will select a connection as the "selected connection" |
2608 // on requests from an unknown address before the controlling side nominates | 2651 // based on requests from an unknown address before the controlling side |
2609 // a connection, and will nominate a connection from an unknown address if the | 2652 // nominates a connection, and will nominate a connection from an unknown |
2610 // request contains the use_candidate attribute. Plus, it will also sends back | 2653 // address if the request contains the use_candidate attribute. Plus, it will |
2611 // a ping response and set the ICE pwd in the remote candidate appropriately. | 2654 // also sends back a ping response and set the ICE pwd in the remote candidate |
| 2655 // appropriately. |
2612 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { | 2656 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { |
2613 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2657 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2614 P2PTransportChannel ch("receiving state change", 1, &pa); | 2658 P2PTransportChannel ch("receiving state change", 1, &pa); |
2615 PrepareChannel(&ch); | 2659 PrepareChannel(&ch); |
2616 ch.SetIceRole(ICEROLE_CONTROLLED); | 2660 ch.SetIceRole(ICEROLE_CONTROLLED); |
2617 ch.Connect(); | 2661 ch.Connect(); |
2618 ch.MaybeStartGathering(); | 2662 ch.MaybeStartGathering(); |
2619 // A minimal STUN message with prflx priority. | 2663 // A minimal STUN message with prflx priority. |
2620 IceMessage request; | 2664 IceMessage request; |
2621 request.SetType(STUN_BINDING_REQUEST); | 2665 request.SetType(STUN_BINDING_REQUEST); |
2622 request.AddAttribute( | 2666 request.AddAttribute( |
2623 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); | 2667 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); |
2624 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; | 2668 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; |
2625 request.AddAttribute( | 2669 request.AddAttribute( |
2626 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); | 2670 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); |
2627 TestUDPPort* port = static_cast<TestUDPPort*>(GetPort(&ch)); | 2671 TestUDPPort* port = static_cast<TestUDPPort*>(GetPort(&ch)); |
2628 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, | 2672 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, |
2629 &request, kIceUfrag[1], false); | 2673 &request, kIceUfrag[1], false); |
2630 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2674 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2631 ASSERT_TRUE(conn1 != nullptr); | 2675 ASSERT_TRUE(conn1 != nullptr); |
2632 EXPECT_TRUE(port->sent_binding_response()); | 2676 EXPECT_TRUE(port->sent_binding_response()); |
2633 EXPECT_EQ(conn1, ch.best_connection()); | 2677 EXPECT_EQ(conn1, ch.selected_connection()); |
2634 conn1->ReceivedPingResponse(LOW_RTT); | 2678 conn1->ReceivedPingResponse(LOW_RTT); |
2635 EXPECT_EQ(conn1, ch.best_connection()); | 2679 EXPECT_EQ(conn1, ch.selected_connection()); |
2636 port->set_sent_binding_response(false); | 2680 port->set_sent_binding_response(false); |
2637 | 2681 |
2638 // Another connection is nominated via use_candidate. | 2682 // Another connection is nominated via use_candidate. |
2639 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); | 2683 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); |
2640 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2684 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2641 ASSERT_TRUE(conn2 != nullptr); | 2685 ASSERT_TRUE(conn2 != nullptr); |
2642 // Because it has a lower priority, the best connection is still conn1. | 2686 // Because it has a lower priority, the selected connection is still conn1. |
2643 EXPECT_EQ(conn1, ch.best_connection()); | 2687 EXPECT_EQ(conn1, ch.selected_connection()); |
2644 // When it is nominated via use_candidate and writable, it is chosen as the | 2688 // When it is nominated via use_candidate and writable, it is chosen as the |
2645 // best connection. | 2689 // selected connection. |
2646 conn2->ReceivedPingResponse(LOW_RTT); // Become writable. | 2690 conn2->ReceivedPingResponse(LOW_RTT); // Become writable. |
2647 conn2->set_nominated(true); | 2691 conn2->set_nominated(true); |
2648 conn2->SignalNominated(conn2); | 2692 conn2->SignalNominated(conn2); |
2649 EXPECT_EQ(conn2, ch.best_connection()); | 2693 EXPECT_EQ(conn2, ch.selected_connection()); |
2650 | 2694 |
2651 // Another request with unknown address, it will not be set as the best | 2695 // Another request with unknown address, it will not be set as the selected |
2652 // connection because the best connection was nominated by the controlling | 2696 // connection because the selected connection was nominated by the controlling |
2653 // side. | 2697 // side. |
2654 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 3), PROTO_UDP, | 2698 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 3), PROTO_UDP, |
2655 &request, kIceUfrag[1], false); | 2699 &request, kIceUfrag[1], false); |
2656 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 2700 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); |
2657 ASSERT_TRUE(conn3 != nullptr); | 2701 ASSERT_TRUE(conn3 != nullptr); |
2658 EXPECT_TRUE(port->sent_binding_response()); | 2702 EXPECT_TRUE(port->sent_binding_response()); |
2659 conn3->ReceivedPingResponse(LOW_RTT); // Become writable. | 2703 conn3->ReceivedPingResponse(LOW_RTT); // Become writable. |
2660 EXPECT_EQ(conn2, ch.best_connection()); | 2704 EXPECT_EQ(conn2, ch.selected_connection()); |
2661 port->set_sent_binding_response(false); | 2705 port->set_sent_binding_response(false); |
2662 | 2706 |
2663 // However if the request contains use_candidate attribute, it will be | 2707 // However if the request contains use_candidate attribute, it will be |
2664 // selected as the best connection. | 2708 // selected as the selected connection. |
2665 request.AddAttribute(new StunByteStringAttribute(STUN_ATTR_USE_CANDIDATE)); | 2709 request.AddAttribute(new StunByteStringAttribute(STUN_ATTR_USE_CANDIDATE)); |
2666 port->SignalUnknownAddress(port, rtc::SocketAddress("4.4.4.4", 4), PROTO_UDP, | 2710 port->SignalUnknownAddress(port, rtc::SocketAddress("4.4.4.4", 4), PROTO_UDP, |
2667 &request, kIceUfrag[1], false); | 2711 &request, kIceUfrag[1], false); |
2668 Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4); | 2712 Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4); |
2669 ASSERT_TRUE(conn4 != nullptr); | 2713 ASSERT_TRUE(conn4 != nullptr); |
2670 EXPECT_TRUE(port->sent_binding_response()); | 2714 EXPECT_TRUE(port->sent_binding_response()); |
2671 // conn4 is not the best connection yet because it is not writable. | 2715 // conn4 is not the selected connection yet because it is not writable. |
2672 EXPECT_EQ(conn2, ch.best_connection()); | 2716 EXPECT_EQ(conn2, ch.selected_connection()); |
2673 conn4->ReceivedPingResponse(LOW_RTT); // Become writable. | 2717 conn4->ReceivedPingResponse(LOW_RTT); // Become writable. |
2674 EXPECT_EQ(conn4, ch.best_connection()); | 2718 EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout); |
2675 | 2719 |
2676 // Test that the request from an unknown address contains a ufrag from an old | 2720 // Test that the request from an unknown address contains a ufrag from an old |
2677 // generation. | 2721 // generation. |
2678 port->set_sent_binding_response(false); | 2722 port->set_sent_binding_response(false); |
2679 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 2723 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); |
2680 ch.SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 2724 ch.SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
2681 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, | 2725 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, |
2682 &request, kIceUfrag[2], false); | 2726 &request, kIceUfrag[2], false); |
2683 Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); | 2727 Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); |
2684 ASSERT_TRUE(conn5 != nullptr); | 2728 ASSERT_TRUE(conn5 != nullptr); |
2685 EXPECT_TRUE(port->sent_binding_response()); | 2729 EXPECT_TRUE(port->sent_binding_response()); |
2686 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password()); | 2730 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password()); |
2687 } | 2731 } |
2688 | 2732 |
2689 // The controlled side will select a connection as the "best connection" | 2733 // The controlled side will select a connection as the "selected connection" |
2690 // based on media received until the controlling side nominates a connection, | 2734 // based on media received until the controlling side nominates a connection, |
2691 // at which point the controlled side will select that connection as | 2735 // at which point the controlled side will select that connection as |
2692 // the "best connection". | 2736 // the "selected connection". |
2693 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { | 2737 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { |
2694 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2738 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2695 P2PTransportChannel ch("receiving state change", 1, &pa); | 2739 P2PTransportChannel ch("receiving state change", 1, &pa); |
2696 PrepareChannel(&ch); | 2740 PrepareChannel(&ch); |
2697 ch.SetIceRole(ICEROLE_CONTROLLED); | 2741 ch.SetIceRole(ICEROLE_CONTROLLED); |
2698 ch.Connect(); | 2742 ch.Connect(); |
2699 ch.MaybeStartGathering(); | 2743 ch.MaybeStartGathering(); |
2700 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 10)); | 2744 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 10)); |
2701 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2745 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2702 ASSERT_TRUE(conn1 != nullptr); | 2746 ASSERT_TRUE(conn1 != nullptr); |
2703 EXPECT_EQ(conn1, ch.best_connection()); | 2747 EXPECT_EQ(conn1, ch.selected_connection()); |
2704 | 2748 |
2705 // If a data packet is received on conn2, the best connection should | 2749 // If a data packet is received on conn2, the selected connection should |
2706 // switch to conn2 because the controlled side must mirror the media path | 2750 // switch to conn2 because the controlled side must mirror the media path |
2707 // chosen by the controlling side. | 2751 // chosen by the controlling side. |
2708 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); | 2752 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); |
2709 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2753 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2710 ASSERT_TRUE(conn2 != nullptr); | 2754 ASSERT_TRUE(conn2 != nullptr); |
2711 conn2->ReceivedPing(); // Start receiving. | 2755 conn2->ReceivedPing(); // Start receiving. |
2712 // Do not switch because it is not writable. | |
2713 conn2->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); | 2756 conn2->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); |
2714 EXPECT_EQ(conn1, ch.best_connection()); | 2757 EXPECT_EQ(conn2, ch.selected_connection()); |
2715 | |
2716 conn2->ReceivedPingResponse(LOW_RTT); // Become writable. | 2758 conn2->ReceivedPingResponse(LOW_RTT); // Become writable. |
2717 // Switch because it is writable. | |
2718 conn2->OnReadPacket("DEF", 3, rtc::CreatePacketTime(0)); | |
2719 EXPECT_EQ(conn2, ch.best_connection()); | |
2720 | 2759 |
2721 // Now another STUN message with an unknown address and use_candidate will | 2760 // Now another STUN message with an unknown address and use_candidate will |
2722 // nominate the best connection. | 2761 // nominate the selected connection. |
2723 IceMessage request; | 2762 IceMessage request; |
2724 request.SetType(STUN_BINDING_REQUEST); | 2763 request.SetType(STUN_BINDING_REQUEST); |
2725 request.AddAttribute( | 2764 request.AddAttribute( |
2726 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); | 2765 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); |
2727 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; | 2766 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; |
2728 request.AddAttribute( | 2767 request.AddAttribute( |
2729 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); | 2768 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); |
2730 request.AddAttribute(new StunByteStringAttribute(STUN_ATTR_USE_CANDIDATE)); | 2769 request.AddAttribute(new StunByteStringAttribute(STUN_ATTR_USE_CANDIDATE)); |
2731 Port* port = GetPort(&ch); | 2770 Port* port = GetPort(&ch); |
2732 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 3), PROTO_UDP, | 2771 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 3), PROTO_UDP, |
2733 &request, kIceUfrag[1], false); | 2772 &request, kIceUfrag[1], false); |
2734 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 2773 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); |
2735 ASSERT_TRUE(conn3 != nullptr); | 2774 ASSERT_TRUE(conn3 != nullptr); |
2736 EXPECT_EQ(conn2, ch.best_connection()); // Not writable yet. | 2775 EXPECT_EQ(conn2, ch.selected_connection()); // Not writable yet. |
2737 conn3->ReceivedPingResponse(LOW_RTT); // Become writable. | 2776 conn3->ReceivedPingResponse(LOW_RTT); // Become writable. |
2738 EXPECT_EQ(conn3, ch.best_connection()); | 2777 EXPECT_EQ_WAIT(conn3, ch.selected_connection(), kDefaultTimeout); |
2739 | 2778 |
2740 // Now another data packet will not switch the best connection because the | 2779 // Now another data packet will not switch the selected connection because the |
2741 // best connection was nominated by the controlling side. | 2780 // selected connection was nominated by the controlling side. |
2742 conn2->ReceivedPing(); | 2781 conn2->ReceivedPing(); |
2743 conn2->ReceivedPingResponse(LOW_RTT); | 2782 conn2->ReceivedPingResponse(LOW_RTT); |
2744 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 2783 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
2745 EXPECT_EQ(conn3, ch.best_connection()); | 2784 EXPECT_EQ_WAIT(conn3, ch.selected_connection(), kDefaultTimeout); |
| 2785 } |
| 2786 |
| 2787 TEST_F(P2PTransportChannelPingTest, |
| 2788 TestControlledAgentDataReceivingTakesHigherPrecedenceThanPriority) { |
| 2789 rtc::ScopedFakeClock clock; |
| 2790 |
| 2791 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 2792 P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa); |
| 2793 PrepareChannel(&ch); |
| 2794 ch.SetIceRole(ICEROLE_CONTROLLED); |
| 2795 ch.Connect(); |
| 2796 ch.MaybeStartGathering(); |
| 2797 // The connections have decreasing priority. |
| 2798 Connection* conn1 = |
| 2799 CreateConnectionWithCandidate(ch, clock, "1.1.1.1", 1, 10, true); |
| 2800 ASSERT_TRUE(conn1 != nullptr); |
| 2801 Connection* conn2 = |
| 2802 CreateConnectionWithCandidate(ch, clock, "2.2.2.2", 2, 9, true); |
| 2803 ASSERT_TRUE(conn2 != nullptr); |
| 2804 |
| 2805 // Initially, connections are selected based on priority. |
| 2806 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2807 EXPECT_EQ(conn1, last_selected_candidate_pair()); |
| 2808 |
| 2809 // conn2 receives data; it becomes selected. |
| 2810 // Advance the clock by 1ms so that the last data receiving timestamp of |
| 2811 // conn2 is larger. |
| 2812 SIMULATED_WAIT(false, 1, clock); |
| 2813 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 2814 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2815 EXPECT_EQ(conn2, last_selected_candidate_pair()); |
| 2816 |
| 2817 // conn1 also receives data; it becomes selected due to priority again. |
| 2818 conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 2819 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2820 EXPECT_EQ(conn1, last_selected_candidate_pair()); |
| 2821 |
| 2822 // Make sure sorting won't reselect candidate pair. |
| 2823 SIMULATED_WAIT(false, 10, clock); |
| 2824 EXPECT_EQ(0, get_and_reset_selected_candidate_pair_switches()); |
| 2825 } |
| 2826 |
| 2827 TEST_F(P2PTransportChannelPingTest, |
| 2828 TestControlledAgentNominationTakesHigherPrecedenceThanDataReceiving) { |
| 2829 rtc::ScopedFakeClock clock; |
| 2830 |
| 2831 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 2832 P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa); |
| 2833 PrepareChannel(&ch); |
| 2834 ch.SetIceRole(ICEROLE_CONTROLLED); |
| 2835 ch.Connect(); |
| 2836 ch.MaybeStartGathering(); |
| 2837 // The connections have decreasing priority. |
| 2838 Connection* conn1 = |
| 2839 CreateConnectionWithCandidate(ch, clock, "1.1.1.1", 1, 10, false); |
| 2840 ASSERT_TRUE(conn1 != nullptr); |
| 2841 Connection* conn2 = |
| 2842 CreateConnectionWithCandidate(ch, clock, "2.2.2.2", 2, 9, false); |
| 2843 ASSERT_TRUE(conn2 != nullptr); |
| 2844 |
| 2845 // conn1 received data; it is the selected connection. |
| 2846 // Advance the clock to have a non-zero last-data-receiving time. |
| 2847 SIMULATED_WAIT(false, 1, clock); |
| 2848 conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 2849 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2850 EXPECT_EQ(conn1, last_selected_candidate_pair()); |
| 2851 |
| 2852 // conn2 is nominated; it becomes the selected connection. |
| 2853 NominateConnection(conn2); |
| 2854 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2855 EXPECT_EQ(conn2, last_selected_candidate_pair()); |
| 2856 |
| 2857 NominateConnection(conn1); |
| 2858 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2859 EXPECT_EQ(conn1, last_selected_candidate_pair()); |
| 2860 |
| 2861 // conn2 received data more recently; it is selected now because it |
| 2862 // received data more recently. |
| 2863 SIMULATED_WAIT(false, 1, clock); |
| 2864 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 2865 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2866 EXPECT_EQ(conn2, last_selected_candidate_pair()); |
| 2867 |
| 2868 // Make sure sorting won't reselect candidate pair. |
| 2869 SIMULATED_WAIT(false, 10, clock); |
| 2870 EXPECT_EQ(0, get_and_reset_selected_candidate_pair_switches()); |
| 2871 } |
| 2872 |
| 2873 TEST_F(P2PTransportChannelPingTest, |
| 2874 TestControlledAgentWriteStateTakesHigherPrecedenceThanNomination) { |
| 2875 rtc::ScopedFakeClock clock; |
| 2876 |
| 2877 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 2878 P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa); |
| 2879 PrepareChannel(&ch); |
| 2880 ch.SetIceRole(ICEROLE_CONTROLLED); |
| 2881 ch.Connect(); |
| 2882 ch.MaybeStartGathering(); |
| 2883 // The connections have decreasing priority. |
| 2884 Connection* conn1 = |
| 2885 CreateConnectionWithCandidate(ch, clock, "1.1.1.1", 1, 10, false); |
| 2886 ASSERT_TRUE(conn1 != nullptr); |
| 2887 Connection* conn2 = |
| 2888 CreateConnectionWithCandidate(ch, clock, "2.2.2.2", 2, 9, false); |
| 2889 ASSERT_TRUE(conn2 != nullptr); |
| 2890 |
| 2891 NominateConnection(conn1); |
| 2892 EXPECT_EQ(1, get_and_reset_selected_candidate_pair_switches()); |
| 2893 |
| 2894 // conn2 becomes writable; it is selected even though it is not nominated. |
| 2895 conn2->ReceivedPingResponse(LOW_RTT); |
| 2896 |
| 2897 EXPECT_EQ_SIMULATED_WAIT(1, get_and_reset_selected_candidate_pair_switches(), |
| 2898 kDefaultTimeout, clock); |
| 2899 EXPECT_EQ_SIMULATED_WAIT(conn2, last_selected_candidate_pair(), |
| 2900 kDefaultTimeout, clock); |
| 2901 |
| 2902 // If conn1 is also writable, it will become selected. |
| 2903 conn1->ReceivedPingResponse(LOW_RTT); |
| 2904 EXPECT_EQ_SIMULATED_WAIT(1, get_and_reset_selected_candidate_pair_switches(), |
| 2905 kDefaultTimeout, clock); |
| 2906 EXPECT_EQ_SIMULATED_WAIT(conn1, last_selected_candidate_pair(), |
| 2907 kDefaultTimeout, clock); |
| 2908 |
| 2909 // Make sure sorting won't reselect candidate pair. |
| 2910 SIMULATED_WAIT(false, 10, clock); |
| 2911 EXPECT_EQ(0, get_and_reset_selected_candidate_pair_switches()); |
2746 } | 2912 } |
2747 | 2913 |
2748 // Test that if a new remote candidate has the same address and port with | 2914 // Test that if a new remote candidate has the same address and port with |
2749 // an old one, it will be used to create a new connection. | 2915 // an old one, it will be used to create a new connection. |
2750 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) { | 2916 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) { |
2751 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2917 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2752 P2PTransportChannel ch("candidate reuse", 1, &pa); | 2918 P2PTransportChannel ch("candidate reuse", 1, &pa); |
2753 PrepareChannel(&ch); | 2919 PrepareChannel(&ch); |
2754 ch.Connect(); | 2920 ch.Connect(); |
2755 ch.MaybeStartGathering(); | 2921 ch.MaybeStartGathering(); |
(...skipping 21 matching lines...) Expand all Loading... |
2777 EXPECT_EQ(kIceUfrag[2], conn2->remote_candidate().username()); | 2943 EXPECT_EQ(kIceUfrag[2], conn2->remote_candidate().username()); |
2778 EXPECT_EQ(1u, conn2->remote_candidate().generation()); | 2944 EXPECT_EQ(1u, conn2->remote_candidate().generation()); |
2779 | 2945 |
2780 // Verify that a ping with the new ufrag can be received on the new | 2946 // Verify that a ping with the new ufrag can be received on the new |
2781 // connection. | 2947 // connection. |
2782 EXPECT_EQ(0, conn2->last_ping_received()); | 2948 EXPECT_EQ(0, conn2->last_ping_received()); |
2783 ReceivePingOnConnection(conn2, kIceUfrag[2], 1 /* priority */); | 2949 ReceivePingOnConnection(conn2, kIceUfrag[2], 1 /* priority */); |
2784 EXPECT_TRUE(conn2->last_ping_received() > 0); | 2950 EXPECT_TRUE(conn2->last_ping_received() > 0); |
2785 } | 2951 } |
2786 | 2952 |
2787 // When the current best connection is strong, lower-priority connections will | 2953 // When the current selected connection is strong, lower-priority connections |
2788 // be pruned. Otherwise, lower-priority connections are kept. | 2954 // will be pruned. Otherwise, lower-priority connections are kept. |
2789 TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { | 2955 TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { |
2790 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2956 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2791 P2PTransportChannel ch("test channel", 1, &pa); | 2957 P2PTransportChannel ch("test channel", 1, &pa); |
2792 PrepareChannel(&ch); | 2958 PrepareChannel(&ch); |
2793 ch.SetIceRole(ICEROLE_CONTROLLED); | 2959 ch.SetIceRole(ICEROLE_CONTROLLED); |
2794 ch.Connect(); | 2960 ch.Connect(); |
2795 ch.MaybeStartGathering(); | 2961 ch.MaybeStartGathering(); |
2796 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 2962 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
2797 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2963 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2798 ASSERT_TRUE(conn1 != nullptr); | 2964 ASSERT_TRUE(conn1 != nullptr); |
2799 EXPECT_EQ(conn1, ch.best_connection()); | 2965 EXPECT_EQ(conn1, ch.selected_connection()); |
2800 conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving | 2966 conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving |
2801 | 2967 |
2802 // When a higher-priority, nominated candidate comes in, the connections with | 2968 // When a higher-priority, nominated candidate comes in, the connections with |
2803 // lower-priority are pruned. | 2969 // lower-priority are pruned. |
2804 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 10)); | 2970 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 10)); |
2805 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2971 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2806 ASSERT_TRUE(conn2 != nullptr); | 2972 ASSERT_TRUE(conn2 != nullptr); |
2807 conn2->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving | 2973 conn2->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving |
2808 conn2->set_nominated(true); | 2974 conn2->set_nominated(true); |
2809 conn2->SignalNominated(conn2); | 2975 conn2->SignalNominated(conn2); |
2810 EXPECT_TRUE_WAIT(conn1->pruned(), 3000); | 2976 EXPECT_TRUE_WAIT(conn1->pruned(), 3000); |
2811 | 2977 |
2812 ch.SetIceConfig(CreateIceConfig(500, false)); | 2978 ch.SetIceConfig(CreateIceConfig(500, false)); |
2813 // Wait until conn2 becomes not receiving. | 2979 // Wait until conn2 becomes not receiving. |
2814 EXPECT_TRUE_WAIT(!conn2->receiving(), 3000); | 2980 EXPECT_TRUE_WAIT(!conn2->receiving(), 3000); |
2815 | 2981 |
2816 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 1)); | 2982 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 1)); |
2817 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 2983 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); |
2818 ASSERT_TRUE(conn3 != nullptr); | 2984 ASSERT_TRUE(conn3 != nullptr); |
2819 // The best connection should still be conn2. Even through conn3 has lower | 2985 // The selected connection should still be conn2. Even through conn3 has lower |
2820 // priority and is not receiving/writable, it is not pruned because the best | 2986 // priority and is not receiving/writable, it is not pruned because the |
2821 // connection is not receiving. | 2987 // selected connection is not receiving. |
2822 WAIT(conn3->pruned(), 1000); | 2988 WAIT(conn3->pruned(), 1000); |
2823 EXPECT_FALSE(conn3->pruned()); | 2989 EXPECT_FALSE(conn3->pruned()); |
2824 } | 2990 } |
2825 | 2991 |
| 2992 TEST_F(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) { |
| 2993 rtc::ScopedFakeClock clock; |
| 2994 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 2995 P2PTransportChannel ch("test channel", 1, &pa); |
| 2996 PrepareChannel(&ch); |
| 2997 ch.SetIceRole(ICEROLE_CONTROLLED); |
| 2998 ch.Connect(); |
| 2999 ch.MaybeStartGathering(); |
| 3000 Connection* conn1 = |
| 3001 CreateConnectionWithCandidate(ch, clock, "1.1.1.1", 1, 100, true); |
| 3002 ASSERT_TRUE(conn1 != nullptr); |
| 3003 Connection* conn2 = |
| 3004 CreateConnectionWithCandidate(ch, clock, "2.2.2.2", 2, 200, false); |
| 3005 ASSERT_TRUE(conn2 != nullptr); |
| 3006 // Even if conn1 is writable, nominated, receiving data, it should not prune |
| 3007 // conn2. |
| 3008 NominateConnection(conn1); |
| 3009 SIMULATED_WAIT(false, 1, clock); |
| 3010 conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 3011 SIMULATED_WAIT(conn2->pruned(), 100, clock); |
| 3012 EXPECT_FALSE(conn2->pruned()); |
| 3013 } |
| 3014 |
2826 // Test that GetState returns the state correctly. | 3015 // Test that GetState returns the state correctly. |
2827 TEST_F(P2PTransportChannelPingTest, TestGetState) { | 3016 TEST_F(P2PTransportChannelPingTest, TestGetState) { |
2828 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3017 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2829 P2PTransportChannel ch("test channel", 1, &pa); | 3018 P2PTransportChannel ch("test channel", 1, &pa); |
2830 PrepareChannel(&ch); | 3019 PrepareChannel(&ch); |
2831 ch.Connect(); | 3020 ch.Connect(); |
2832 ch.MaybeStartGathering(); | 3021 ch.MaybeStartGathering(); |
2833 EXPECT_EQ(TransportChannelState::STATE_INIT, ch.GetState()); | 3022 EXPECT_EQ(TransportChannelState::STATE_INIT, ch.GetState()); |
2834 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 3023 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
2835 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); | 3024 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); |
(...skipping 17 matching lines...) Expand all Loading... |
2853 TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { | 3042 TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { |
2854 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3043 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2855 P2PTransportChannel ch("test channel", 1, &pa); | 3044 P2PTransportChannel ch("test channel", 1, &pa); |
2856 PrepareChannel(&ch); | 3045 PrepareChannel(&ch); |
2857 ch.SetIceConfig(CreateIceConfig(1000, false)); | 3046 ch.SetIceConfig(CreateIceConfig(1000, false)); |
2858 ch.Connect(); | 3047 ch.Connect(); |
2859 ch.MaybeStartGathering(); | 3048 ch.MaybeStartGathering(); |
2860 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 3049 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
2861 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3050 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2862 ASSERT_TRUE(conn1 != nullptr); | 3051 ASSERT_TRUE(conn1 != nullptr); |
2863 EXPECT_EQ(conn1, ch.best_connection()); | 3052 EXPECT_EQ(conn1, ch.selected_connection()); |
2864 conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving | 3053 conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving |
2865 | 3054 |
2866 // Add a low-priority connection |conn2|, which will be pruned, but it will | 3055 // Add a low-priority connection |conn2|, which will be pruned, but it will |
2867 // not be deleted right away. Once the current best connection becomes not | 3056 // not be deleted right away. Once the current selected connection becomes not |
2868 // receiving, |conn2| will start to ping and upon receiving the ping response, | 3057 // receiving, |conn2| will start to ping and upon receiving the ping response, |
2869 // it will become the best connection. | 3058 // it will become the selected connection. |
2870 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); | 3059 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); |
2871 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3060 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2872 ASSERT_TRUE(conn2 != nullptr); | 3061 ASSERT_TRUE(conn2 != nullptr); |
2873 EXPECT_TRUE_WAIT(!conn2->active(), 1000); | 3062 EXPECT_TRUE_WAIT(!conn2->active(), 1000); |
2874 // |conn2| should not send a ping yet. | 3063 // |conn2| should not send a ping yet. |
2875 EXPECT_EQ(Connection::STATE_WAITING, conn2->state()); | 3064 EXPECT_EQ(Connection::STATE_WAITING, conn2->state()); |
2876 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); | 3065 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); |
2877 // Wait for |conn1| becoming not receiving. | 3066 // Wait for |conn1| becoming not receiving. |
2878 EXPECT_TRUE_WAIT(!conn1->receiving(), 3000); | 3067 EXPECT_TRUE_WAIT(!conn1->receiving(), 3000); |
2879 // Make sure conn2 is not deleted. | 3068 // Make sure conn2 is not deleted. |
2880 conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3069 conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2881 ASSERT_TRUE(conn2 != nullptr); | 3070 ASSERT_TRUE(conn2 != nullptr); |
2882 EXPECT_EQ_WAIT(Connection::STATE_INPROGRESS, conn2->state(), 1000); | 3071 EXPECT_EQ_WAIT(Connection::STATE_INPROGRESS, conn2->state(), 1000); |
2883 conn2->ReceivedPingResponse(LOW_RTT); | 3072 conn2->ReceivedPingResponse(LOW_RTT); |
2884 EXPECT_EQ_WAIT(conn2, ch.best_connection(), 1000); | 3073 EXPECT_EQ_WAIT(conn2, ch.selected_connection(), 1000); |
2885 EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState()); | 3074 EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState()); |
2886 | 3075 |
2887 // When |conn1| comes back again, |conn2| will be pruned again. | 3076 // When |conn1| comes back again, |conn2| will be pruned again. |
2888 conn1->ReceivedPingResponse(LOW_RTT); | 3077 conn1->ReceivedPingResponse(LOW_RTT); |
2889 EXPECT_EQ_WAIT(conn1, ch.best_connection(), 1000); | 3078 EXPECT_EQ_WAIT(conn1, ch.selected_connection(), 1000); |
2890 EXPECT_TRUE_WAIT(!conn2->active(), 1000); | 3079 EXPECT_TRUE_WAIT(!conn2->active(), 1000); |
2891 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); | 3080 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); |
2892 } | 3081 } |
2893 | 3082 |
2894 // Test that if all connections in a channel has timed out on writing, they | 3083 // Test that if all connections in a channel has timed out on writing, they |
2895 // will all be deleted. We use Prune to simulate write_time_out. | 3084 // will all be deleted. We use Prune to simulate write_time_out. |
2896 TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { | 3085 TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { |
2897 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3086 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2898 P2PTransportChannel ch("test channel", 1, &pa); | 3087 P2PTransportChannel ch("test channel", 1, &pa); |
2899 PrepareChannel(&ch); | 3088 PrepareChannel(&ch); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3087 | 3276 |
3088 private: | 3277 private: |
3089 std::unique_ptr<BasicPortAllocator> allocator_; | 3278 std::unique_ptr<BasicPortAllocator> allocator_; |
3090 rtc::FakeNetworkManager network_manager_; | 3279 rtc::FakeNetworkManager network_manager_; |
3091 TestTurnServer turn_server_; | 3280 TestTurnServer turn_server_; |
3092 std::unique_ptr<P2PTransportChannel> channel_; | 3281 std::unique_ptr<P2PTransportChannel> channel_; |
3093 }; | 3282 }; |
3094 | 3283 |
3095 // Test that Relay/Relay connections will be pinged first when no other | 3284 // Test that Relay/Relay connections will be pinged first when no other |
3096 // connections have been pinged yet, unless we need to ping a trigger check or | 3285 // connections have been pinged yet, unless we need to ping a trigger check or |
3097 // we have a best connection. | 3286 // we have a selected connection. |
3098 TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, | 3287 TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, |
3099 TestRelayRelayFirstWhenNothingPingedYet) { | 3288 TestRelayRelayFirstWhenNothingPingedYet) { |
3100 const int max_strong_interval = 100; | 3289 const int max_strong_interval = 100; |
3101 P2PTransportChannel& ch = StartTransportChannel(true, max_strong_interval); | 3290 P2PTransportChannel& ch = StartTransportChannel(true, max_strong_interval); |
3102 EXPECT_TRUE_WAIT(ch.ports().size() == 2, 5000); | 3291 EXPECT_TRUE_WAIT(ch.ports().size() == 2, 5000); |
3103 EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE); | 3292 EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE); |
3104 EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE); | 3293 EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE); |
3105 | 3294 |
3106 ch.AddRemoteCandidate(CreateUdpCandidate(RELAY_PORT_TYPE, "1.1.1.1", 1, 1)); | 3295 ch.AddRemoteCandidate(CreateUdpCandidate(RELAY_PORT_TYPE, "1.1.1.1", 1, 1)); |
3107 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); | 3296 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); |
3108 | 3297 |
3109 EXPECT_TRUE_WAIT(ch.connections().size() == 4, 5000); | 3298 EXPECT_TRUE_WAIT(ch.connections().size() == 4, 5000); |
3110 | 3299 |
3111 // Relay/Relay should be the first pingable connection. | 3300 // Relay/Relay should be the first pingable connection. |
3112 Connection* conn = FindNextPingableConnectionAndPingIt(&ch); | 3301 Connection* conn = FindNextPingableConnectionAndPingIt(&ch); |
3113 EXPECT_EQ(conn->local_candidate().type(), RELAY_PORT_TYPE); | 3302 EXPECT_EQ(conn->local_candidate().type(), RELAY_PORT_TYPE); |
3114 EXPECT_EQ(conn->remote_candidate().type(), RELAY_PORT_TYPE); | 3303 EXPECT_EQ(conn->remote_candidate().type(), RELAY_PORT_TYPE); |
3115 | 3304 |
3116 // Unless that we have a trigger check waiting to be pinged. | 3305 // Unless that we have a trigger check waiting to be pinged. |
3117 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3306 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
3118 EXPECT_EQ(conn2->local_candidate().type(), LOCAL_PORT_TYPE); | 3307 EXPECT_EQ(conn2->local_candidate().type(), LOCAL_PORT_TYPE); |
3119 EXPECT_EQ(conn2->remote_candidate().type(), LOCAL_PORT_TYPE); | 3308 EXPECT_EQ(conn2->remote_candidate().type(), LOCAL_PORT_TYPE); |
3120 conn2->ReceivedPing(); | 3309 conn2->ReceivedPing(); |
3121 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch)); | 3310 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch)); |
3122 | 3311 |
3123 // Make conn3 the best connection. | 3312 // Make conn3 the selected connection. |
3124 Connection* conn3 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3313 Connection* conn3 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
3125 EXPECT_EQ(conn3->local_candidate().type(), LOCAL_PORT_TYPE); | 3314 EXPECT_EQ(conn3->local_candidate().type(), LOCAL_PORT_TYPE); |
3126 EXPECT_EQ(conn3->remote_candidate().type(), RELAY_PORT_TYPE); | 3315 EXPECT_EQ(conn3->remote_candidate().type(), RELAY_PORT_TYPE); |
3127 conn3->ReceivedPingResponse(LOW_RTT); | 3316 conn3->ReceivedPingResponse(LOW_RTT); |
3128 ASSERT_TRUE(conn3->writable()); | 3317 ASSERT_TRUE(conn3->writable()); |
3129 conn3->ReceivedPing(); | 3318 conn3->ReceivedPing(); |
3130 | 3319 |
3131 /* | 3320 /* |
3132 | 3321 |
3133 TODO(honghaiz): Re-enable this once we use fake clock for this test to fix | 3322 TODO(honghaiz): Re-enable this once we use fake clock for this test to fix |
3134 the flakiness. The following test becomes flaky because we now ping the | 3323 the flakiness. The following test becomes flaky because we now ping the |
3135 connections with fast rates until every connection is pinged at least three | 3324 connections with fast rates until every connection is pinged at least three |
3136 times. The best connection may have been pinged before |max_strong_interval|, | 3325 times. The selected connection may have been pinged before |
3137 so it may not be the next connection to be pinged as expected in the test. | 3326 |max_strong_interval|, so it may not be the next connection to be pinged as |
| 3327 expected in the test. |
3138 | 3328 |
3139 // Verify that conn3 will be the "best connection" since it is readable and | 3329 // Verify that conn3 will be the "selected connection" since it is readable |
3140 // writable. After |MAX_CURRENT_STRONG_INTERVAL|, it should be the next | 3330 // and writable. After |MAX_CURRENT_STRONG_INTERVAL|, it should be the next |
3141 // pingable connection. | 3331 // pingable connection. |
3142 EXPECT_TRUE_WAIT(conn3 == ch.best_connection(), 5000); | 3332 EXPECT_TRUE_WAIT(conn3 == ch.selected_connection(), 5000); |
3143 WAIT(false, max_strong_interval + 100); | 3333 WAIT(false, max_strong_interval + 100); |
3144 conn3->ReceivedPingResponse(LOW_RTT); | 3334 conn3->ReceivedPingResponse(LOW_RTT); |
3145 ASSERT_TRUE(conn3->writable()); | 3335 ASSERT_TRUE(conn3->writable()); |
3146 EXPECT_EQ(conn3, FindNextPingableConnectionAndPingIt(&ch)); | 3336 EXPECT_EQ(conn3, FindNextPingableConnectionAndPingIt(&ch)); |
3147 | 3337 |
3148 */ | 3338 */ |
3149 } | 3339 } |
3150 | 3340 |
3151 // Test that Relay/Relay connections will be pinged first when everything has | 3341 // Test that Relay/Relay connections will be pinged first when everything has |
3152 // been pinged even if the Relay/Relay connection wasn't the first to be pinged | 3342 // been pinged even if the Relay/Relay connection wasn't the first to be pinged |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3238 | 3428 |
3239 // TCP Relay/Relay is the next. | 3429 // TCP Relay/Relay is the next. |
3240 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 3430 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
3241 TCP_PROTOCOL_NAME); | 3431 TCP_PROTOCOL_NAME); |
3242 | 3432 |
3243 // Finally, Local/Relay will be pinged. | 3433 // Finally, Local/Relay will be pinged. |
3244 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 3434 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
3245 } | 3435 } |
3246 | 3436 |
3247 } // namespace cricket { | 3437 } // namespace cricket { |
OLD | NEW |