Perform WiFi Round Trip Time measurements with Android P

Christopher Schott
3 min readApr 18, 2018

--

With the introduction of Android P, a new API for performing WiFi Round Trip measurements was introduced. The API is based on the IEEE 802.11mc Fine Timing Measurement standard. The purpose of the Android API is to measure the distance between the Android smartphone and a nearby access point or another WiFi aware peer. As a result of such a ranging, the distance between smartphone and access point is returned.

Requirements

There are some requirements for the smartphone respectively the used access point:

  • The smartphone has to support the ranging standard by hardware. Newer smartphones using e.g. a Qualcomm Snapdragon 820 CPU should do that.
  • Android P installed on the smartphone.
  • The access point has to support the IEEE 802.11mc FTM standard.

Initial Checks

First of all create an Android Project with Android P as minSdkVersion. Afterwards you can retrieve an instance of the WifiRttManager and you can check whether your smartphone supports the ranging via WiFi:

Perform WiFi Scan

A simple way to perform the distance ranging with a WiFi in range of the smartphone is to get a ScanResult from the AndroidWifiManager . The following snippets gives an example how a WiFi scan can be performed. Most important line of code is the filter, if the WiFi supports the IEEE 802.11mc FTM standard:
if (network.is80211mcResponder()) {
If the WiFi supports the standard it returns true, otherwise false.

Perform Ranging

The ScanResult from the WiFi scan can be used as input for performing the ranging. As a first task a RangingRequest has to be created using the ScanResult:

The 2nd parameter of the startRanging function is a callback, which needs to be created next:

Finally you can use the WifiRttManager to start the ranging:

The OS will perform the ranging asynchronous and will call the respectively callback function. The RangingResult object contains the measured distance in millimeter between smartphone and access point: rangingResult. getDistanceMm() .

Conclusion and Details on GitHub

My first experiments showed a quite poor result quality. Despite the phone was only about one meter away from the access point, the result indicate a much higher distance. I tested with a Pixel phone and our custom Intel Galileo build access point. I am not sure what was causing the “wrong” results, might be the access point as well. One very good point from my point of view is that no classical WiFi connection is required between smartphone and access point.

The official documentation about the RTT feature can be found here: https://developer.android.com/reference/android/net/wifi/rtt/WifiRttManager.html

You can find the source code of my test application on GitHub:
https://github.com/Plinzen/android-rttmanager-sample
It basically consists of two screens. The first one informs about the capabilities of the smartphone and performs the WiFi scan:

The 2nd one performs the ranging and shows the result:

--

--