Add logging of "use candidate" and when we switch ICE "best" connections.
R=guoweis@webrtc.org Review URL: https://webrtc-codereview.appspot.com/46309004 Cr-Commit-Position: refs/heads/master@{#9197}
This commit is contained in:
@ -623,15 +623,20 @@ void P2PTransportChannel::OnUseCandidate(Connection* conn) {
|
|||||||
ASSERT(worker_thread_ == rtc::Thread::Current());
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
||||||
ASSERT(ice_role_ == ICEROLE_CONTROLLED);
|
ASSERT(ice_role_ == ICEROLE_CONTROLLED);
|
||||||
ASSERT(protocol_type_ == ICEPROTO_RFC5245);
|
ASSERT(protocol_type_ == ICEPROTO_RFC5245);
|
||||||
|
|
||||||
if (conn->write_state() == Connection::STATE_WRITABLE) {
|
if (conn->write_state() == Connection::STATE_WRITABLE) {
|
||||||
if (best_connection_ != conn) {
|
if (best_connection_ != conn) {
|
||||||
pending_best_connection_ = NULL;
|
pending_best_connection_ = NULL;
|
||||||
|
LOG(LS_INFO) << "Switching best connection on controlled side: "
|
||||||
|
<< conn->ToString();
|
||||||
SwitchBestConnectionTo(conn);
|
SwitchBestConnectionTo(conn);
|
||||||
// Now we have selected the best connection, time to prune other existing
|
// Now we have selected the best connection, time to prune other existing
|
||||||
// connections and update the read/write state of the channel.
|
// connections and update the read/write state of the channel.
|
||||||
RequestSort();
|
RequestSort();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
LOG(LS_INFO) << "Not switching the best connection on controlled side yet,"
|
||||||
|
<< " because it's not writable: " << conn->ToString();
|
||||||
pending_best_connection_ = conn;
|
pending_best_connection_ = conn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -988,9 +993,12 @@ void P2PTransportChannel::SortConnections() {
|
|||||||
|
|
||||||
// If necessary, switch to the new choice.
|
// If necessary, switch to the new choice.
|
||||||
if (protocol_type_ != ICEPROTO_RFC5245 || ice_role_ == ICEROLE_CONTROLLING) {
|
if (protocol_type_ != ICEPROTO_RFC5245 || ice_role_ == ICEROLE_CONTROLLING) {
|
||||||
if (ShouldSwitch(best_connection_, top_connection))
|
if (ShouldSwitch(best_connection_, top_connection)) {
|
||||||
|
LOG(LS_INFO) << "Switching best connection on controlling side: "
|
||||||
|
<< top_connection->ToString();
|
||||||
SwitchBestConnectionTo(top_connection);
|
SwitchBestConnectionTo(top_connection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We can prune any connection for which there is a connected, writable
|
// We can prune any connection for which there is a connected, writable
|
||||||
// connection on the same network with better or equal priority. We leave
|
// connection on the same network with better or equal priority. We leave
|
||||||
@ -1265,6 +1273,8 @@ void P2PTransportChannel::OnConnectionStateChange(Connection* connection) {
|
|||||||
if (protocol_type_ == ICEPROTO_RFC5245 && ice_role_ == ICEROLE_CONTROLLED) {
|
if (protocol_type_ == ICEPROTO_RFC5245 && ice_role_ == ICEROLE_CONTROLLED) {
|
||||||
if (connection == pending_best_connection_ && connection->writable()) {
|
if (connection == pending_best_connection_ && connection->writable()) {
|
||||||
pending_best_connection_ = NULL;
|
pending_best_connection_ = NULL;
|
||||||
|
LOG(LS_INFO) << "Switching best connection on controlled side"
|
||||||
|
<< " because it's now writable: " << connection->ToString();
|
||||||
SwitchBestConnectionTo(connection);
|
SwitchBestConnectionTo(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1301,6 +1311,7 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
|
|||||||
// Since this connection is no longer an option, we can just set best to NULL
|
// Since this connection is no longer an option, we can just set best to NULL
|
||||||
// and re-choose a best assuming that there was no best connection.
|
// and re-choose a best assuming that there was no best connection.
|
||||||
if (best_connection_ == connection) {
|
if (best_connection_ == connection) {
|
||||||
|
LOG(LS_INFO) << "Best connection destroyed. Will choose a new one.";
|
||||||
SwitchBestConnectionTo(NULL);
|
SwitchBestConnectionTo(NULL);
|
||||||
RequestSort();
|
RequestSort();
|
||||||
}
|
}
|
||||||
|
@ -1319,15 +1319,16 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request,
|
|||||||
ReceivedPing();
|
ReceivedPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(pthatcher): Figure out how to use LOG_CHECK_LEVEL with a
|
|
||||||
// variable. rtc:LogCheckLevel doesn't work within Chrome.
|
|
||||||
if (LOG_CHECK_LEVEL_V(sev)) {
|
if (LOG_CHECK_LEVEL_V(sev)) {
|
||||||
|
bool use_candidate = (
|
||||||
|
response->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr);
|
||||||
std::string pings;
|
std::string pings;
|
||||||
PrintPingsSinceLastResponse(&pings, 5);
|
PrintPingsSinceLastResponse(&pings, 5);
|
||||||
LOG_JV(sev, this) << "Received STUN ping response"
|
LOG_JV(sev, this) << "Received STUN ping response"
|
||||||
<< ", id=" << rtc::hex_encode(request->id())
|
<< ", id=" << rtc::hex_encode(request->id())
|
||||||
<< ", code=0" // Makes logging easier to parse.
|
<< ", code=0" // Makes logging easier to parse.
|
||||||
<< ", rtt=" << rtt
|
<< ", rtt=" << rtt
|
||||||
|
<< ", use_candidate=" << use_candidate
|
||||||
<< ", pings_since_last_response=" << pings;
|
<< ", pings_since_last_response=" << pings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1388,8 +1389,10 @@ void Connection::OnConnectionRequestTimeout(ConnectionRequest* request) {
|
|||||||
void Connection::OnConnectionRequestSent(ConnectionRequest* request) {
|
void Connection::OnConnectionRequestSent(ConnectionRequest* request) {
|
||||||
// Log at LS_INFO if we send a ping on an unwritable connection.
|
// Log at LS_INFO if we send a ping on an unwritable connection.
|
||||||
rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE;
|
rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE;
|
||||||
|
bool use_candidate = use_candidate_attr();
|
||||||
LOG_JV(sev, this) << "Sent STUN ping"
|
LOG_JV(sev, this) << "Sent STUN ping"
|
||||||
<< ", id=" << rtc::hex_encode(request->id());
|
<< ", id=" << rtc::hex_encode(request->id())
|
||||||
|
<< ", use_candidate=" << use_candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::CheckTimeout() {
|
void Connection::CheckTimeout() {
|
||||||
|
Reference in New Issue
Block a user