mDNS / multicast question for the network experts

I am trying to implement the mDNS and or LLMNR protocol however the CobraII with ENC module does not react if a multicast packet is available on the network.

I am using the following socket setup.

serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 5353);

anyone knows if lwip or netmf is limmited or do i use a wrong setup?

First, if you are not already using it, I recommend Wireshark to allow you to see the packets on the network. Your code generally looks fine, although I can’t tell you for sure if it is valid for a Multicast socket. I know mIP would work for that, since mDNS and LLMNR were among my primary goals. However, with LWIP, you might need to join the Multicast group with IP

Generally, communicating with mDNS is just simple UDP messaging. The exception though is that the MAC address is special and the IP address is special and LWIP may filter out the packets unless you join the group.


1 Like

Yes you do have to join the group add this code after the bind call

// Join Multicast Group
             var multicastOpt = new byte[] { 239, 255, 255, 250, 0, 0, 0, 0 };
             serverSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 0);
           serverSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, multicastOpt);


Thanks guys ! that saved me a lot of digging.

@ Valkyrie-MT - Over the last days i implement DHCP server, DNS server, mDNS & LLMNR which i will post in the cource of the week on codeshare. My question to you is if you know if Android only relies on DNS?

Ah yes. Great question. You’d think that Android, the product of a company that is so closely tied to the internet, would have a great TCP/IP implementation. Sadly on local name resolution it is by far the worst. I have rarely had Android resolve local names properly. I think it worked once for me by DNS. I believe if the device passes the hostname via DHCP, some routers will use this name for name resolution requests. I have also read that mDNS is supposed to work on Android, but never has for me. Maybe that’s changed recently.

Android local name resolution has been so bad for so long, I find it very hard to believe it’s an accident. Sadly, I have come to believe that local devices that do not rely on the internet are perceived as a threat to Google. They don’t want them to work because there is no way for them to monetize that. I also think that is why they bought NEST. What they don’t realize is that people will never want to be dependent on the Internet for home automation. Can you imagine if my TV would not turn on because the internet is down? Or if I am forced to watch a commercial when the TV starts up. The internet is an unnecessary dependency for most home automation functions. IMHO.

@ Valkyrie-MT - Thanks. I fully agree. I will do some more investigation… maybe there is a trick to fool android / chrome to get connected to a local device by name…

Gee, I sure hope so. If you could get your device to be considered a secondary DNS server by the router, you could respond to the DNS name request. But, I don’t see any way to do that…