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

Side by Side Diff: webrtc/p2p/base/port.cc

Issue 1815473002: Add 16-bit network id to the candidate signaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Remove the old NETWORK_COST attribute. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 const std::string& relay_protocol, 235 const std::string& relay_protocol,
236 const std::string& tcptype, 236 const std::string& tcptype,
237 const std::string& type, 237 const std::string& type,
238 uint32_t type_preference, 238 uint32_t type_preference,
239 uint32_t relay_preference, 239 uint32_t relay_preference,
240 bool final) { 240 bool final) {
241 if (protocol == TCP_PROTOCOL_NAME && type == LOCAL_PORT_TYPE) { 241 if (protocol == TCP_PROTOCOL_NAME && type == LOCAL_PORT_TYPE) {
242 ASSERT(!tcptype.empty()); 242 ASSERT(!tcptype.empty());
243 } 243 }
244 244
245 Candidate c; 245 std::string foundation =
246 c.set_id(rtc::CreateRandomString(8)); 246 ComputeFoundation(type, protocol, relay_protocol, base_address);
247 c.set_component(component_); 247 Candidate c(component_, protocol, address, 0U, username_fragment(), password_,
248 c.set_type(type); 248 type, generation_, foundation, network_->id(), network_cost_);
249 c.set_protocol(protocol); 249 c.set_priority(
250 c.GetPriority(type_preference, network_->preference(), relay_preference));
250 c.set_relay_protocol(relay_protocol); 251 c.set_relay_protocol(relay_protocol);
251 c.set_tcptype(tcptype); 252 c.set_tcptype(tcptype);
252 c.set_address(address);
253 c.set_priority(c.GetPriority(type_preference, network_->preference(),
254 relay_preference));
255 c.set_username(username_fragment());
256 c.set_password(password_);
257 c.set_network_name(network_->name()); 253 c.set_network_name(network_->name());
258 c.set_network_type(network_->type()); 254 c.set_network_type(network_->type());
259 c.set_network_cost(network_cost_);
260 c.set_generation(generation_);
261 c.set_related_address(related_address); 255 c.set_related_address(related_address);
262 c.set_foundation(
263 ComputeFoundation(type, protocol, relay_protocol, base_address));
264 candidates_.push_back(c); 256 candidates_.push_back(c);
265 SignalCandidateReady(this, c); 257 SignalCandidateReady(this, c);
266 258
267 if (final) { 259 if (final) {
268 SignalPortComplete(this); 260 SignalPortComplete(this);
269 } 261 }
270 } 262 }
271 263
272 void Port::AddConnection(Connection* conn) { 264 void Port::AddConnection(Connection* conn) {
273 connections_[conn->remote_candidate().address()] = conn; 265 connections_[conn->remote_candidate().address()] = conn;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 request->AddAttribute( 690 request->AddAttribute(
699 new StunByteStringAttribute(STUN_ATTR_USERNAME, username)); 691 new StunByteStringAttribute(STUN_ATTR_USERNAME, username));
700 692
701 // connection_ already holds this ping, so subtract one from count. 693 // connection_ already holds this ping, so subtract one from count.
702 if (connection_->port()->send_retransmit_count_attribute()) { 694 if (connection_->port()->send_retransmit_count_attribute()) {
703 request->AddAttribute(new StunUInt32Attribute( 695 request->AddAttribute(new StunUInt32Attribute(
704 STUN_ATTR_RETRANSMIT_COUNT, 696 STUN_ATTR_RETRANSMIT_COUNT,
705 static_cast<uint32_t>(connection_->pings_since_last_response_.size() - 697 static_cast<uint32_t>(connection_->pings_since_last_response_.size() -
706 1))); 698 1)));
707 } 699 }
708 uint32_t network_cost = connection_->port()->network_cost(); 700 uint32_t network_info = connection_->port()->Network()->id();
709 if (network_cost > 0) { 701 network_info = (network_info << 16) | connection_->port()->network_cost();
710 request->AddAttribute( 702 request->AddAttribute(
711 new StunUInt32Attribute(STUN_ATTR_NETWORK_COST, network_cost)); 703 new StunUInt32Attribute(STUN_ATTR_NETWORK_INFO, network_info));
712 }
713 704
714 // Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role. 705 // Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role.
715 if (connection_->port()->GetIceRole() == ICEROLE_CONTROLLING) { 706 if (connection_->port()->GetIceRole() == ICEROLE_CONTROLLING) {
716 request->AddAttribute(new StunUInt64Attribute( 707 request->AddAttribute(new StunUInt64Attribute(
717 STUN_ATTR_ICE_CONTROLLING, connection_->port()->IceTiebreaker())); 708 STUN_ATTR_ICE_CONTROLLING, connection_->port()->IceTiebreaker()));
718 // Since we are trying aggressive nomination, sending USE-CANDIDATE 709 // Since we are trying aggressive nomination, sending USE-CANDIDATE
719 // attribute in every ping. 710 // attribute in every ping.
720 // If we are dealing with a ice-lite end point, nomination flag 711 // If we are dealing with a ice-lite end point, nomination flag
721 // in Connection will be set to false by default. Once the connection 712 // in Connection will be set to false by default. Once the connection
722 // becomes "best connection", nomination flag will be turned on. 713 // becomes "best connection", nomination flag will be turned on.
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 new_local_candidate.set_id(id); 1396 new_local_candidate.set_id(id);
1406 new_local_candidate.set_component(local_candidate().component()); 1397 new_local_candidate.set_component(local_candidate().component());
1407 new_local_candidate.set_type(PRFLX_PORT_TYPE); 1398 new_local_candidate.set_type(PRFLX_PORT_TYPE);
1408 new_local_candidate.set_protocol(local_candidate().protocol()); 1399 new_local_candidate.set_protocol(local_candidate().protocol());
1409 new_local_candidate.set_address(addr->GetAddress()); 1400 new_local_candidate.set_address(addr->GetAddress());
1410 new_local_candidate.set_priority(priority); 1401 new_local_candidate.set_priority(priority);
1411 new_local_candidate.set_username(local_candidate().username()); 1402 new_local_candidate.set_username(local_candidate().username());
1412 new_local_candidate.set_password(local_candidate().password()); 1403 new_local_candidate.set_password(local_candidate().password());
1413 new_local_candidate.set_network_name(local_candidate().network_name()); 1404 new_local_candidate.set_network_name(local_candidate().network_name());
1414 new_local_candidate.set_network_type(local_candidate().network_type()); 1405 new_local_candidate.set_network_type(local_candidate().network_type());
1415 new_local_candidate.set_network_cost(local_candidate().network_cost());
1416 new_local_candidate.set_related_address(local_candidate().address()); 1406 new_local_candidate.set_related_address(local_candidate().address());
1417 new_local_candidate.set_foundation(ComputeFoundation( 1407 new_local_candidate.set_foundation(ComputeFoundation(
1418 PRFLX_PORT_TYPE, local_candidate().protocol(), 1408 PRFLX_PORT_TYPE, local_candidate().protocol(),
1419 local_candidate().relay_protocol(), local_candidate().address())); 1409 local_candidate().relay_protocol(), local_candidate().address()));
1410 new_local_candidate.set_network_id(local_candidate().network_id());
1411 new_local_candidate.set_network_cost(local_candidate().network_cost());
1420 1412
1421 // Change the local candidate of this Connection to the new prflx candidate. 1413 // Change the local candidate of this Connection to the new prflx candidate.
1422 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); 1414 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate);
1423 1415
1424 // SignalStateChange to force a re-sort in P2PTransportChannel as this 1416 // SignalStateChange to force a re-sort in P2PTransportChannel as this
1425 // Connection's local candidate has changed. 1417 // Connection's local candidate has changed.
1426 SignalStateChange(this); 1418 SignalStateChange(this);
1427 } 1419 }
1428 1420
1429 ProxyConnection::ProxyConnection(Port* port, 1421 ProxyConnection::ProxyConnection(Port* port,
(...skipping 14 matching lines...) Expand all
1444 ASSERT(sent < 0); 1436 ASSERT(sent < 0);
1445 error_ = port_->GetError(); 1437 error_ = port_->GetError();
1446 sent_packets_discarded_++; 1438 sent_packets_discarded_++;
1447 } else { 1439 } else {
1448 send_rate_tracker_.AddSamples(sent); 1440 send_rate_tracker_.AddSamples(sent);
1449 } 1441 }
1450 return sent; 1442 return sent;
1451 } 1443 }
1452 1444
1453 } // namespace cricket 1445 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698