... | @@ -427,36 +427,32 @@ Some Android devices cannot receive multicast packets at all, or can only receiv |
... | @@ -427,36 +427,32 @@ Some Android devices cannot receive multicast packets at all, or can only receiv |
|
|
|
|
|
### Network Service Discovery (NSD)
|
|
### Network Service Discovery (NSD)
|
|
|
|
|
|
Android's Network Service Discovery (NSD) API provides service advertising and discovery on the local network via mDNS and DNS-SD. The NSD API can interoperate with Apple's Bonjour API, which could be useful for cross-platform communication.
|
|
Android's Network Service Discovery (NSD) API provides service discovery on the local network via mDNS and DNS-SD. The NSD API can interoperate with Apple's Bonjour API, which could be useful for cross-platform communication.
|
|
|
|
|
|
(Android's Wi-Fi Direct API also provides service discovery and advertising via mDNS/DNS-SD, as well as UPnP. Wi-Fi Direct service discovery doesn't interoperate with NSD, but it may simplify the implementation of higher layers if the same service definitions can be used for LAN and Wi-Fi Direct transports.)
|
|
(Android's [Wi-Fi Direct API](#wi-fi-direct) also provides service discovery via mDNS/DNS-SD, as well as UPnP. Wi-Fi Direct service discovery doesn't interoperate with NSD, but it may simplify the implementation of higher layers if the same service definitions can be used for LAN and Wi-Fi Direct transports.)
|
|
|
|
|
|
#### Peer Advertisement
|
|
#### Peer Advertisement
|
|
|
|
|
|
<https://developer.android.com/training/connect-devices-wirelessly/nsd#register>
|
|
<https://developer.android.com/training/connect-devices-wirelessly/nsd#register>
|
|
|
|
|
|
|
|
The advertisement for an NSD service includes an instance name, a service type, and a set of key-value pairs known as attributes.
|
|
|
|
|
|
#### Peer Discovery
|
|
#### Peer Discovery
|
|
|
|
|
|
<https://developer.android.com/training/connect-devices-wirelessly/nsd#discover>
|
|
<https://developer.android.com/training/connect-devices-wirelessly/nsd#discover>
|
|
|
|
|
|
|
|
Services are discovered by specifying a service type.
|
|
|
|
The app receives the instance name and attributes of discovered services.
|
|
|
|
However, some devices (eg Huawei P8 Lite 2015, Moto G 4G, Moto E3) don't receive the attributes.
|
|
|
|
This appears to be an Android bug that was fixed in Android version 7 (API level 24):
|
|
|
|
<https://issuetracker.google.com/issues/37020436>
|
|
|
|
|
|
#### Peer Connectivity
|
|
#### Peer Connectivity
|
|
|
|
|
|
<https://developer.android.com/training/connect-devices-wirelessly/nsd#connect>
|
|
<https://developer.android.com/training/connect-devices-wirelessly/nsd#connect>
|
|
|
|
|
|
#### Notes
|
|
Connecting to a service consists of two steps: resolving the service's current IP address and port, and making a TCP connection.
|
|
|
|
Attributes are fetched during the resolution step.
|
|
Some devices (eg Huawei P8 Lite 2015 and 2017) can receive multicast packets via the NSD API, but not directly via multicast sockets, making NSD more useful than LSD on these devices.
|
|
|
|
|
|
|
|
NSD is also a special case for Android apps running on ChromeOS: apps can't generally make or receive connections via the LAN, except in the case of outgoing connections to services discovered via NSD. See [briar#1362](https://code.briarproject.org/briar/briar/-/issues/1362).
|
|
|
|
|
|
|
|
The following comment suggests that NSD service resolution will fail for network interfaces that don't have an associated Network instance:
|
|
|
|
<https://cs.android.com/android/platform/superproject/+/master:packages/modules/Connectivity/service-t/src/com/android/server/NsdService.java;drc=b45a2ea782074944f79fc388df20b06e01f265f7;l=576>
|
|
|
|
|
|
|
|
On at least some devices, NSD works when the LAN is a Wi-Fi Direct legacy mode access point. Tested with Samsung Galaxy A21s as access point, Nokia 1.3 as client and vice versa. Tested with the `wifi-direct-and-nsd` branch.
|
|
|
|
|
|
|
|
Some devices (Huawei P8 Lite 2015, Moto G 4G, Moto E3) don't receive the attributes map in the NSD advertisement. This appears to be an Android bug that was fixed in Android 7 (API level 24):
|
|
|
|
|
|
|
|
https://issuetracker.google.com/issues/37020436
|
|
|
|
|
|
|
|
#### Service Resolution Issues
|
|
#### Service Resolution Issues
|
|
|
|
|
... | @@ -471,6 +467,14 @@ This means we can't advertise attributes, unless we encode them in the service n |
... | @@ -471,6 +467,14 @@ This means we can't advertise attributes, unless we encode them in the service n |
|
|
|
|
|
Alternatively we could implement our own unicast protocol for fetching attributes, while still using NSD for the multicast part, to benefit from the special treatment it seems to get on some devices.
|
|
Alternatively we could implement our own unicast protocol for fetching attributes, while still using NSD for the multicast part, to benefit from the special treatment it seems to get on some devices.
|
|
|
|
|
|
|
|
#### Notes
|
|
|
|
|
|
|
|
* Some devices (eg Huawei P8 Lite 2015 and 2017) can receive multicast packets via the NSD API, but not directly via multicast sockets, making NSD more useful than LSD on these devices.
|
|
|
|
* NSD is also a special case for Android apps running on ChromeOS: apps can't generally make or receive connections via the LAN, except in the case of outgoing connections to services discovered via NSD.
|
|
|
|
* The following comment suggests that NSD service resolution will fail for network interfaces that don't have an associated `Network` instance:
|
|
|
|
<https://cs.android.com/android/platform/superproject/+/master:packages/modules/Connectivity/service-t/src/com/android/server/NsdService.java;drc=b45a2ea782074944f79fc388df20b06e01f265f7;l=576>
|
|
|
|
* On at least some devices, NSD works when the LAN is a Wi-Fi Direct legacy mode access point. Tested with Samsung Galaxy A21s as access point, Nokia 1.3 as client and vice versa. Tested with the `wifi-direct-and-nsd` branch.
|
|
|
|
|
|
### Local Service Discovery (LSD)
|
|
### Local Service Discovery (LSD)
|
|
|
|
|
|
Local Service Discovery (LSD) is the protocol used by BitTorrent clients to discover peers on the local network.
|
|
Local Service Discovery (LSD) is the protocol used by BitTorrent clients to discover peers on the local network.
|
... | | ... | |