[GSOC 2024] MDNS / Bonjour / Avahi network discovery

I am considering implementing the mDNS for the project, I am wondering whether reading RFC 6762 - Multicast DNS is a good place to start(but this website is a lot)? Moreover, what should the proposal look like? Is there any source code where mDNS should be implemented on I can look at?@PulkoMandy

6 Likes

There are open tickets and source code links for references:

https://dev.haiku-os.org/ticket/17208

https://dev.haiku-os.org/ticket/12961

https://dev.haiku-os.org/ticket/16318

1:Based on my understanding, is the task basically the ticket #1042? #1042 (implement ZeroConf/Bonjour support) – Haiku
2:Moreover, it says in the ticket #1042 that “This can be integrated as a network kit add-on, complementing our existing DNS resolver”, is there source code for existing DNS resolver I can refer to?
3:Are the github links you just shared the mDNS on other applications and it will be similar idea as I implement it in this project?

Hello,
I think what makes more sense is to start from mdnsresponder which is kind of the reference implementation for this.
The current dns resolver is based on netresolv and netbsd dns resolution code.

It currently lives in libnetwork: netresolv « libnetwork « system « src - haiku - Haiku's main repository which means each application runs its own resolutions. I think for mDNS, there should be a hart of the code that’s always running and handling the discovery of other machines and announcement of the machine on the network. So it would make sense to have that part done inside net_server

2 Likes

PulkoMandy explained many points well.

The mdnsresponder license is not MIT, the project links are MIT licensed, something might be useful, code on the MIT license would be more interesting.

Do you mean GitHub - Apple-FOSS-Mirror/mDNSResponder is not licensed? And I need to find another github link for reference(Sorry I am new to this type of thing, I just want to check to make sure)
Is there other mDNS responder github might be helpful here that I can use?

The licensing issue would be to make things easier, Haiku uses the MIT license, mDNSResponder uses several licenses.

It is a simpler and older version in the Apple-FOSS-Mirror repository, there is a current code version in the Apple repository:

So my plan is to use GitHub - apple-oss-distributions/mDNSResponder as a reference and try to understand netresolv « libnetwork « system « src - haiku - Haiku's main repository and see how it can fit in. Does this sound right?

1 Like

A good way to start!

1 Like

I was looking at the these two github whole day and it makes me like the task is not easy. So for my background:I just finished the computer networks course, for which the first is about sliding window protocol and congestion control and second one is about sending the packets through routers with the help of existing mininet(unicasting) . And I saw the idea of implementing mDNS has been proposed since 2021 and no one did this. I just want to know how hard it is to implement it(I would say looking at the apple open source code is a bit hard for me)@PulkoMandy

I think the Apple code can be reused, maybe with some minor changes. Have you tried compiling and running it on Haiku? That would at least give us a starting point.

We can see if it works, and what are the limitations of using it as a separate piece of software and if we need to integrate it more with the OS. It will also allow to see if mDNS works at all, or if we need to do some work in the lower levels of the network stack, for example I am not completely sure if we have fully working multicast in the UDP and IP implementation yet.

I don’t think this is a very difficult project, but maybe things look easier for me after 15+ years working in Haiku and quite a bit of experience in network protocols as well.

1 Like

There are severall parts of this puzzle,

The first one is a multicast DNS daemon, this has to be long running, respond to asvertisements, be responsible for querring records with it‘s own cache etc. (probably best in net_server)

The second part is an api for programms to querry these records, and one to publish them
e.g usb connected printer → publish as network printer

third part is debugging tools, showing all records, all service types (dns-sd „DNS service discovery specific)

The dns-sd stuff builds ontop of mDNS anyhow.

mDNSResponder is a bit complex and tries to solve all these problems at once, personally I think the RFC is simple enough that an integrated solution (i.e write your own) would work better, and be doable in a reasonable timeframe.

Since I‘ve read the RFC and this is my area of interest i could probably mentor this specific project (saw pulkomandy mentioning probably not having enough mentors in another thread)

4 Likes

Please not again reimplementing like for the DHCP client.

What do you mean by this? could you elaborate?

As I‘ve written above there are severall components we need, and some may make more sense implementing on our own.
(Especially stuff like a native Ui of a service browser)

Apart from implementing this on our own (there is no „re“ about this since we don‘t have one either way), there are two projects one could look at: avahi and mDNSresponder.
Personally I would be strongly oposed to taking anything from avahi, so that leaves mDNSresponder, and there it depends what the implementation does.

We have written our DHCP client from scratch. It was full of bugs and a massive waste of time. Wrong timings. Compatibility problems with some DHCP servers. Options not handled correctly, or not handled at all. And so on.

Let’s try to reuse existing open source code as much as possible, and save ourselves the trouble.

I agree with korli, every time we went with “I read the RFC, this looks simple enough”, it was a disaster (this applies to DHCP but also to the HTTP implementation, for example). It’s always better to start from existing code, even if we end up having to modify it a lot.

3 Likes

There are many implementation examples with MIT licensed code, which code can be reused or modified!

So you suggest me read the RFC 6762 - Multicast DNS ?

In the course of this, yes. It will help debugging the implementation and understand debug output, even if you choose to use mdnsresponder.

That doesn‘t mean you have to read everything, but atleast the basic mode of operation and such is likely good.

This one is also relevant for the later part. RFC 6763: DNS-Based Service Discovery

I would say directly look at apple source code is definitely hard for me, but I can try to submit the best proposal I can have

1 Like

1:You suggest implement it in net_server, where in the branch are you referring to?Is it net « servers « src - haiku - Haiku's main repository?
2:Moreover, is normal DNS implemented somewher in this directory? Because based on my understanding mDNS different from DNS in the way that DNS use local DNS servers to find the IP address associated with the destination device, whereas mDNS just send the mDNS query(which encapsulated into the packet) through switches and goes through the port 5353 of every device to find if there is any match within LAN