开发者

receiving multicast on a server with multiple interfaces (linux)

To receive a multicast on my not default NIC (dvb) I do the following:

  • 开发者_开发问答open a socket (AF_INET, SOCK_DGRAM)
  • join the multicast address with IP_ADD_MEMBERSHIP on the dvb interface
  • bind the multicast address (note that a common error is to bind "0.0.0.0" and then receive on that socket even multicast you are not interested in) and the port

at this point the only way to receive the needed multicast packets is to add in the routing table a rule to reach the network where the sender is (another network) trough the dvb, as if the dvb needs to reply to the multicast sender; let say a sort of source sender multicast mode. Anyone knows what is going on? The problem is annoying to me because in principle I don't know the ip of sender.


You appear to be being stung by rp_filter reverse-path filtering. This drops packets if they arrive on an interface that doesn't have a route for the source address.

You can disable it on a per-interface basis with the sysctl /proc/sys/net/ipv4/conf/<if>/rp_filter.


bind the multicast address

That is definitely wrong. You must bind to an actual IP address of a real adapter, or 0.0.0.0.

note that a common error is to bind "0.0.0.0"

That's not an error. THat is correct procedure unless you only want to listen to one IP address.

and then receive on that socket even multicast you are not interested in

I don't know what this means.

in principle I don't know the ip of sender

The IP address of the sender of any UDP datagram is available via the sockets API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜