Not seeing UDP packets via wireshark using sendto function

In my current project, I have a static IP address of and am directly connected to my pc via ethernet with static IP I am able to run the tcp and udp loop back test with success by verifying with Hercules and Wireshark.

Next, I am working on adding a MDNS library based on the DNS drivers from the Wiznet library. This should be relatively simple based on information from RFC6762 Section 5.1:

With this information, I copied the dns files into a new folder and renamed to mdns.c/h and renamed other functions similarly. I then changed to a constant destination IP address and port as stated in RFC6762. Then when sending a message, I first open a unique UDP socket for MDNS using

if(getSn_SR(1) != SOCK_UDP)
    if((socket(1, Sn_MR_UDP, 5300, 0x00) != 1))
        return 0x00;

When I’m ready to send a message to the MDNS server, I am using the following code command:

uint8_t mdns_ip[4] = {224, 0, 0, 251};
sendto(1, MDNS_Message, len, mdns_ip, 5353);

My issue is that after this command, I do not see any packets sent out over wireshark. Why is this the case? I can see all udp and tcp packets in the loopback part of the code. When stepping through the code, I see the information passed and sent out using the assigned spi_burst callback functions.

Any? Even no ARP packets?

Nothing shows up. It is like nothing was ever sent out. I have seen normal TCP and UDP messages without issue by using the loopback functions provided in the example library. The only difference I see between those and trying to use the DNS library is that DNS uses the sendto() function vs. just send() in the loopback examples. Of course the loop backs get their destination address by receiving a message while in the DNS library, the destination port and IP are set before calling send(). Setting seems to work properly using these built in functions:


I did have to fix an issue in the DNS library. In socket.c in the sendto() function, the following lines except for the second line were commented out

#if ( _WIZCHIP_ < 5200 )
   if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; 
   if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS;

Therefore since the socket was for UDP, an error was always returned, preventing reaching the wiz_send_data() function. I just uncommented the entire preprocessor defines and the other if statement and now get to the send functionality. I also have verified that the tx buffer on the chip has plenty of room to send out the message. In fact, it is completely free.

Is there really anything outside of setting up the socket and then sending any arbitrary message where I should be seeing results show up in wireshark? I’d assume even wrongly formatted packets should still be seen, even if it meant the MDNS server was unable to parse them and make a reply. Also, I am running bonjour on my laptop in order to process MDNS messages.

Two suggestions:

  • in your socket initialization function close the socket first, ensure it is closed and then open it. Opening already opened socket is not correct IMHO (not sure if it may lead to issues though).
  • try sending UDP packet to another, non-special IP address in the current network.

You must see ARP packets. If you do not see them then your Wireshark does not get all the traffic.

Thanks for your suggestions Eugeny. I went ahead and used the disconnect() function on socket initialization as you suggested and then I changed the port to 5004 for opening the socket. I can now see MDNS messages in Wireshark. I have one more question before resolving this thread. I consistently get a timeout when sending the query. It looks like the status “Sn_IR_SENDOK” is expected to return in order to avoid a timeout. What are the conditions of this status being sent back? Is it just an ACK from the MDNS server in this case?

Eugeny ,
I went ahead and looked at other answers based on timeouts and found one here. Using Andrej_Buryachenko’s answer, I changed the Sn_CR_SEND to Sn_CR_SEND_MAC and I don’t see anymore issues and I see a full MDNS query in WireShark coming from the W5500 chip.

1 Like

Where do you get timeout? SENDOK is socket indication of the successful send of the packet into the wire. It has nothing to do with another node replying to that packet. If you get timeout because of bad communication with another network node, then problem is in different location of the algorithm/code, or in contents of the packet being sent (which is being dropped at the remote node’s end and not answered).

That’s why I was constantly asking you if you see anything on the wire. SEND command performs ARP first to identify MAC address of the remove node, and you normally see this packet in the Wireshark. As soon as is not a valid local network IP address, ARP request will not be answered, and SEND will time out/return the error. And it seems you are correct in your case you must bypass ARP phase, and SEND_MAC is the one to use. However take care about DHAR field value to be in accordance to the protocol definition (e.g. 0:0:0:0:0:0).