1

I built a library for doing IGMP stuff. Now, the silly thing is, my library also does presence monitoring to make sure others are still part of the group.

IGMP does exactly the same thing at a lower level. Parting messages, polling to the router that it's still part of the same group, the whole thing. I've just repeated all the same work, and it's likely not as robust.

I can make everything a lot cleaner (and I wouldn't be reinventing the wheel) if I could tap into those packets.

Anyone have any experience doing this? Maybe create some sort of crazy socket? I don't want to use libpcap for it. I don't think the language matters, as long as it's possible using Sockets on Windows/Linux

RandomInsano
  • 1,204
  • 2
  • 16
  • 36
  • AFAIK there is NO pure .NET/Mono solution for this level of accesss... best bet is a driver which integrates wird the network stack... such a driver can be written using C – Yahia Oct 13 '11 at 20:40
  • It's looking likely possible using raw sockets. IOControlCode.ReceiveAllIgmpMulticast Still researching – RandomInsano Oct 13 '11 at 21:54

1 Answers1

1

Alright, found a way. It's super dirty right now since I have to extract the information I need by hand, but this is in essence how you pull IGMP data on an interface (note that you need to have administrator privileges to pull raw data):

var buffer = new byte[65536];
var s = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Igmp); // filter out non IGMP
byte[] one = BitConverter.GetBytes(1);
s.Bind(new IPEndPoint(IPAddress.Parse("192.168.1.148"), 0)); // Which interface to listen on
s.IOControl(IOControlCode.ReceiveAll, one, one); // enter promiscuous mode
s.Recieve(buffer); // get yourself some data (BeginRecieve didn't seem to work here)

then do something with said buffer. If you poke in wireshark you can see the packet breakdown

RandomInsano
  • 1,204
  • 2
  • 16
  • 36
  • Also, 65536 is huge. Because of where these messages are in the IP stack, the number should actually be the size of your MTU. I think 9K is the max now? – RandomInsano Oct 13 '11 at 23:06