private static void PrintIcmp6Statistics() { IcmpV6Statistics stats = IPGlobalProperties.GetIPGlobalProperties().GetIcmpV6Statistics(); Console.WriteLine("--ICMPv6 Statistics--"); PrintProperties(stats); }
private string GetIcmpV6Statistics(IPGlobalProperties properties) { IcmpV6Statistics icmpV6Stat = null; StringBuilder icmpV6StatBuilder = new StringBuilder(); try { icmpV6Stat = properties.GetIcmpV6Statistics(); } catch (NetworkInformationException) { return(String.Empty); } icmpV6StatBuilder.Append("ICMPv6 Statistics\n"); icmpV6StatBuilder.Append("=================================================\n"); icmpV6StatBuilder.AppendFormat(" Messages ...................... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.MessagesSent, icmpV6Stat.MessagesReceived); icmpV6StatBuilder.AppendFormat(" Errors ........................ : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.ErrorsSent, icmpV6Stat.ErrorsReceived); icmpV6StatBuilder.AppendFormat(" Echo Requests ................. : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.EchoRequestsSent, icmpV6Stat.EchoRequestsReceived); icmpV6StatBuilder.AppendFormat(" Echo Replies .................. : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.EchoRepliesSent, icmpV6Stat.EchoRepliesReceived); icmpV6StatBuilder.AppendFormat(" Destination Unreachables ...... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.DestinationUnreachableMessagesSent, icmpV6Stat.DestinationUnreachableMessagesReceived); icmpV6StatBuilder.AppendFormat(" Parameter Problems ............ : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.ParameterProblemsSent, icmpV6Stat.ParameterProblemsReceived); icmpV6StatBuilder.AppendFormat(" Packets Too Big ............... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.PacketTooBigMessagesSent, icmpV6Stat.PacketTooBigMessagesReceived); icmpV6StatBuilder.AppendFormat(" Redirects ..................... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.RedirectsSent, icmpV6Stat.RedirectsReceived); icmpV6StatBuilder.AppendFormat(" Router Advertisements ......... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.RouterAdvertisementsSent, icmpV6Stat.RouterAdvertisementsReceived); icmpV6StatBuilder.AppendFormat(" Router Solicitations .......... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.RouterSolicitsSent, icmpV6Stat.RouterSolicitsReceived); icmpV6StatBuilder.AppendFormat(" Time Exceeded ................. : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.TimeExceededMessagesSent, icmpV6Stat.TimeExceededMessagesReceived); icmpV6StatBuilder.AppendFormat(" Neighbor Advertisements ....... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.NeighborAdvertisementsSent, icmpV6Stat.NeighborAdvertisementsReceived); icmpV6StatBuilder.AppendFormat(" Neighbor Solicitations ........ : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.NeighborSolicitsSent, icmpV6Stat.NeighborSolicitsReceived); icmpV6StatBuilder.AppendFormat(" Membership Queries ............ : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.MembershipQueriesSent, icmpV6Stat.MembershipQueriesReceived); icmpV6StatBuilder.AppendFormat(" Membership Reports ............ : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.MembershipReportsSent, icmpV6Stat.MembershipReportsReceived); icmpV6StatBuilder.AppendFormat(" Membership Reductions ......... : Sent: {0,-10} Received: {1,-10}\n", icmpV6Stat.MembershipReductionsSent, icmpV6Stat.MembershipReductionsReceived); return(icmpV6StatBuilder.ToString()); }
//</Snippet38> //<Snippet39> public static void ShowIcmpV6ParameterData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", statistics.ParameterProblemsSent, statistics.ParameterProblemsReceived); }
//</Snippet37> //<Snippet38> public static void ShowIcmpV6TimeExceededData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", statistics.TimeExceededMessagesSent, statistics.TimeExceededMessagesReceived); }
//</Snippet36> //<Snippet37> public static void ShowIcmpV6RedirectsData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Redirects ........................... Sent: {0,-10} Received: {1,-10}", statistics.RedirectsSent, statistics.RedirectsReceived); }
//</Snippet35> //<Snippet36> public static void ShowIcmpV6BigPacketData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Too Big Packet ........................ Sent: {0,-10} Received: {1,-10}", statistics.PacketTooBigMessagesSent, statistics.PacketTooBigMessagesReceived); }
//</Snippet31> //<Snippet32> public static void ShowIcmpV6UnreachableData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", statistics.DestinationUnreachableMessagesSent, statistics.DestinationUnreachableMessagesReceived); }
//</Snippet39> //<Snippet40> public static void ShowIcmpV6RouterData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Advertisements ....................... Sent: {0,-10} Received: {1,-10}", statistics.RouterAdvertisementsSent, statistics.RouterAdvertisementsReceived); Console.WriteLine(" Solicits ............................. Sent: {0,-10} Received: {1,-10}", statistics.RouterSolicitsSent, statistics.RouterSolicitsReceived); }
//</Snippet29> //<Snippet30> public static void ShowIcmpV6EchoData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", statistics.EchoRequestsSent, statistics.EchoRequestsReceived); Console.WriteLine(" Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", statistics.EchoRepliesSent, statistics.EchoRepliesReceived); }
internal static void ShowIcmpv6MessagesAndErrors(IcmpV6Statistics stat6) { if (stat6 != null && Socket.OSSupportsIPv6) { Console.WriteLine("ICMP v6 Messages ...................... Sent: {0,-10} Received: {1,-10}", stat6.MessagesSent, stat6.MessagesReceived); Console.WriteLine("ICMP v6 Errors ........................ Sent: {0,-10} Received: {1,-10}", stat6.ErrorsSent, stat6.ErrorsReceived); } }
public static void ShowEchoIcmpv6(IcmpV6Statistics stat6) { if (stat6 != null) { Console.WriteLine("ICMP v6 Echo Requests.................. Sent: {0,-10} Received: {1,-10}", stat6.EchoRequestsSent, stat6.EchoRequestsReceived); Console.WriteLine("ICMP v6 Echo Replies .................. Sent: {0,-10} Received: {1,-10}", stat6.EchoRepliesSent, stat6.EchoRepliesReceived); } }
//</Snippet33> //<Snippet34> public static void ShowIcmpV6MembershipData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics statistics = properties.GetIcmpV6Statistics(); Console.WriteLine(" Queries .............................. Sent: {0,-10} Received: {1,-10}", statistics.MembershipQueriesSent, statistics.MembershipQueriesReceived); Console.WriteLine(" Reductions ........................... Sent: {0,-10} Received: {1,-10}", statistics.MembershipReductionsSent, statistics.MembershipReductionsReceived); Console.WriteLine(" Reports .............................. Sent: {0,-10} Received: {1,-10}", statistics.MembershipReportsSent, statistics.MembershipReportsReceived); }
//</Snippet6> //<Snippet7> public static void ShowIcmpV6Statistics() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics stat = properties.GetIcmpV6Statistics(); Console.WriteLine("ICMP V6 Statistics:"); Console.WriteLine(" Messages ............................ Sent: {0,-10} Received: {1,-10}", stat.MessagesSent, stat.MessagesReceived); Console.WriteLine(" Errors .............................. Sent: {0,-10} Received: {1,-10}", stat.ErrorsSent, stat.ErrorsReceived); Console.WriteLine(" Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", stat.EchoRequestsSent, stat.EchoRequestsReceived); Console.WriteLine(" Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", stat.EchoRepliesSent, stat.EchoRepliesReceived); Console.WriteLine(" Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", stat.DestinationUnreachableMessagesSent, stat.DestinationUnreachableMessagesReceived); Console.WriteLine(" Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", stat.ParameterProblemsSent, stat.ParameterProblemsReceived); Console.WriteLine(" Packets Too Big ..................... Sent: {0,-10} Received: {1,-10}", stat.PacketTooBigMessagesSent, stat.PacketTooBigMessagesReceived); Console.WriteLine(" Redirects ........................... Sent: {0,-10} Received: {1,-10}", stat.RedirectsSent, stat.RedirectsReceived); Console.WriteLine(" Router Advertisements ............... Sent: {0,-10} Received: {1,-10}", stat.RouterAdvertisementsSent, stat.RouterAdvertisementsReceived); Console.WriteLine(" Router Solicitations ................ Sent: {0,-10} Received: {1,-10}", stat.RouterSolicitsSent, stat.RouterSolicitsReceived); Console.WriteLine(" Time Exceeded ....................... Sent: {0,-10} Received: {1,-10}", stat.TimeExceededMessagesSent, stat.TimeExceededMessagesReceived); Console.WriteLine(" Neighbor Advertisements ............. Sent: {0,-10} Received: {1,-10}", stat.NeighborAdvertisementsSent, stat.NeighborAdvertisementsReceived); Console.WriteLine(" Neighbor Solicitations .............. Sent: {0,-10} Received: {1,-10}", stat.NeighborSolicitsSent, stat.NeighborSolicitsReceived); Console.WriteLine(" Membership Queries .................. Sent: {0,-10} Received: {1,-10}", stat.MembershipQueriesSent, stat.MembershipQueriesReceived); Console.WriteLine(" Membership Reports .................. Sent: {0,-10} Received: {1,-10}", stat.MembershipReportsSent, stat.MembershipReportsReceived); Console.WriteLine(" Membership Reductions ............... Sent: {0,-10} Received: {1,-10}", stat.MembershipReductionsSent, stat.MembershipReductionsReceived); Console.WriteLine(""); }
private void UpdateICMPv6Stats() { try { IPGlobalProperties ipgp = IPGlobalProperties.GetIPGlobalProperties(); IcmpV6Statistics stat = ipgp.GetIcmpV6Statistics(); txtDestinationUnreachableMessagesReceivedICMPv6.Text = stat.DestinationUnreachableMessagesReceived.ToString("n", nfi); txtEchoRepliesReceivedICMPv6.Text = stat.EchoRepliesReceived.ToString("n", nfi); txtEchoRequestsReceivedICMPv6.Text = stat.EchoRequestsReceived.ToString("n", nfi); txtErrorsReceivedICMPv6.Text = stat.ErrorsReceived.ToString("n", nfi); txtMembershipQueriesReceivedICMPv6.Text = stat.MembershipQueriesReceived.ToString("n", nfi); txtMembershipReductionsReceivedICMPv6.Text = stat.MembershipReductionsReceived.ToString("n", nfi); txtMembershipReportsReceivedICMPv6.Text = stat.MembershipReportsReceived.ToString("n", nfi); txtMessagesReceivedICMPv6.Text = stat.MessagesReceived.ToString("n", nfi); txtNeighborAdvertisementsReceivedICMPv6.Text = stat.NeighborAdvertisementsReceived.ToString("n", nfi); txtNeighborSolicitsReceivedICMPv6.Text = stat.NeighborSolicitsReceived.ToString("n", nfi); txtPacketTooBigMessagesReceivedICMPv6.Text = stat.PacketTooBigMessagesReceived.ToString("n", nfi); txtParameterProblemsReceivedICMPv6.Text = stat.ParameterProblemsReceived.ToString("n", nfi); txtRedirectsReceivedICMPv6.Text = stat.RedirectsReceived.ToString("n", nfi); txtRouterAdvertisementsReceivedICMPv6.Text = stat.RouterAdvertisementsReceived.ToString("n", nfi); txtRouterSolicitsReceivedICMPv6.Text = stat.RouterSolicitsReceived.ToString("n", nfi); txtTimeExceededMessagesReceivedICMPv6.Text = stat.TimeExceededMessagesReceived.ToString("n", nfi); txtDestinationUnreachableMessagesSentICMPv6.Text = stat.DestinationUnreachableMessagesSent.ToString("n", nfi); txtEchoRepliesSentICMPv6.Text = stat.EchoRepliesSent.ToString("n", nfi); txtEchoRequestsSentICMPv6.Text = stat.EchoRequestsSent.ToString("n", nfi); txtErrorsSentICMPv6.Text = stat.ErrorsSent.ToString("n", nfi); txtMembershipQueriesSentICMPv6.Text = stat.MembershipQueriesSent.ToString("n", nfi); txtMembershipReductionsSentICMPv6.Text = stat.MembershipReductionsSent.ToString("n", nfi); txtMembershipReportsSentICMPv6.Text = stat.MembershipReportsSent.ToString("n", nfi); txtMessagesSentICMPv6.Text = stat.MessagesSent.ToString("n", nfi); txtNeighborAdvertisementsSentICMPv6.Text = stat.NeighborAdvertisementsSent.ToString("n", nfi); txtNeighborSolicitsSentICMPv6.Text = stat.NeighborSolicitsSent.ToString("n", nfi); txtPacketTooBigMessagesSentICMPv6.Text = stat.PacketTooBigMessagesSent.ToString("n", nfi); txtParameterProblemsSentICMPv6.Text = stat.ParameterProblemsSent.ToString("n", nfi); txtRedirectsSentICMPv6.Text = stat.RedirectsSent.ToString("n", nfi); txtRouterAdvertisementsSentICMPv6.Text = stat.RouterAdvertisementsSent.ToString("n", nfi); txtRouterSolicitsSentICMPv6.Text = stat.RouterSolicitsSent.ToString("n", nfi); txtTimeExceededMessagesSentICMPv6.Text = stat.TimeExceededMessagesSent.ToString("n", nfi); } catch (NetworkInformationException) { } catch (PlatformNotSupportedException) { } }
// Display the data for given IcmpV6Statistics object. private static void DisplayIcmpV6Statistics( IPGlobalProperties ipGlobal) { string protocol = GetProtocolString(ProtocolTypes.IcmpV6); Console.WriteLine(); Console.WriteLine("{0} Statistics", protocol); try { IcmpV6Statistics icmpStat = ipGlobal.GetIcmpV6Statistics(); Console.WriteLine(sendReceiveFormatString, "", "Received", "Sent"); Console.WriteLine( sendReceiveFormatString, "Messages", icmpStat.MessagesReceived, icmpStat.MessagesSent); Console.WriteLine( sendReceiveFormatString, "Errors", icmpStat.ErrorsReceived, icmpStat.ErrorsSent); Console.WriteLine( sendReceiveFormatString, "Destination Unreachable", icmpStat.DestinationUnreachableMessagesReceived, icmpStat.DestinationUnreachableMessagesSent); Console.WriteLine( sendReceiveFormatString, "Time Exceeded", icmpStat.TimeExceededMessagesReceived, icmpStat.TimeExceededMessagesSent); Console.WriteLine( sendReceiveFormatString, "Parameter Problems", icmpStat.ParameterProblemsReceived, icmpStat.ParameterProblemsSent); Console.WriteLine( sendReceiveFormatString, "Redirects", icmpStat.RedirectsReceived, icmpStat.RedirectsSent); Console.WriteLine( sendReceiveFormatString, "Echos", icmpStat.EchoRepliesReceived, icmpStat.EchoRepliesSent); Console.WriteLine( sendReceiveFormatString, "Echo Replies", icmpStat.EchoRepliesReceived, icmpStat.EchoRepliesSent); Console.WriteLine( sendReceiveFormatString, "Membership Queries", icmpStat.MembershipQueriesReceived, icmpStat.MembershipQueriesSent); Console.WriteLine( sendReceiveFormatString, "Membership Reductios", icmpStat.MembershipReductionsReceived, icmpStat.MembershipReductionsSent); Console.WriteLine( sendReceiveFormatString, "Membership Reports", icmpStat.MembershipReportsReceived, icmpStat.MembershipReportsSent); Console.WriteLine( sendReceiveFormatString, "Neighbour Advertisements", icmpStat.NeighborAdvertisementsReceived, icmpStat.NeighborAdvertisementsSent); Console.WriteLine( sendReceiveFormatString, "Neighbour Solicit", icmpStat.NeighborSolicitsReceived, icmpStat.NeighborSolicitsSent); Console.WriteLine( sendReceiveFormatString, "Packets Too Large", icmpStat.PacketTooBigMessagesReceived, icmpStat.PacketTooBigMessagesSent); Console.WriteLine( sendReceiveFormatString, "Redirects", icmpStat.RedirectsReceived, icmpStat.RedirectsSent); Console.WriteLine( sendReceiveFormatString, "Router Advertisements", icmpStat.RouterAdvertisementsReceived, icmpStat.RouterAdvertisementsSent); Console.WriteLine( sendReceiveFormatString, "Router Solicits", icmpStat.RouterSolicitsReceived, icmpStat.RouterSolicitsSent); } catch (NetworkInformationException ex) { Console.WriteLine(errorFormatString, protocol, ex.Message); } }