keepsimple1 / mdns-sd

Rust library for mDNS based Service Discovery
Apache License 2.0
94 stars 37 forks source link

add support for Known Answer Suppression part 2: multi-packet (querier side) #232

Closed keepsimple1 closed 2 weeks ago

keepsimple1 commented 1 month ago

This is to address #193 section 2: multiple packets

keepsimple1 commented 2 weeks ago

There is a pending issue with the changes on the Responder side for this feature:

Per RFC 6762 section 7.2:

A Multicast DNS responder seeing a Multicast DNS query with the TC
   bit set defers its response for a time period randomly selected in
   the interval 400-500 ms.  This gives the Multicast DNS querier time
   to send additional Known-Answer packets before the responder

   responds.  If the responder sees any of its answers listed in the
   Known-Answer lists of subsequent packets from the querying host, it
   MUST delete that answer from the list of answers it is planning to
   give (provided that no other host on the network has also issued a
   query for that record and is waiting to receive an answer).

The above means the responder needs to know the sender of each packet (e.g. the queryer IP address), otherwise it cannot associate the additional Known-Answer lists of the subsequent packets with a sender (and the question).

However socket2 lib current version (0.5.5) does not have a safe API to get the source address of a packet, and I don't want to use any unsafe APIs.

There are a couple of options I'm thinking of: 1) not to implement the Responder side for multi-packet. 2) figure out a basic / narrower case for the Responder that handles certain cases of multi-packet without using the source address.

keepsimple1 commented 2 weeks ago

Because of the issue describe in earlier comments, I decided to merge in the support for the querier side first. This will unblock Known-Answer feature, except not supporting the multi-packet on the responder side. I think it is better than keep all of them stuck in PR.