I'm trying to get some multicast packets moving between 4 machines
connected with different interfaces.
I'm using these two java scripts to generate the packets:
import sun.net.*;
import java.net.*;
public class Client
{
public static void main(String [] arstring) throws Exception
{
String ip = "224.2.2.2";
for (int i=1; i<=100; i++)
{
try
{
// Create a datagram package and send it to the multicast
byte [] arb = {'H','e','l','l','o'};
InetAddress inetAddress = InetAddress.getByName(ip);
DatagramPacket datagramPacket =
new DatagramPacket(arb, arb.length, inetAddress, 7777);
MulticastSocket multicastSocket = new MulticastSocket();
multicastSocket.setTimeToLive(10);
multicastSocket.send(datagramPacket);
System.out.println(i + ": sending "+ new String(arb));
Thread.sleep(100);
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
}
<<And this one>>
import sun.net.*;
import java.net.*;
public class Server
{
public static void main(String [] arstring)
{
String ip = "224.2.2.2";
try
{
// Create a multicast datagram socket for receiving IP
// multicast packets. Join the multicast group at
// 230.0.0.1, port 7777.
MulticastSocket multicastSocket = new MulticastSocket(7777);
InetAddress inetAddress = InetAddress.getByName(ip);
multicastSocket.joinGroup(inetAddress);
System.out.println("Listening on " + ip + ":7777");
// Loop forever and receive messages from clients. Print
// the received messages.
while (true)
{
byte [] arb = new byte [100];
DatagramPacket datagramPacket = new DatagramPacket(arb,
arb.length);
multicastSocket.receive(datagramPacket);
String s = new String(arb);
System.out.println(s);
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
I add the interfaces needed for multicast traffic to 224.0.0.0 on both
linux machines:
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth1
route add -net 224.0.0.0 netmask 240.0.0.0 dev ppp0
I have two windows laptops connected to the linux boxes via ethernet,
the linux boxes are connected via PPP.
When I run the scripts anywhere, they're only recieved by whatever
device is listed first in the routing table. So if ppp0 is listed above
eth1, and I start the script on a linux machine, they're recieved ONLY
by the second linux box because they're connected via ppp. If I start
the script on a linux box, and eth1 is first up, then it's recieved by
the locally attached laptop ONLY.
I have NAT/ICS set up on the linux machines. I can ping every device,
from any device (laptop to laptop, linux box to remote laptop, etc). I
can access shares everywhere and FTP to any device. I just cannot get
these packets to go to every machine simultaneously.
Any thoughts on how this could be accomplished?
|