From 1e435628366fb9fed71632369f05928ed857d8ef Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Mon, 23 May 2016 12:48:50 -0700 Subject: [PATCH] Change initial DTLS retransmission timer from 1 second to 50ms. This will help ensure a timely DTLS handshake when there's packet loss. It will likely result in spurious retransmissions (since the RTT is usually > 50ms), but since exponential backoff is still used, there will at most be ~4 extra retransmissions. For a time-sensitive application like WebRTC this seems like a reasonable tradeoff. R=juberti@chromium.org, juberti@webrtc.org, pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1981463002 . Cr-Commit-Position: refs/heads/master@{#12853} --- webrtc/base/opensslstreamadapter.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc index abdf5e4834..c2cf00779a 100644 --- a/webrtc/base/opensslstreamadapter.cc +++ b/webrtc/base/opensslstreamadapter.cc @@ -771,13 +771,19 @@ int OpenSSLStreamAdapter::BeginSSL() { SSL_set_app_data(ssl_, this); SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now. -#ifndef OPENSSL_IS_BORINGSSL if (ssl_mode_ == SSL_MODE_DTLS) { +#ifdef OPENSSL_IS_BORINGSSL + // Change the initial retransmission timer from 1 second to 50ms. + // This will likely result in some spurious retransmissions, but + // it's useful for ensuring a timely handshake when there's packet + // loss. + DTLSv1_set_initial_timeout_duration(ssl_, 50); +#else // Enable read-ahead for DTLS so whole packets are read from internal BIO // before parsing. This is done internally by BoringSSL for DTLS. SSL_set_read_ahead(ssl_, 1); - } #endif + } SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);