Is it possible to send a UDP broadcast packet to a different subnet through a router? I'm writing an app to discover certain devices on the network, and the PC might be on a different subnet than the devices it's looking for.
UDP is not suitable if: you are using a router in your network to connect across subnets. Remember that we are broadcasting across a single subnet and data packets will not reach DSP units on a different subnet. UDP broadcast method will always take longer than TCP to discover units on the network.
If you really want to broadcast across subnets then you should be using IP Multicast instead. That still requires that the intervening routers are configured appropriately, but it is the "right" way to do it.
A UDP broadcast packet is 'sent' to an IP address with the subnet of the broadcasting device and all 1's in the host portion. For example, if a device has an address 128.253. 109.10 and a subnet mask 255.255. 255.0, it can use the broadcast address 128.253. 109.255.
Yes, and no.
It's actually do-able, so long as the intervening routers don't have no ip directed-broadcasts
or similar configured. However these days that's the default because allowing normal broadcasts to traverse routers is a DoS problem.
If you really want to broadcast across subnets then you should be using IP Multicast instead. That still requires that the intervening routers are configured appropriately, but it is the "right" way to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With