Skip to content

ESP8266mDNS: Replies are not reliably sent on the correct network interface #3101

Closed
@ccooper21

Description

@ccooper21

Basic Info

Hardware

Hardware: NodeMCU (ESP-12E)
Core Version: Latest (commit a01638f from Mar 13, 2017)

Description

I spent the day experimenting with the mDNS-SD_Extended example and the related ESP8266mDNS library. I did not have any success getting my ESP to respond to mDNS queries for most the day. In order to investigate, I used both WireShark on my laptop and tcpdump on my router to monitor the relevant network traffic. There just weren't any mDNS/UDP packets getting sent in response to queries from my other devices. Ultimately, I discovered that the responses were getting sent, but through the SOFTAP_IF interface instead of the STATION_IF interface that was connected to my local network. As a workaround, disabling the SOFTAP_IF interface was a step in the right direction, but it was not sufficient. I noticed that in the MDNSResponder::advertiseServices(...) method that all traffic gets sent to the SOFTAP_IF interface. It appears that this is just a simple coding mistake. These problems appear to have been caused as a result of commit a546d64. Aside from the simple coding mistake that I mentioned, unfortunately, I'm not familiar enough with all of the code involved or mDNS to understand exactly what needs to be fixed to get mDNS working reliably with both interfaces enabled as was the intent of the referenced commit.

Settings in IDE

Module: NodeMCU 1.0 (ESP-12E)
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: Unknown
Flash Frequency: Unknown
Upload Using: Serial over USB
Reset Method: NodeMCU

Sketch

See mDNS-SD_Extended example

Debug Messages

Entering MDNSResponder::queryService(...)...
queryService esp tcp
Sending mDNS query...
Entering send(...)...
Calling udp_sendto(,, 224.0.0.251, 5353)...
Payload:
000000000001000000000000045f657370045f746370056c6f63616c00000c0001
 . . . . . . . . . . . . . _ e s p . _ t c p . l o c a l . . . . .
udp_send
udp_send: added header in given pbuf 0x3fff2994
udp_send: sending datagram of length 41
udp_send: UDP packet length 41
udp_send: UDP checksum 0x2cb0
udp_send: ip_output_if (,,,,IP_PROTO_UDP,)
ip_output_if: ew1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        61     | (v, hl, tos, len)
+-------------------------------+
|        8      |000|       0   | (id, flags, offset)
+-------------------------------+
|    1  |   17  |    0x1404     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    4  |    1  | (src)  <----- This network is not in use.  The correct network is 192.168.16.1/23.
+-------------------------------+
|  224  |    0  |    0  |  251  | (dest)
+-------------------------------+
netif->output()
udp_send: ip_output_if(...) rc = 0x0000
Leaving send(...)
Waiting for answers...

/cc @swarren

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions