How to send MDNS Query over UDP to get Domain Name Pointer (PTR)?
-
I am currently trying to get Axis IP cameras to identify themselves via the network using C#. I've captured the packets that Axis' own tool uses and I am trying to mimic them in .NET - without success : ( Apparently the Axis program sends out a Multicast UDP/TCP packet to 224.0.0.251:5353 with the message "_axis-video_tcplocal" Here's what I captured: 224.0.0.251 MDNS Standard query PTR _axis-video._tcp.local, "QU" question I've scoured the web looking for a method to do a Domain Name Pointer lookup without any luck. Any pointers...?
Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't
-
I am currently trying to get Axis IP cameras to identify themselves via the network using C#. I've captured the packets that Axis' own tool uses and I am trying to mimic them in .NET - without success : ( Apparently the Axis program sends out a Multicast UDP/TCP packet to 224.0.0.251:5353 with the message "_axis-video_tcplocal" Here's what I captured: 224.0.0.251 MDNS Standard query PTR _axis-video._tcp.local, "QU" question I've scoured the web looking for a method to do a Domain Name Pointer lookup without any luck. Any pointers...?
Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't
Hi, The way is like this: // Send request try { m_socket = new DatagramSocket(); m_socket.MessageReceived += MessageReceived; // Bind socket await m_socket.BindServiceNameAsync("5353"); HostName host = new HostName("224.0.0.251"); // Connect m_socket.JoinMulticastGroup(host); // Prepare request ... IOutputStream stream = await m_socket.GetOutputStreamAsync(host, "5353"); DataWriter writer = new DataWriter(stream); DnsQueryRequest req = new DnsQueryRequest(); byte[] b = req.BuildDnsRequest( m_service, // service to looking for ... DnDns.Enums.NsType.PTR, // PTR = 12 DnDns.Enums.NsClass.ANY, // ANY = 255 17); // User Datagram-Protokoll Udp = 17 Debug.WriteLine("Sent {0} Bytes: {1}\n", b.Length, BitConverter.ToString(b)); // ... and send it! writer.WriteBytes(b); await writer.StoreAsync(); } catch (Exception e) { Debug.WriteLine(e.Message.ToString()); }
-
Hi, The way is like this: // Send request try { m_socket = new DatagramSocket(); m_socket.MessageReceived += MessageReceived; // Bind socket await m_socket.BindServiceNameAsync("5353"); HostName host = new HostName("224.0.0.251"); // Connect m_socket.JoinMulticastGroup(host); // Prepare request ... IOutputStream stream = await m_socket.GetOutputStreamAsync(host, "5353"); DataWriter writer = new DataWriter(stream); DnsQueryRequest req = new DnsQueryRequest(); byte[] b = req.BuildDnsRequest( m_service, // service to looking for ... DnDns.Enums.NsType.PTR, // PTR = 12 DnDns.Enums.NsClass.ANY, // ANY = 255 17); // User Datagram-Protokoll Udp = 17 Debug.WriteLine("Sent {0} Bytes: {1}\n", b.Length, BitConverter.ToString(b)); // ... and send it! writer.WriteBytes(b); await writer.StoreAsync(); } catch (Exception e) { Debug.WriteLine(e.Message.ToString()); }
Thanks! I had forgotten about this one again, it's been five years :-).
Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't