Sending data to Android WiFi Direct service instead of connecting

Following the documentation here:

http://developer.android.com/training/connect-devices-wirelessly/nsd-wifi-direct.html

It looks like it is possible to transfer data to all nearby WiFi Direct devices without establishing a connection by simply putting the data in a WifiP2pDnsSdServiceInfo object. This works for my purposes as I am trying to create a simple P2P messaging application among many nearby devices. However, this looks like a misuse of the API, as it is designed to carry information to set up a connection and advertise a service. My questions:

  • What are the advantages and disadvantages of sending data this way (please ignore security)?
  • Whether there will be delays in sending / receiving messages.
  • What will be the impact on battery life?
+3


source to share


1 answer


  • The key / value pair you pass to the entity WifiP2pDnsSdServiceInfo

    will be encapsulated in DNS multicast messages as specified in DNS Provisioning of Service .

  • Multicast traffic on WiFi is especially expensive, so it is not recommended to use it for messaging. Only for critical things like service discovery.

  • Depending on the implementation (android), within the framework it is possible to concatenate all service discovery records / responses before it invokes your callbacks. This can add significant (even unpredictable) latency to your simple P2P messaging.

  • This is mostly DNS messaging, so your "messages" can be cached locally. You can also try middle-tier optimizations in DNS queries, such as pooling, retrying, query filtering, prioritization, etc.

  • There is no guarantee of reliability so that your messages could be lost.

  • Multicast traffic used here can cause significant battery drain on Android, see here



+4


source







All Articles