jdomnitz / net-mdns

Simple Multicast DNS (MDNS) Client/Server
MIT License
22 stars 6 forks source link

Delay query responses #39

Open cyanfish opened 2 weeks ago

cyanfish commented 2 weeks ago

Per https://datatracker.ietf.org/doc/html/rfc6762#section-6:

In any case where there may be multiple responses, such as queries where the answer is a member of a shared resource record set, each responder SHOULD delay its response by a random amount of time selected with uniform random distribution in the range 20-120 ms.

I implemented this in my fork but perhaps it's worth making it configurable.

jdomnitz commented 2 weeks ago

That's not spec correct either. A server is expected to be listening to broadcasts during that waiting period and respond accordingly. That waiting period only applies in some cases where as others like probe responses MUST be sent immediately.

This library needs a transmission scheduler with preemption to handle mandatory delays, response trimming, query aggregation and many other SHOULDs. I'll try to address these where it's unlikely to harm stability.

This library also needs to differentiate between shared and exclusive records. Then handling things like negative responses and deconfliction could be tackled.