Commit 8203e3b1 authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Expose typical network quality from NQE

Add an API that exposes typical network
quality for a given effective connection type. This API
would be used to set RTT and throughput values when
effective connection type value is overridden
due to holdback experiment, or otherwise.

Bug: 880545
Change-Id: If83593e31e44e2e0e9ab8357a673300e032cea9e
Reviewed-on: https://chromium-review.googlesource.com/1249962Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595247}
parent 8b635aaa
...@@ -238,6 +238,24 @@ void ObtainDefaultObservations( ...@@ -238,6 +238,24 @@ void ObtainDefaultObservations(
} }
} }
// Typical HTTP RTT value corresponding to a given WebEffectiveConnectionType
// value. Taken from
// https://cs.chromium.org/chromium/src/net/nqe/network_quality_estimator_params.cc.
const base::TimeDelta kTypicalHttpRttEffectiveConnectionType
[net::EFFECTIVE_CONNECTION_TYPE_LAST] = {
base::TimeDelta::FromMilliseconds(0),
base::TimeDelta::FromMilliseconds(0),
base::TimeDelta::FromMilliseconds(3600),
base::TimeDelta::FromMilliseconds(1800),
base::TimeDelta::FromMilliseconds(450),
base::TimeDelta::FromMilliseconds(175)};
// Typical downlink throughput (in Mbps) value corresponding to a given
// WebEffectiveConnectionType value. Taken from
// https://cs.chromium.org/chromium/src/net/nqe/network_quality_estimator_params.cc.
const int32_t kTypicalDownlinkKbpsEffectiveConnectionType
[net::EFFECTIVE_CONNECTION_TYPE_LAST] = {0, 0, 40, 75, 400, 1600};
// Sets |typical_network_quality| to typical network quality for different // Sets |typical_network_quality| to typical network quality for different
// effective connection types. // effective connection types.
void ObtainTypicalNetworkQualities( void ObtainTypicalNetworkQualities(
...@@ -257,30 +275,39 @@ void ObtainTypicalNetworkQualities( ...@@ -257,30 +275,39 @@ void ObtainTypicalNetworkQualities(
// Set to the 77.5th percentile of 2G RTT observations on Android. // Set to the 77.5th percentile of 2G RTT observations on Android.
// This corresponds to the median RTT observation when effective // This corresponds to the median RTT observation when effective
// connection type is Slow 2G. // connection type is Slow 2G.
base::TimeDelta::FromMilliseconds(3600), kTypicalHttpRttEffectiveConnectionType
base::TimeDelta::FromMilliseconds(3000), 40); [EFFECTIVE_CONNECTION_TYPE_SLOW_2G],
base::TimeDelta::FromMilliseconds(3000),
kTypicalDownlinkKbpsEffectiveConnectionType
[EFFECTIVE_CONNECTION_TYPE_SLOW_2G]);
typical_network_quality[EFFECTIVE_CONNECTION_TYPE_2G] = typical_network_quality[EFFECTIVE_CONNECTION_TYPE_2G] =
nqe::internal::NetworkQuality( nqe::internal::NetworkQuality(
// Set to the 58th percentile of 2G RTT observations on Android. This // Set to the 58th percentile of 2G RTT observations on Android. This
// corresponds to the median RTT observation when effective connection // corresponds to the median RTT observation when effective connection
// type is 2G. // type is 2G.
base::TimeDelta::FromMilliseconds(1800), kTypicalHttpRttEffectiveConnectionType[EFFECTIVE_CONNECTION_TYPE_2G],
base::TimeDelta::FromMilliseconds(1500), 75); base::TimeDelta::FromMilliseconds(1500),
kTypicalDownlinkKbpsEffectiveConnectionType
[EFFECTIVE_CONNECTION_TYPE_2G]);
typical_network_quality[EFFECTIVE_CONNECTION_TYPE_3G] = typical_network_quality[EFFECTIVE_CONNECTION_TYPE_3G] =
nqe::internal::NetworkQuality( nqe::internal::NetworkQuality(
// Set to the 75th percentile of 3G RTT observations on Android. This // Set to the 75th percentile of 3G RTT observations on Android. This
// corresponds to the median RTT observation when effective connection // corresponds to the median RTT observation when effective connection
// type is 3G. // type is 3G.
base::TimeDelta::FromMilliseconds(450), kTypicalHttpRttEffectiveConnectionType[EFFECTIVE_CONNECTION_TYPE_3G],
base::TimeDelta::FromMilliseconds(400), 400); base::TimeDelta::FromMilliseconds(400),
kTypicalDownlinkKbpsEffectiveConnectionType
[EFFECTIVE_CONNECTION_TYPE_3G]);
// Set to the 25th percentile of 3G RTT observations on Android. // Set to the 25th percentile of 3G RTT observations on Android.
typical_network_quality[EFFECTIVE_CONNECTION_TYPE_4G] = typical_network_quality[EFFECTIVE_CONNECTION_TYPE_4G] =
nqe::internal::NetworkQuality(base::TimeDelta::FromMilliseconds(175), nqe::internal::NetworkQuality(
base::TimeDelta::FromMilliseconds(125), kTypicalHttpRttEffectiveConnectionType[EFFECTIVE_CONNECTION_TYPE_4G],
1600); base::TimeDelta::FromMilliseconds(125),
kTypicalDownlinkKbpsEffectiveConnectionType
[EFFECTIVE_CONNECTION_TYPE_4G]);
static_assert( static_assert(
EFFECTIVE_CONNECTION_TYPE_4G + 1 == EFFECTIVE_CONNECTION_TYPE_LAST, EFFECTIVE_CONNECTION_TYPE_4G + 1 == EFFECTIVE_CONNECTION_TYPE_LAST,
...@@ -518,6 +545,18 @@ bool NetworkQualityEstimatorParams::use_small_responses() const { ...@@ -518,6 +545,18 @@ bool NetworkQualityEstimatorParams::use_small_responses() const {
return use_small_responses_; return use_small_responses_;
}; };
// static
base::TimeDelta NetworkQualityEstimatorParams::GetDefaultTypicalHttpRtt(
EffectiveConnectionType effective_connection_type) {
return kTypicalHttpRttEffectiveConnectionType[effective_connection_type];
}
// static
int32_t NetworkQualityEstimatorParams::GetDefaultTypicalDownlinkKbps(
EffectiveConnectionType effective_connection_type) {
return kTypicalDownlinkKbpsEffectiveConnectionType[effective_connection_type];
}
void NetworkQualityEstimatorParams::SetForcedEffectiveConnectionTypeForTesting( void NetworkQualityEstimatorParams::SetForcedEffectiveConnectionTypeForTesting(
EffectiveConnectionType type) { EffectiveConnectionType type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
...@@ -174,6 +174,18 @@ class NET_EXPORT NetworkQualityEstimatorParams { ...@@ -174,6 +174,18 @@ class NET_EXPORT NetworkQualityEstimatorParams {
// network quality. Set to true only for tests. // network quality. Set to true only for tests.
bool use_small_responses() const; bool use_small_responses() const;
// Returns the typical HTTP RTT that maps to the given
// |effective_connection_type|. May return invalid value if
// |effective_connection_type| is less than Slow2G or faster than 4G,
static base::TimeDelta GetDefaultTypicalHttpRtt(
EffectiveConnectionType effective_connection_type);
// Returns the typical downslink throughput (in kbps) that maps to the given
// |effective_connection_type|. May return invalid value if
// |effective_connection_type| is less than Slow2G or faster than 4G,
static int32_t GetDefaultTypicalDownlinkKbps(
EffectiveConnectionType effective_connection_type);
// |use_small_responses| should only be true when testing. // |use_small_responses| should only be true when testing.
// Allows the responses smaller than |kMinTransferSizeInBits| to be used for // Allows the responses smaller than |kMinTransferSizeInBits| to be used for
// network quality estimation. // network quality estimation.
......
...@@ -83,6 +83,12 @@ TEST(NetworkQualityEstimatorParamsTest, TypicalNetworkQualities) { ...@@ -83,6 +83,12 @@ TEST(NetworkQualityEstimatorParamsTest, TypicalNetworkQualities) {
params.TypicalNetworkQuality(ect).downstream_throughput_kbps()); params.TypicalNetworkQuality(ect).downstream_throughput_kbps());
EXPECT_EQ(nqe::internal::INVALID_RTT_THROUGHPUT, EXPECT_EQ(nqe::internal::INVALID_RTT_THROUGHPUT,
params.ConnectionThreshold(ect).downstream_throughput_kbps()); params.ConnectionThreshold(ect).downstream_throughput_kbps());
EXPECT_EQ(params.TypicalNetworkQuality(ect).http_rtt(),
NetworkQualityEstimatorParams::GetDefaultTypicalHttpRtt(ect));
EXPECT_EQ(
params.TypicalNetworkQuality(ect).downstream_throughput_kbps(),
NetworkQualityEstimatorParams::GetDefaultTypicalDownlinkKbps(ect));
} }
// The typical network quality of 4G connection should be at least as fast // The typical network quality of 4G connection should be at least as fast
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment