shill: LinkMonitor: Test reliability of unicast responses

Some gateways do not support replying to unicast ARP.  As such,
it is on tenuous grounds that we use the unicast test to trigger
a link monitor failure.  This change delays counting of unicast
failures until it is clear that unicast replies are the norm
with the currently connected gateway.

BUG=chromium:237290,chromium:295844
TEST=Unit tests

Change-Id: I3f60c09069a31ad93aa4c71fe8d5b3e0224bda34
Reviewed-on: https://chromium-review.googlesource.com/170473
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
diff --git a/link_monitor.h b/link_monitor.h
index ff6785b..3b95269 100644
--- a/link_monitor.h
+++ b/link_monitor.h
@@ -32,11 +32,6 @@
  public:
   typedef base::Closure FailureCallback;
 
-  // When the sum of consecutive unicast and broadcast failures
-  // equals this value, the failure callback is called, the counters
-  // are reset, and the link monitoring quiesces.  Needed by Metrics.
-  static const int kFailureThreshold;
-
   // The default number of milliseconds between ARP requests. Needed by Metrics.
   static const int kDefaultTestPeriodMilliseconds;
 
@@ -44,6 +39,11 @@
   // Needed by DefaultProfile.
   static const char kDefaultLinkMonitorTechnologies[];
 
+  // When the sum of consecutive counted unicast and broadcast failures
+  // equals this value, the failure callback is called, the counters
+  // are reset, and the link monitoring quiesces.  Needed by Metrics.
+  static const int kFailureThreshold;
+
   LinkMonitor(const ConnectionRefPtr &connection,
               EventDispatcher *dispatcher,  // Owned by caller; can't be NULL.
               Metrics *metrics,  // Owned by caller; must not be NULL.
@@ -86,6 +86,11 @@
   // our simple low-pass filter works.
   static const int kMaxResponseSampleFilterDepth;
 
+  // When the sum of consecutive unicast successes equals this value,
+  // we can assume that in general this gateway supports unicast ARP
+  // requests, and we will count future unicast failures.
+  static const int kUnicastReplyReliabilityThreshold;
+
   // Similar to Start, except that the initial probes use
   // |probe_period_milliseconds|. After successfully probing with both
   // broadcast and unicast ARPs (at least one of each), LinkMonitor
@@ -148,6 +153,10 @@
   // both types of network traffic is monitored.
   bool is_unicast_;
 
+  // Whether we have observed that the gateway reliably responds
+  // to unicast ARP requests.
+  bool gateway_supports_unicast_arp_;
+
   // Number of response samples received in our rolling averge.
   int response_sample_count_;
   // The sum of response samples in our rolling average.