好吧,找到方法了。它现在超级脏,因为我必须手动提取我需要的信息,但这本质上是您在接口上提取 IGMP 数据的方式(请注意,您需要具有管理员权限才能提取原始数据):
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)
然后用所述缓冲区做一些事情。如果你戳wireshark,你可以看到数据包分解