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

Unified Diff: webrtc/p2p/base/stunrequest.cc

Issue 1274273005: Revert "Remove GICE (gone forever!) and PORTALLOCATOR_ENABLE_SHARED_UFRAG (enabled forever)." becau… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Increase STUN RTOs Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/stunrequest.cc
diff --git a/webrtc/p2p/base/stunrequest.cc b/webrtc/p2p/base/stunrequest.cc
index 57c3c2e4a5864e74212302ed9e92f4b761d8ef00..9b1f22c7ffb318db4d2f56c17a696472dd98fc61 100644
--- a/webrtc/p2p/base/stunrequest.cc
+++ b/webrtc/p2p/base/stunrequest.cc
@@ -22,9 +22,19 @@ namespace cricket {
const uint32_t MSG_STUN_SEND = 1;
-const int MAX_SENDS = 9;
-const int DELAY_UNIT = 100; // 100 milliseconds
-const int DELAY_MAX_FACTOR = 16;
+// RFC 5389 says SHOULD be 500ms.
+// For years, this was 100ms, but then it was discovered that this doesn't
+// work well for networks with a high RTT (such as 2G networks).
+const int STUN_INITIAL_RTO = 250; // milliseconds
+// The timeout doubles each retransmission, up to this many times
+// RFC 5389 says SHOULD retransmit 7 times.
+const int STUN_MAX_RETRANSMISSIONS = 8; // Total sends: 9
+const int STUN_MAX_SENDS = STUN_MAX_RETRANSMISSIONS + 1;
+// We also cap the doubling, even though the standard doesn't say to.
+const int STUN_MAX_RTO = 8000; // milliseconds, or 5 doublings
+// Total max timeouts: 39.75 seconds
+// For years, this was 9.5 seconds, but for networks that experience moments of
+// high RTT (such as 40s on 2G networks), this doesn't work well.
StunRequestManager::StunRequestManager(rtc::Thread* thread)
: thread_(thread) {
@@ -226,7 +236,7 @@ void StunRequest::OnMessage(rtc::Message* pmsg) {
void StunRequest::OnSent() {
count_ += 1;
- if (count_ == MAX_SENDS) {
+ if (count_ == STUN_MAX_SENDS) {
timeout_ = true;
}
LOG(LS_VERBOSE) << "Sent STUN request " << count_
@@ -237,7 +247,7 @@ int StunRequest::resend_delay() {
if (count_ == 0) {
return 0;
}
- return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR);
+ return std::min((STUN_INITIAL_RTO << (count_ - 1)), STUN_MAX_RTO);
}
} // namespace cricket
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698