Re: multicast: same port, different IP address?

From: David Stevens
Date: Wed Apr 08 2009 - 15:51:26 EST


Matt Garman <matthew.garman@xxxxxxxxx> wrote on 04/08/2009 11:43:48 AM:

> Is it a dangerous oversimplification to think of the port as simply an
> extension of the address? E.g., you have address 239.0.0.1 port 1234,
> but just call it 239.0.0.1.1234. Then you can tell at a glance that
> it will result in a different socket than 239.0.0.2.1234 (i.e. address
> 239.0.0.2 port 1234). [I'm not suggesting using this nomenclature, it
> just seems like an intuitive way to think about/explain it.]

That is correct.

Note that there is no port number for a raw socket. UDP is entirely
appropriate, and as already mentioned, the sender should send to
the multicast destination. You should specify the outgoing interface
for the sender(s) and receivers. You can do this using the IP_MULTICAST_IF
or
SO_BINDTODEVICE socket options. Although the unicast routing table
may be used for senders as a last resort, it's usually a good idea to
know exactly which interface you're sending on.

Finally, note that for receivers, it does matter which interface
you specify. Binding to 239.0.0.2 on one interface will not deliver
packets for that address on a different interface without a separate
join, and 239.0.0.2 on two different interfaces may be different
groups (ie, have different traffic) if they are not in the same
multicast routing domain (or if you have no multicast routers
configured at all). So, also, generally, the application
cares which interface(s) it listens on and should specify them
explicitly.

+-DLS

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html