http://www.perlmonks.org?node_id=973878


in reply to Same multicast packet received by multiple NICs

I also caveat that I've never used this module before. You could try specifying the interface device rather than the IP assigned to it, but since mcast_add just uses that to lookup the device IP, I can't see that it would make any difference.

If I want to see what's appearing on the NIC, I lean towards going to the source. You can use Net::Pcap with a compiled filter to get what you're looking for -- no pesky network stack mucking things up :)

fnord

  • Comment on Re: Same multicast packet received by multiple NICs

Replies are listed 'Best First'.
Re^2: Same multicast packet received by multiple NICs
by sophate (Beadle) on Jun 01, 2012 at 23:15 UTC

    Thanks but I don't think the interface device name or IP matters here. Actually I'm using the workaround to use Perl sockets to listen to the mcast from the NICs then create additional threads to monitor the traffic with tcpdump. It looks clumsy but it works. However, I still have no clue why recv() of a socket mapped to a particular NIC can receives data from ALL NICs listening to the same mcast address:port.

      It may depend on your OS. This module creates a socket of type SOCK_DGRAM. These route at the IP/UDP level. I know the module says it can limit you to what's on one NIC, but I'm pretty sure on Linux there's no way to enforce this. The point of multicast is to deliver to every endpoint using that destination address. Maybe the Windows stack has hooks to limit this. I am curious as to why you need to listen for the mcast traffic on a socket if you're using tcpdump to see them as well. You can pass a filter to tcpdump to only see what you're looking for.

      fnord

        Hi, the socket is actually for joining the mcast group to draw the traffic into the NIC. Tcpdump is just for watching if there are any packets flowing through the NIC. Correct me if I'm wrong, I can't join a mcast group with just topdump :-)