title: Why readings for WiFi link speed and bandwidth don't correlate?
body: <p>I want to get the "speed" for my WiFi connection.</p>
  
  <p>From <code>NetworkCapabilities</code> class, I get:</p>
  
  <pre><code>Link downstream bandwidth: 1048576 Kbps
  Link upstream bandwidth:   1048576 Kbps
  </code></pre>
  
  <p>However, using <code>WiFiInfo</code> class I get:</p>
  
  <pre><code>Link speed:                200000 Kbps
  </code></pre>
  
  <p>Why values are different?</p>
  
  <p>From my research, I concluded, that <code>NetworkCapabilities</code> class doesn't actually MEASURE bandwidth - it just returns EXPECTED values for detected technology (WiFi, cellular, etc.). I guess, that <code>WiFiInfo</code> does the same thing. I ran the code many times during extended period of time and got the same values you see above.</p>
  
  <hr>
  
  <h2>Code</h2>
  
  <p>Here is the code with <code>NetworkCapabilities</code>:</p>
  
  <pre><code>val connectivityManager = context.getSystemService(ConnectivityManager::class.java)    
  
  val networkCapabilities: NetworkCapabilities?
              get() = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
  
      networkCapabilities?.linkDownstreamBandwidthKbps // 1048576
      networkCapabilities?.linkUpstreamBandwidthKbps   // 1048576
  </code></pre>
  
  <p>Here is the code with <code>WiFiInfo</code>:</p>
  
  <pre><code>val wifiManager = context.getSystemService(WifiManager::class.java)
  wifiManager.connectionInfo.linkSpeed // returns 200 Mbps
  </code></pre>