narcisoleedev / esp32-TDD

1 stars 2 forks source link

Not possible (yet) to narrow DNS-SD/mDNS service query #2

Open FNakano opened 3 months ago

FNakano commented 3 months ago

(2024-07-17: I believe I refer to the most up to date documents.) Once I asked if it was possible to program the ESP32 to query for the thing-directory. According to the the WoT-discovery recommendation (https://www.w3.org/TR/wot-discovery/#introduction-dns-sd-sec), the thing-directory should have the Service Name _directory._sub._wot._tcp.

DNS-SD/mDNS are "ruled by" IETF standards. Specifically on DNS-SD, it is stated that:

The portion of a Service Instance Name consists of a pair of DNS labels, following the convention already established for SRV records [RFC2782].

The first label of the pair is an underscore character followed by the Service Name [RFC6335]. The Service Name identifies what the service does and what application protocol it uses to do it.

(https://datatracker.ietf.org/doc/html/rfc6763#page-19)

Interpreting rfc6763, a service name _printer._tcp is compliant to the standard but a service name _directory._sub._wot._tcp is not compliant.

mDNS subtypes are mentioned on the standard but it seems that mDNS implementers did not implement it.

ESP-IDF support to mDNS is documented here: https://docs.espressif.com/projects/esp-idf/en/v4.4.4/esp32/api-reference/protocols/mdns.html

Linux library to support mDNS is Avahi. its documentation on service search is here:https://avahi.org/doxygen/html/index.html#good_browse - it does not mention mDNS subtypes.

Microsoft was questioned about support to mDNS subtypes: https://learn.microsoft.com/en-us/answers/questions/53734/querying-for-services-with-subtypes-using-dns-sd . Microsoft's response was: "subtypes are not supported in your scenario." . The particular scenario is similar to our scenario.

note: it is not useful in this case: Avahi can translate _printer._tcp names to friendly names by using a db. The reverse (translate a friendly name to a Service Name is not possible (https://superuser.com/questions/1576320/browse-only-unix-printer-with-avahi-browse)

note: avahi is a library, avahi-utils is a (linux) package, avahi-browse (for instance) is a program in the package.

This issue can be circumvented by changing _directory._sub._wot._tcp to (for instance) _wotDirectory._tcp and changing Service Name in the Thing-directory.

FNakano commented 3 months ago

...did it...

image

Changed line 9 of file thing-directory/wot/discovery.go from DNSSDServiceType = "_wot._tcp" to DNSSDServiceType = "_wotDirectory._tcp", rebuilt thing-directory and tested it with a variation of mDNS-SD Extended.ino ESP32 Arduino IDE example.