//IGMP协议的Info private string setIgmpInfo(IGMPv2Packet IGMP) { string type = IGMP.Type.ToString(); string groupAddress = IGMP.GroupAddress.ToString(); if (type == "MembershipQuery" && IGMP.GroupAddress.ToString() == "0.0.0.0") return "Membership Query, general"; else if (type == "MembershipQuery") return "Membership Query, specific for group " + groupAddress; else if (type == "MembershipReportIGMPv2") return "Membership Report group " + groupAddress; else if (type == "LeaveGroup") return "Leave Group " + groupAddress; else return "Unknown state"; }
public static String IGMPv2Analyzor(ref TreeView tree, IGMPv2Packet igmpv2) { string info = "\r\n--------- IGMPv2 Header --------\r\n"; TreeNode IGMP2Node = new TreeNode("IGMP(Internet Group Management Protocol)v2 Header"); string type, maxrt, chk, gaddr, ecp; try { IGMP2Node.Nodes.Add(type = "Type = " + igmpv2.Type.ToString()); IGMP2Node.Nodes.Add(maxrt = "MaxResponseTime = " + igmpv2.MaxResponseTime.ToString()); IGMP2Node.Nodes.Add(chk = "Checksum = " + igmpv2.Checksum.ToString()); IGMP2Node.Nodes.Add(gaddr = "GroupAddress = " + igmpv2.GroupAddress.ToString()); info += type + "\r\n" + maxrt + "\r\n" + chk + "\r\n" + gaddr + "\r\n"; } catch (Exception) { IGMP2Node.Nodes.Add(ecp = "IGMP segment or incomplete header"); info += ecp + "\r\n"; } tree.Nodes.Add(IGMP2Node); return info; }