Reputation: 345
Currently, I'm working on a project (WIFI based) in which there is a base station (Master) and N-devices (slave/ UDP Listener). In my application, the base station needs to broadcast a packet/ message every second for the N-devices to receive. So, for achieving this task, I've built a UDP network in the LAN, and I'm using the UDP broadcast feature to transmit the packet/ message every second to the N-device. Now, while broadcasting the packet, I only provide the port number on which all N-devices are listing. Hence, I want to know how I can link this UDP broadcasting (currently happening in LAN) to the internet, so, the devices which are outside of the network can also get the UDP broadcasted packet. I'm using EPS32-WROOM and ESP32 on Arduino IDE.
Upvotes: 1
Views: 1856
Reputation: 1
If your application needs minimal time difference between the transmission and reception of the packets, you can use a mix of MQTT and direct UDP communication:
This way you only "loose" time on the setup using a pub/sub protocol, but all the future communication are quick
Upvotes: 0
Reputation: 7069
As @Christian B. pointed out in their answer, you absolutely do not broadcast packets over the general Internet. The Internet has over 7 billion devices on it at this time; if they all broadcast to one another the result would be catastrophic.
If you have an application where you need to communicate with multiple devices periodically, you should consider using a pubsub protocol. Pubsub provides a networking abstraction where multiple devices can publish data and multiple devices can subscribe to data being published.
Consider using MQTT - it's well supported and is easy to use. You'll need an MQTT broker. Brokers can run on computers as simple as Raspberry Pis. There are also public, cloud-based MQTT brokers available; some have free tiers which may be accommodate the level of traffic you need.
Upvotes: 0
Reputation: 814
broadcasts only work in the same subnet. Just think for a second what would happen if very inet abled device on this world would be contacted because one device send a broadcast to everyone. But one can create "tunnels" or proxy which relay a broadcasted packaet to a specific target.
Upvotes: 1