I'm writing a code to work through sockets in java. I've created a multicast group to which anybody can join on the LAN. But the LAN has many different networks, operated by a router, and the multicast group created by the code would be different in different network and if a person multicast's something to the multicast group in the network A it will only be received by the people joined to the group in that network only, and not by all the people's in different networks.
The multicast group is, let's say, 220.127.116.11. And the LAN has 2 different networks.
Network A = 172.22.28.0/255.255.254.0
Network B = 172.22.30.0/255.255.254.0
Then there will be two different multicast group, with the same address as 18.104.22.168, in the two different networks.
My problem is How can I multicast over these two diff. networks on the LAN through java?
As I was searching for the solution, I came across the concept of IP ENCAPSULATION, in which I can add an outer ip address to the packet, so that it can go through different networks. I think this should work as I can encapsulate the other network's address on the packet send.
Can somebody tell me that how can this(IP ENCAPSULATION) be implemented in java? If not, Is there any other method possible which I can apply.
Any help Appreciated.