Re: Too much multicasting in Linux

From: Johan Hendriks (j.w.hendriks_at_wanadoo.nl)
Date: 04/07/04


Date: Wed, 7 Apr 2004 10:09:30 +0200


"bnt" <bnt@fastpace.org> schreef in bericht
news:8325087d.0404060741.5930f71a@posting.google.com...
> Hello everybody. I've run into something that amazes me.
>
> I've seen some posts from people who can't send/receive datagrams sent
> to multicast addresses. I have the opposite problem.
>
> I have a pair of Java classes (hold on, this is not a Java related
> question, as you will see...) that do some things with multicast
> addresses. One of them is sending some datagram packets to the
> multicast address 224.0.1.84, port 4160. The other is listening for
> datagram packets sent to the address 224.0.1.85. It listens to port
> 4160.
>
> Now, see that the latter application has joined the multicast group
> 224.0.1.85, while the first application has joined no group, it just
> sends its data to 224.0.1.84:4160.
>
> I expected the second application NOT to receive the datagrams. But
> that's exactly what it does: it is receiving datagrams sent to a
> multicast address it's not subscribed to.
>
> I first thought it could be the Java implementation, so I went and
> copied a quick multicasting example from the net, in C. The results
> are the same.
>
> After some tests, it seems that whenever a UDP socket is created and
> it joins ANY multicast group (class D IP address) and that socket is
> bound to port A, any datagram sent to any class D IP address and port
> A is received by this socket.
>
> Has anybody any idea of what is going on? I can provide source code
> if you wish. BTW, linux kernel is 2.4.25. What kernel options would
> be useful to know?
>
> I've spent quite a long time (some hours, now) looking for info in the
> Internet, but it seems the common problem is the opposite. Moreover,
> all tutorials/docs say you MUST join a multicast group before you can
> receive udp packets sent to that address.
>
> TIA.

To send multicast messages, you don't have to do anything special.
Just apply the multicast address and the kernel (network driver) will
recognize this and generate
the expected packets.

Only on the receiving side you must join a multicast group (setsocktopt)
after binding the socket to a port.

Above applies to a socket implementation. Your JAVA classes should not do
anything more

Johan



Relevant Pages

  • Re: Too much multicasting in Linux
    ... > that didn't join the multicast address where the data is being sent. ... > the interface 0.0.0.0 causes them to receive all data. ... if I have a socket that joins the SAME ... > multicast group but is tied to a different interface it will not receive ...
    (comp.os.linux.networking)
  • Re: Too much multicasting in Linux
    ... that didn't join the multicast address where the data is being sent. ... if I have a socket that joins the SAME ... multicast group but is tied to a different interface it will not receive ... > Only on the receiving side you must join a multicast group ...
    (comp.os.linux.networking)
  • Re: Question for multicast
    ... I am implementing multicast on Windows server 2003. ... bind to a specific multicast address when created a socket. ... (If you only want to /send/ multicast there's no need to set any socket option (do a join etc)). ... what if I need listen to more than one multicast group? ...
    (microsoft.public.win32.programmer.networks)
  • Re: Question for multicast
    ... the multicast group address I use is valid ... I am implementing multicast on Windows server 2003. ... a specific multicast address when created a socket. ... and bind the UDP socket for multicasting. ...
    (microsoft.public.win32.programmer.networks)
  • Too much multicasting in Linux
    ... to multicast addresses. ... multicast address 224.0.1.84, port 4160. ... see that the latter application has joined the multicast group ... I expected the second application NOT to receive the datagrams. ...
    (comp.os.linux.networking)