feralin feralin - 2 months ago 18
C Question

UDP Packet Captured by Wireshark but not Application

I have a Windows 8 system with two Ethernet adapters (specifically for testing network stuff). I am writing an application that will send a

"Are you there?"
UDP broadcast across the entire local network on port 4950 and then wait for any responses from FPGA boards that say
"Yes I'm here."
on port 4951.

The problem is that in Windows 8 (and probably in older versions too), sending a broadcast to
actually only picks the primary network adapter, but my application must send a broadcast to every single network adapter on my computer. I hardcoded a broadcast to my second (non-primary) NIC at the IP address
(with a netmask of
), so the application broadcasts to
in order to determine if any boards are on the network of the second NIC.

The board itself has a static IP address of
, so when my application broadcasts over the secondary NIC, the broadcast message (
"Are you there?"
) is received by the FPGA board (and I can confirm this because the board will tell me over a serial port that it received an Ethernet broadcast). The strange thing is that although the board does send a response back on the correct port of 4951, my application never receives the response, whereas Wireshark does see the response packet when listening to the secondary NIC.

Also, when I run
netstat -s
before and after a failed attempt to contact any board, I see that the
Receive Errors
counter under
UDP Statistics for IPv4
increments; it seems like Windows 8 drops the packet because there's an error, while Wireshark accepts the packet (and doesn't say that there's anything wrong with it).

tl;dr: What could cause Windows 8 to drop a UDP packet even when Wireshark doesn't show anything wrong with said packet?

Oh, and in case someone says "your UDP code doesn't work!": the application correctly hears responses from boards on my primary NIC; it is only when I move a board to the router that's connected to my secondary NIC that my application never receives a response.

I have also disabled the Windows Firewall to test whether that is the issue; it is not.


Very strange indeed. Turning off the Windows Firewall apparently didn't turn off the firewall; I just needed to manually change the rules for my application from "block UDP" to "allow UDP" and now everything works just fine.