• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.util;
18 
19 /**
20  * Collection of utilities for data stall.
21  */
22 public class DataStallUtils {
23     /**
24      * Detect data stall via using dns timeout counts.
25      */
26     public static final int DATA_STALL_EVALUATION_TYPE_DNS = 1;
27     // Default configuration values for data stall detection.
28     public static final int DEFAULT_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD = 5;
29     public static final int DEFAULT_DATA_STALL_MIN_EVALUATE_TIME_MS = 60 * 1000;
30     public static final int DEFAULT_DATA_STALL_VALID_DNS_TIME_THRESHOLD_MS = 30 * 60 * 1000;
31     /**
32      * The threshold value for the number of consecutive dns timeout events received to be a
33      * signal of data stall. The number of consecutive timeouts needs to be {@code >=} this
34      * threshold to be considered a data stall. Set the value to {@code <= 0} to disable. Note
35      * that the value should be {@code > 0} if the DNS data stall detection is enabled.
36      *
37      */
38     public static final String CONFIG_DATA_STALL_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD =
39             "data_stall_consecutive_dns_timeout_threshold";
40 
41     /**
42      * The minimal time interval in milliseconds for data stall reevaluation.
43      *
44      */
45     public static final String CONFIG_DATA_STALL_MIN_EVALUATE_INTERVAL =
46             "data_stall_min_evaluate_interval";
47 
48     /**
49      * DNS timeouts older than this timeout (in milliseconds) are not considered for detecting
50      * a data stall.
51      *
52      */
53     public static final String CONFIG_DATA_STALL_VALID_DNS_TIME_THRESHOLD =
54             "data_stall_valid_dns_time_threshold";
55 
56     /**
57      * Which data stall detection signal to use. This is a bitmask constructed by bitwise-or-ing
58      * (i.e. {@code |}) the DATA_STALL_EVALUATION_TYPE_* values.
59      *
60      * Type: int
61      * Valid values:
62      *   {@link #DATA_STALL_EVALUATION_TYPE_DNS} : Use dns as a signal.
63      */
64     public static final String CONFIG_DATA_STALL_EVALUATION_TYPE = "data_stall_evaluation_type";
65     public static final int DEFAULT_DATA_STALL_EVALUATION_TYPES = DATA_STALL_EVALUATION_TYPE_DNS;
66     // The default number of DNS events kept of the log kept for dns signal evaluation. Each event
67     // is represented by a {@link com.android.server.connectivity.NetworkMonitor#DnsResult} objects.
68     // It's also the size of array of {@link com.android.server.connectivity.nano.DnsEvent} kept in
69     // metrics. Note that increasing the size may cause statsd log buffer bust. Need to check the
70     // design in statsd when you try to increase the size.
71     public static final int DEFAULT_DNS_LOG_SIZE = 20;
72 }
73