xref: /aosp_15_r20/external/openscreen/docs/discovery.md (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1# Discovery
2
3This discovery module is an implementation of the mDNS and DNS-SD protocols as
4defined in [RFC 6762](https://tools.ietf.org/html/rfc6762) and
5[RFC 6763](https://tools.ietf.org/html/rfc6763). The protocols have been fully
6implemented, with the exceptions called out below.
7
8Other modules in Open Screen use this module to advertise and discover
9presentation displays. If you wish to provide your own implementation of DNS-SD,
10implement the
11[DNS-SD public interfaces](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/dnssd/public)
12and updating the linker rules. In this case, the
13[public discovery layer](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/public)
14will continue to function as described below.
15
16Note that this DNS-SD implementation is fully generic and can be used for
17advertisement and discovery of any RFC 6763 compliant services.
18
19
20## How To Use This Module
21
22In order to use the discovery module, embedders should only need to reference
23the
24[public](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/public)
25and
26[common](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/common)
27directories. The
28[DNS-SD](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/dnssd)
29and
30[mDNS](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/mdns)
31layers should not be accessed. In order to encourage this behavior, DEPS rules
32have been defined.
33
34The config directory provides parameters needed to configure the discovery
35module. Specifically:
36
37* The
38[openscreen::discovery::Config struct](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/common/config.h)
39provides the required data to publish or discover service
40instances, such as a list of valid network interfaces or constants used to
41configure the underlying stack.
42* The
43[openscreen::discovery::ReportingClient](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/common/reporting_client.h)
44provides a way for embedders to receive callbacks for errors which occur inside
45the discovery implementation.
46
47The public directory provides wrappers around the DNS-SD protocol to simplify
48interacting with the internals of this module:
49
50* The
51[openscreen::discovery::DnsSdServicePublisher](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/public/dns_sd_service_publisher.h)
52provides a simple interface for registering, updating, and de-registering DNS-SD
53service instances.
54* The
55[openscreen::discovery::DnsSdServiceWatcher](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/public/dns_sd_service_watcher.h)
56provides an interface to begin and end querying for service types, providing
57callbacks for the embedder to be notified whenever an instance is discovered,
58changed, or deleted.
59
60For an example use case of this module, see the
61[standalone sender](https://chromium.googlesource.com/openscreen/+/refs/heads/master/cast/standalone_sender/main.cc)
62and
63[standalone receiver](https://chromium.googlesource.com/openscreen/+/refs/heads/master/cast/standalone_receiver/main.cc)
64code.
65
66
67## Limitations
68
69This implementation has been created to fulfill the role of discovery for the
70CastV2 protocol. For this reason, some details or optimizations called out in
71the RFC documents had cost or additional required complexity that outweighed the
72added benefit they provided. As such, the following have not been fully
73implemented:
74
75* [Selective Instance Enumeration](https://tools.ietf.org/html/rfc6763#section-7.1)
76is not supported.
77* [Multiple SRV records](https://tools.ietf.org/html/rfc6763#section-5) for a
78single service instance are not supported.
79* [Multiple TXT records](https://tools.ietf.org/html/rfc6763#section-6.8) for a
80single service instance are not supported.
81* Hosts which publish [no TXT record](https://tools.ietf.org/html/rfc6763#section-6.1)
82are treated as invalid. However, hosts which publish
83[an empty TXT record](https://tools.ietf.org/html/rfc6763#section-6.1) are
84valid.
85* [Duplicate Question Suppression](https://tools.ietf.org/html/rfc6762#section-7.3)
86has not been implemented.
87
88Additionally, the following limitations should be noted:
89
90* If network interface information is changed, the discovery stack must be
91re-initialized.
92* If a
93[fatal error](https://chromium.googlesource.com/openscreen/+/refs/heads/master/discovery/common/reporting_client.h#25)
94occurs, the discovery stack must be re-initialized.
95