From dda828f707b1505f75a62a66c7bdb59f13e183fd Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Fri, 28 Jan 2022 14:49:34 +0100 Subject: [PATCH] Field trials for DSCP Add a field trial "WebRTC-DscpFieldTrial" that allows user to set any int value to be used as tagging. This tag value will be used for all packets on the PeerConnection, whether they are audio, video, data or ICE e.g WebRTC-DscpFieldTrial/override_dscp:40/ see https://webrtc.googlesource.com/src/+/b477fc73cfd2f4c09bb9c416b170ba4b566cecaf/rtc_base/dscp.h for names of popular ints. Bug: webrtc:13622 Change-Id: Iedbedd0f918100259678eb5bc083c9bf89b343b1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249786 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#35848} --- p2p/base/p2p_transport_channel.cc | 14 ++++++++++++++ p2p/base/p2p_transport_channel_ice_field_trials.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 47f858e272..18d921c979 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -775,6 +775,16 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { ice_controller_->SetIceConfig(config_); + // DSCP override, allow user to specify (any) int value + // that will be used for tagging all packets. + webrtc::StructParametersParser::Create("override_dscp", + &field_trials_.override_dscp) + ->Parse(webrtc::field_trial::FindFullName("WebRTC-DscpFieldTrial")); + + if (field_trials_.override_dscp) { + SetOption(rtc::Socket::OPT_DSCP, *field_trials_.override_dscp); + } + RTC_DCHECK(ValidateIceConfig(config_).ok()); } @@ -1529,6 +1539,10 @@ void P2PTransportChannel::RememberRemoteCandidate( // port objects. int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) { RTC_DCHECK_RUN_ON(network_thread_); + if (field_trials_.override_dscp && opt == rtc::Socket::OPT_DSCP) { + value = *field_trials_.override_dscp; + } + OptionMap::iterator it = options_.find(opt); if (it == options_.end()) { options_.insert(std::make_pair(opt, value)); diff --git a/p2p/base/p2p_transport_channel_ice_field_trials.h b/p2p/base/p2p_transport_channel_ice_field_trials.h index 4987f1cbcb..f05623dd36 100644 --- a/p2p/base/p2p_transport_channel_ice_field_trials.h +++ b/p2p/base/p2p_transport_channel_ice_field_trials.h @@ -61,6 +61,9 @@ struct IceFieldTrials { // Stop gathering when having a strong connection. bool stop_gather_on_strongly_connected = true; + + // DSCP taging. + absl::optional override_dscp; }; } // namespace cricket