1
votes

I am attempting to create a program for a wireless mesh (adhoc in all but name). Most of the network will deal with TCP messaging but to determine all neighbor IPs (as they will be unknown on startup), I choose to use UDP Broadcast for the initial discovery messages.

I have two problems currently. First, the UDP Broadcast is only being received by the sender and none of its neighbors; second, as the receiving socket can not accept the sender's socket (due to the message being a datagram), I am not able to recover an IP address.

I am in need of a methodology that would allow this to work.

2

2 Answers

3
votes

You're supposed to get the source address along with the datagram via e.g. recvfrom. Here's the .NET version. You also have to set a socket option to send broadcast datagrams.

See also this question: Broadcasting UDP thru all network cards

0
votes

Why UDP and why not say, ICMP Pings to the broadcast address, or even bruteforcing your way down the netblock with ICMP pings? It seems to me that a ping would be more appropriate for determining if a specific host is "alive", no?