I am sending out MDNS packages and those should ideally have an ip.ttl=1. On linux I would
int ttl = 1;
setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
but spark_wiring_udp does not seem to expose anything to let me do that. Neither can I find suitable api in the socket_hal.c for the photon.
Build and transmit the mdns packet yourself. We in the embedded world rarely have the luxury of libraries that do all the things, you just need to build the parts that you need.
An mDNS Ethernet frame is a multicast UDP packet to: 1.MAC address 01:00:5E:00:00:FB (for IPv4) or 33:33:00:00:00:FB (for IPv6) |
2.IPv4 address 18.104.22.168 or IPv6 address FF02::FB |
3.UDP port 5353 The payload structure is based on the unicast DNS packet format, consisting of two parts—the header and the data. The header is identical to that found in unicast DNS, as are the sub-sections in the data part: queries, answers, authoritative-nameservers, and additional records. The number of record...
I do build the mdns packet myself, but I don’t build the IP headers myself, since then I would need some lowlevel access sending them.
Maybe I’m mistaken, but doesn’t the mdns packet go into the UDP payload?
( EDIT: and the TTL is part of the mdns packet ? )
That is why I wrote IP TTL. I know it is confusing. The TTL for the mdns service announcement is part of the udp packet and I can control that. The IP TTL is the number of hops for the packet. Since mdns packets should not be routed one needs to set the ttl in the ip header to 1.
Ah, that might get tricky then. The lower level network stuff is part of the WiFi stack that’s not open source at the moment. If you feel like making that deep dive, look into WICED.
See this thread for a working-on-the-older-Spark-Core mDNS.
Spark Core and MDNS
Here is the Spark Core port of Adafruit MDNS library. The library provides the ability to setup a name for the Spark Core and resolve it. We can name the Core anything we want, the library will append “.local” to the name and we can access the Core using the URL “name.local”.
The sample application names the Core as “myspark”. If the MDNS is setup correctly then it creates a TCPServer on port 80. The Core can be accessed using the URL “
http://myspark.local”. The server simpl…
You don’t have easy access to either the TTL (hop-count) or the ICMP Time Exceeded reply messages in this stack.