Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

listing multicast sockets

I am trying to list all opened multicast sockets on a linux system? netstat -g lists the groups joined though. Is there any other utility that I can use for this sake?

Thanks a lot for the help.

like image 370
Sreeram Ravinoothala Avatar asked Apr 09 '13 03:04

Sreeram Ravinoothala


2 Answers

I don't think there is a tool that can give you that information.

The reason is that a multicast socket is not bound to an address, it only participates in a multicast group (IP_ADD_MEMBERSHIP). A socket can join multiple different groups on the same interface, or same group on different interfaces, so it would make little sense to maintain these cross refences. The only information exposed by the kernel is in /proc/net, and in this case /proc/net/igmp (<- netstat -g).

like image 179
Catalin Avatar answered Oct 08 '22 12:10

Catalin


In addition to netstat -g you can use this to see all sockets which are bound to a multicast address:

netstat -anu|sort -nk4

This is a list of all UDP sockets (whether multicast or not). Look for all addresses in the range 224.0.0.0 to 239.255.255.255. These are sockets bound to multicast addresses, regardless whether they joined the multicast group or not. These will only receive traffic for this multicast group.

But:

In practice UDP sockets which are used to receive multicast traffic are usually bound to address 0.0.0.0. These can receive UDP packets for all unicast and multicast addresses, and the server usually does some additional filtering based on the source-IP-address.

So in that list above you may want to look also at UDP sockets bound to 0.0.0.0, for example 0.0.0.0:5353 which is most likely the mDNS (avahi, zeroconf) server.

like image 44
Johannes Overmann Avatar answered Oct 08 '22 12:10

Johannes Overmann