tags:

views:

26

answers:

3

I'm looking for some networking gurus to help me with a problem. I have many computers running my software which uses UDP multicasting. This works fine if the computers are connected ONLY to one network (network A). My computer (which is also running said software) will listen on port XXXX for the multicasts. This computer has two network cards and when I connect it to another network, network B, my software goes haywire. The problem is that I do not know what network a given multicast came from. And if I send out a multicast, I cannot tell it to use network A instead of network B or vice versa.

My questions:

  1. Is there a way to distinguish packets coming in from different networks??
  2. Is there a way to send a multicast to network A and NOT network B?

I'm using C++ and Win32 sockets. Thanks to anyone that replies.

+1  A: 

You should listen for multicast packets on one interface where you joined the group. You should explicitly set the interface used for sending the multicast packets (otherwise they are routed as everything else, default route, etc.). Both are accomplished via setsockopt calls. Here are some links for you:

Disclaimer: the links are admittedly Unix-centric, so your Windows mileage may vary :)

Nikolai N Fetissov
Actually these links are relevant. Using: setsockopt with IP_MULTICAST_IF might solve my problem.
A: 

Working on a project with MC UDP on redundant NICs over the last year, we saw a similar problem. After battling it a bit with winsock, our ultimate solution was to prioritize traffic using the DOS command route

route add 224.x.x.x  ... [desired gateway] METRIC 1

This ensured that the traffic only went out on the Interface we wanted.

I realize this might not be exactly what you want, but it could at least be a stopgap solution while you implement another fix.

Nate