1

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.

Anton Menshov
  • 2,091
  • 11
  • 30
  • 48
Scott S
  • 177
  • 2
  • 11

2 Answers2

3

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

Community
  • 1
  • 1
Ben Voigt
  • 269,602
  • 39
  • 394
  • 697
0

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?

Douglas Muth
  • 336
  • 1
  • 4