I have two processes running on my box as follows:
- Normal client program sending to multicast 224.1.2.3:8000
- "Router" process
The router process is joined to two multicast groups:
- 224.1.2.3:8000
- 224.1.2.4:8001
The idea behind the router is simple, when traffic comes in from either multicast group, simply forward it to the other multicast group. In order to do this, I turn off multicast loopback on the router process so that it doesn't "hear what it sends" (as is normal with multicasting.)
The idea is complicated by the fact that there is a "normal" process running on the same machine. With multicast loopback turned off, the router process doesn't see the traffic that originates from the normal process, and thus the normal process' traffic cannot be routed properly.
I could turn on multicast loopback in the router process, but I dont know how to identify the process that sent the packets. Without identifying the packet's source process, I get stuck in a loop:
receive_packet from 224.1.2.3:8000
--- Forward packet to 224.1.2.4:8001 ---
<< Forwarding causes a receive packet >>
receive_packet from 224.1.2.4:8001
--- Forward packet to 224.1.2.3:8000 ---
<< Forwarding causes a receive packet >>
Unfortunately I can't simply encode that information into the the packets that are sent.
Any ideas? All help is greatly appreciated.
-- Dan
Edit:
My coworker suggested implementing a third multicast group specifically for the normal client to send stuff to the router. In this scenario the normal client would listen on 224.1.2.3:8000 and send across 224.1.2.3:8002. The router would also listen on 8002 and forward it appropriately. It would just never send anything across 8002 (ie. it would treat 8002 as a one way pipe from the normal client.)
This would actually work for many cases, but unfortunately the underlying software requires two way communication on the multicast socket during a number of common operations. So that's a no go.