The problem: Each machine in the same network should be able to broadcast to all the members, including itself.
This is an attempt to get working multicast with socat
with VMs created in Vagrant & VirtualBox Envrionment. It seems things are working differently here, so I first tried to see how multicast working on physical machines.
I've 3 physical machines with ubuntu 12.04 server installed on them and named as pc0
, pc1
and pc2
.
On each machine I run:
socat STDIO UDP-DATAGRAM:224.0.0.1:2200,bind=:2200
...and when I typed hi from pc0
from pc0
, it has broadcasted to itself and other 2 machines and this is what I wanted (and I hope this is how multicast supposed to work):
ubuntu@pc0:~$ socat STDIO UDP-DATAGRAM:224.0.0.1:2200,bind=:2200
hi from pc0
hi from pc0
ubuntu@pc1:~$ socat STDIO UDP-DATAGRAM:224.0.0.1:2200,bind=:2200
hi from pc0
ubuntu@pc2:~$ socat STDIO UDP-DATAGRAM:224.0.0.1:2200,bind=:2200
hi from pc0
I'm using the IP 224.0.0.1
as this is used by default for multicast on every machine.
Next, I have tried to implement same stuff with 3 VMs, vb0
, vb1
and vb2
. Github repo is here.
Now I tried to broadcast from vb0
:
vagrant@vb0:~$ socat STDIO UDP-DATAGRAM:224.0.0.1:2200,bind=:2200
hello from vb0
hello from vb0
...and it doesn't broadcast to the other members (as in case of the physical machines above) except itself.
It seems, there are additional settings should be done prior to have this working...
Vagrantfile
:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu-12.04-x64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider "virtualbox" do |vb|
vb.cpus = "2"
vb.memory = "4096"
end
config.vm.provision "chef_apply" do |chef|
chef.recipe = File.read("recipe.rb")
end
config.vm.define "vb0" do |vb0|
vb0.vm.hostname = "vb0"
vb0.vm.network "private_network", ip: "10.20.30.100"
end
config.vm.define "vb1" do |vb1|
vb1.vm.hostname = "vb1"
vb1.vm.network "private_network", ip: "10.20.30.101"
end
config.vm.define "vb2" do |vb2|
vb2.vm.hostname = "vb2"
vb2.vm.network "private_network", ip: "10.20.30.102"
end
end