This project is read-only.

Service discovery udp issue with multiple network interface active on windows


Symptoms: Windows machine with two network interfaces (NIC), 10.x.x.x and 192.168.x.x. I send a UDP broadcast message (to destination address, and see the same message go out on both networks. The problem is, the source address that goes out with each packet is the IP address for my first network interface, so it’s sending an unreachable address out my second network. Responding devices start doing ARP requests to try (in vain) to find that unreachable address instead of responding. (Watch it with WireShark.)
Cause: is too general. TangentSoft has the general solution (implemented in boost). I craft the broadcast address more carefully, and it works.
10.x.x.x (subnet =>
192.168.1.x (subnet =>
It’s not the language or library. It’s seen for C#, C, and C++, etc, on all windows versions over Windows XP (not tested on older versions).
The broadcast address is also known as INADDR_BROADCAST or ‘‘ in Python.
You only need one socket, which you can bind to all interfaces.
Enumerating your network interfaces requires some work: find it under Win32_NetworkAdapterConfiguration, fields IPAddress and IPSubnet. Those fields are arrays: you want element zero.
If you’re using python, you need the WMI package, which is built on the PyWin32 package.
import wmi
nicsList = wmi.WMI().Win32_NetworkAdapterConfiguration() # your network adapters
If you’re getting WinSock error 10013, you need to set SO_BROADCAST.
Hope that starts you down the right path.
Also, if your devices aren’t configured for the same subnet, crafting a sub-net-specific broadcast message means you’re not going to find them. For example, if you have a 10.x.x.x device off your 192.168.x.x interface, it’s going to ignore your broadcast. You’ll have to fall back to disabling a network interface and using to get to it.


wrote Sep 7, 2011 at 7:10 AM

Associé à l'ensemble de modifications 62977.

wrote Sep 7, 2011 at 7:13 AM

wrote Sep 8, 2011 at 2:25 PM

Associé à l'ensemble de modifications 62989.

wrote Sep 8, 2011 at 2:55 PM

Associé à l'ensemble de modifications 62991.

wrote Feb 2, 2013 at 7:07 AM

wrote Nov 28 at 11:07 PM