simspace
Posts: 13
Joined: Wed Jul 11, 2018 10:31 pm

How can I broadcast OSC messages to multiple RasPi's on my network?

Sat Jul 21, 2018 9:11 pm

I am trying to figure out how to broadcast OSC messages to multiple RasPi's on my network.

I have 14 RasPi's, each running a video player that can be controlled with OSC. Each RasPi and connected to it's own monitor. And each RasPi has a "media" directory containing multiple videos. This directory is the video player's playlist.

I would like to "broadcast" OSC commands such as "/next" and "/play" and "/stop" to all the RasPi's at once, and not have to address each RasPi IP individually.

I have tried this with Osculator on Mac OS and with a Linux command line app called OSC, with no success. Admittedly, I have no idea what I am doing when it comes to broadcasting OSC messages.

I have tried without success to broadcast the "/next" command (from the cli on my linux laptop) as follows ...

Code: Select all

osc 10.0.0.255:9000 /next 
osc 255.255.255.255:9000 /next

However, I can successfully send the OSC messages and control each RasPi individually when using specific IP addresses, for example ...

Code: Select all

osc 10.0.0.123:9000 /next
osc 10.0.0.123:9000 /stop

Does the the developer of the OSC sender app have to implement broadcast functionality in the app, or does the router/switch handle that?

Same question for the OSC receiver app (the video player). Does the developer have to be implement the ability to receive broadcast messages?

I have read about using UDP to broadcast OSC messages. I tried this by sending a "/play" command from a Mac OS app called PacketSender. When I did, the RasPi responded by killing the video player. Upon further research with Wireshark, I saw the protocol was UDP not OSC which makes sense. My understanding is that OSC messages may need to be encoded/decoded when sent over UDP. Does that sound right? Is this possible?

My goal is to have my guitar rig (which is already controlling other apps with OSC during our live shows) broadcast "/play," "/start" and "/stop" OSC messages to all the Pi's, to trigger and stop videos on demand.

Any help, directions or suggestions would be greatly appreciated!

Thanks,
Chris

== UPDATE ==

I found an app released by ETCLabs called OSC Widgets. It has an option to send OSC packets over UDP. I tested it and the RasPi responded correctly to all the commands. Using Wireshark I saw that the protocol was OSC and digging further an encoded OSC packet was sent over UDP. I don't know what to do with this info yet, in terms of how I can get my guitar rig to send encoded OSC packets over UDP. I don't even know how to create an encoded OSC packet. But, I'm one step closer.

I would still appreciate any help with this.

User avatar
topguy
Posts: 4616
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can I broadcast OSC messages to multiple RasPi's on my network?

Sun Jul 22, 2018 6:52 pm

I'll cut and paste a bit from this page: http://www.cs.ubbcluj.ro/~dadi/compnet/ ... dcast.html
But I'll highlight the importand parts.
UDP broadcast is a technique that allows sending UDP datagram from a single source to all computers in a LAN. In order to send a UDP datagram addressed to all computers in the local area network it needs to be sent to a special address called the Broadcast address. The broadcast address for a LAN is either the highest address in the local subnetwork or the universal broadcast address: 255.255.255.255. In order to receive broadcast messages the receiver needs to enable SO_BROADCAST option on the socket
So in theory you only have to to send the OSC (with UDP, not TCP) command to 10.0.0.255 but you do depend on that the receiving software is listening for these broadcast packets.
What software is running on the Pis ?

User avatar
The Traveler
Posts: 361
Joined: Sat Oct 21, 2017 3:48 pm

Re: How can I broadcast OSC messages to multiple RasPi's on my network?

Sun Jul 22, 2018 7:18 pm

It has an option to send OSC packets over UDP.
OSC is "layered" over TCP/UDP. The underlying transmission protocol doesn't care what data is it carries or how it's formatted. The biggest issue with UDP is this, if you drop packets on a network, their gone. Any information they carry is gone with them. UDP is much simpler than TCP but you have no recovery. If you drop a TCP packet, the receiving client will notify the sender to resend it thus insuring data integrity.

So, it mostly comes down to how critical is it that every packet transmitted gets to it's destination. The rest is simply having the server set up and sending out using a broadcast address and making sure the clients in that network subnet are listening on the correct port. The broadcast address varies with your IP subnet configuration.
Does the the developer of the OSC sender app have to implement broadcast functionality in the app, or does the router/switch handle that?
You have to set up the server/client(s) for OSC. So when your server sends OSC commands, it has to be configured with the network addressing you want to broadcast to. The hardware has no direct effect on OSC other than to route the TCP/UDP packets.

Here's an example using Processing with the OscP5 library (this snippet is using the loopback address and port 57120). You could just as easily substitute the subnet broadcast address for 127.0.0.1 and use any unassigned port number generally between 49152-65535.

Code: Select all

oscP5 = new OscP5(this, 12000);   
myRemoteLocation = new NetAddress("127.0.0.1", 57120); 
Simple subnet:

Code: Select all

Class C subnet: 10.1.1.0
First host IP: 10.1.1.1
Last host IP: 10.1.1.254
Subnet Mast: 255.255.255.0
Broadcast IP: 10.1.1.255
So, you set up your server and clients inside the 10.1.1.1 to 10.1.1.254 IP address space. Configure the server to send data to the 10.1.1.255 broadcast address (with some port # assigned), configure your clients to listen on the broadcast address on the pre-configured port # and there you have it.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 5 guests