summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChiachang Wang <chiachangwang@google.com>2020-01-14 20:49:17 +0800
committerChiachang Wang <chiachangwang@google.com>2020-01-16 22:09:53 +0800
commitd740dc382aaf8ede8c1143f35bff28c1c4401a82 (patch)
tree9b149c7e44406651c1935a3b055cc4d4929ea5df
parentf52fa0ea16c0e2bfdc673dbadb58fdacedf7d4ec (diff)
Reduce redundant network probing and prevent probing loop
NetworkMonitor did not limit the probe usage on a non-metered network for data stall detection verification. As NM polls TCP information with certain timer(10s for now), NM may get legacy information if the data stall suspicion comes from other signals, e.g. DNS. It may cause false alarm probing on the network. The first tcp polling event will be 10s later. It may cause a loop due to dns result received w/o latest tcp info. Hence, start first polling while entering validated state. Bug: 145275899 Bug: 147673885 Test: atest NetworkStackTests NetworkStackNextTests Test: Manually test with such network and observe the probe behavior Change-Id: Icb56ebe9d8304880d4f9f4fa8153b6e3727000fb
-rw-r--r--src/com/android/networkstack/netlink/TcpSocketTracker.java2
-rw-r--r--src/com/android/server/connectivity/NetworkMonitor.java23
2 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/networkstack/netlink/TcpSocketTracker.java b/src/com/android/networkstack/netlink/TcpSocketTracker.java
index 8929cdb..78813bd 100644
--- a/src/com/android/networkstack/netlink/TcpSocketTracker.java
+++ b/src/com/android/networkstack/netlink/TcpSocketTracker.java
@@ -311,7 +311,7 @@ public class TcpSocketTracker {
}
}
final SocketInfo info = new SocketInfo(tcpInfo, family, mark, time);
- log("pollSocketsInfo, " + info);
+ log("parseSockInfo, " + info);
return info;
}
diff --git a/src/com/android/server/connectivity/NetworkMonitor.java b/src/com/android/server/connectivity/NetworkMonitor.java
index f950b47..a991156 100644
--- a/src/com/android/server/connectivity/NetworkMonitor.java
+++ b/src/com/android/server/connectivity/NetworkMonitor.java
@@ -752,9 +752,20 @@ public class NetworkMonitor extends StateMachine {
}
mEvaluationState.reportEvaluationResult(result, null /* redirectUrl */);
mValidations++;
+ initSocketTrackingIfRequired();
+ // start periodical polling.
sendTcpPollingEvent();
}
+ private void initSocketTrackingIfRequired() {
+ if (!isValidationRequired()) return;
+
+ final TcpSocketTracker tst = getTcpSocketTracker();
+ if (tst != null) {
+ tst.pollSocketsInfo();
+ }
+ }
+
@Override
public boolean processMessage(Message message) {
switch (message.what) {
@@ -2229,7 +2240,7 @@ public class NetworkMonitor extends StateMachine {
@VisibleForTesting
protected boolean isDataStall() {
Boolean result = null;
- final StringJoiner msg = VDBG_STALL ? new StringJoiner(", ") : null;
+ final StringJoiner msg = (DBG || VDBG_STALL) ? new StringJoiner(", ") : null;
// Reevaluation will generate traffic. Thus, set a minimal reevaluation timer to limit the
// possible traffic cost in metered network.
if (!mNetworkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)
@@ -2247,9 +2258,9 @@ public class NetworkMonitor extends StateMachine {
} else if (tst.isDataStallSuspected()) {
result = true;
}
- if (VDBG_STALL) {
+ if (DBG || VDBG_STALL) {
msg.add("tcp packets received=" + tst.getLatestReceivedCount())
- .add("tcp fail rate=" + tst.getLatestPacketFailPercentage());
+ .add("latest tcp fail rate=" + tst.getLatestPacketFailPercentage());
}
}
@@ -2262,13 +2273,13 @@ public class NetworkMonitor extends StateMachine {
result = true;
logNetworkEvent(NetworkEvent.NETWORK_CONSECUTIVE_DNS_TIMEOUT_FOUND);
}
- if (VDBG_STALL) {
+ if (DBG || VDBG_STALL) {
msg.add("consecutive dns timeout count="
+ mDnsStallDetector.getConsecutiveTimeoutCount());
}
}
-
- if (VDBG_STALL) {
+ // log only data stall suspected.
+ if ((DBG && Boolean.TRUE.equals(result)) || VDBG_STALL) {
log("isDataStall: result=" + result + ", " + msg);
}