private void UpdateICMPv4Stats() { IPGlobalProperties ipgp = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics stat = ipgp.GetIcmpV4Statistics(); txtAddressMaskRepliesReceived.Text = stat.AddressMaskRepliesReceived.ToString("n", nfi); txtAddressMaskRequestsReceived.Text = stat.AddressMaskRequestsReceived.ToString("n", nfi); txtDestinationUnreachableMessagesReceived.Text = stat.DestinationUnreachableMessagesReceived.ToString("n", nfi); txtEchoRepliesReceived.Text = stat.EchoRepliesReceived.ToString("n", nfi); txtEchoRequestsReceived.Text = stat.EchoRequestsReceived.ToString("n", nfi); txtErrorsReceivedICMPv4.Text = stat.ErrorsReceived.ToString("n", nfi); txtMessagesReceived.Text = stat.MessagesReceived.ToString("n", nfi); txtParameterProblemsReceived.Text = stat.ParameterProblemsReceived.ToString("n", nfi); txtRedirectsReceived.Text = stat.RedirectsReceived.ToString("n", nfi); txtSourceQuenchesReceived.Text = stat.SourceQuenchesReceived.ToString("n", nfi); txtTimeExceededMessagesReceived.Text = stat.TimeExceededMessagesReceived.ToString("n", nfi); txtTimestampRepliesReceived.Text = stat.TimestampRepliesReceived.ToString("n", nfi); txtTimestampRequestsReceived.Text = stat.TimestampRequestsReceived.ToString("n", nfi); txtAddressMaskRepliesSent.Text = stat.AddressMaskRepliesSent.ToString("n", nfi); txtAddressMaskRequestsSent.Text = stat.AddressMaskRequestsSent.ToString("n", nfi); txtDestinationUnreachableMessagesSent.Text = stat.DestinationUnreachableMessagesSent.ToString("n", nfi); txtEchoRepliesSent.Text = stat.EchoRepliesSent.ToString("n", nfi); txtEchoRequestsSent.Text = stat.EchoRequestsSent.ToString("n", nfi); txtErrorsSent.Text = stat.ErrorsSent.ToString("n", nfi); txtMessagesSent.Text = stat.MessagesSent.ToString("n", nfi); txtParameterProblemsSent.Text = stat.ParameterProblemsSent.ToString("n", nfi); txtRedirectsSent.Text = stat.RedirectsSent.ToString("n", nfi); txtSourceQuenchesSent.Text = stat.SourceQuenchesSent.ToString("n", nfi); txtTimeExceededMessagesSent.Text = stat.TimeExceededMessagesSent.ToString("n", nfi); txtTimestampRepliesSent.Text = stat.TimestampRepliesSent.ToString("n", nfi); txtTimestampRequestsSent.Text = stat.TimestampRequestsSent.ToString("n", nfi); }
private static void PrintIcmp4Statistics() { IcmpV4Statistics stats = IPGlobalProperties.GetIPGlobalProperties().GetIcmpV4Statistics(); Console.WriteLine("--ICMPv4 Statistics--"); PrintProperties(stats); }
//</Snippet26> //<Snippet27> public static void ShowParameterData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", statistics.ParameterProblemsSent, statistics.ParameterProblemsReceived); }
//</Snippet25> //<Snippet26> public static void ShowTimeExceededData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", statistics.TimeExceededMessagesSent, statistics.TimeExceededMessagesReceived); }
//</Snippet24> //<Snippet25> public static void ShowRedirectsData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" Redirects ........................... Sent: {0,-10} Received: {1,-10}", statistics.RedirectsSent, statistics.RedirectsReceived); }
//</Snippet23> //<Snippet24> public static void ShowSourceQuenchData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" Source Quenches ..................... Sent: {0,-10} Received: {1,-10}", statistics.SourceQuenchesSent, statistics.SourceQuenchesReceived); }
//</Snippet21> //<Snippet22> public static void ShowIcmpV4ErrorData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" Errors .............................. Sent: {0,-10} Received: {1,-10}", statistics.ErrorsSent, statistics.ErrorsReceived); }
//</Snippet22> //<Snippet23> public static void ShowIcmpV4UnreachableData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", statistics.DestinationUnreachableMessagesSent, statistics.DestinationUnreachableMessagesReceived); }
//</Snippet28> //<Snippet29> public static void ShowAddressMaskData() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics statistics = properties.GetIcmpV4Statistics(); Console.WriteLine(" Address Mask Requests ............... Sent: {0,-10} Received: {1,-10}", statistics.AddressMaskRequestsSent, statistics.AddressMaskRequestsReceived); Console.WriteLine(" Address Mask Replies ................ Sent: {0,-10} Received: {1,-10}", statistics.AddressMaskRepliesSent, statistics.AddressMaskRepliesReceived); }
//</Snippet4> //<Snippet5> internal static void ShowIcmpv4MessagesAndErrors(IcmpV4Statistics stat4) { if (stat4 != null) { Console.WriteLine("ICMP v4 Messages ...................... Sent: {0,-10} Received: {1,-10}", stat4.MessagesSent, stat4.MessagesReceived); Console.WriteLine("ICMP v6 Errors ........................ Sent: {0,-10} Received: {1,-10}", stat4.ErrorsSent, stat4.ErrorsReceived); } }
//</Snippet3> //<Snippet4> public static void ShowEchoIcmpv4(IcmpV4Statistics stat4) { if (stat4 != null) { Console.WriteLine("ICMP v4 Echo Requests ................. Sent: {0,-10} Received: {1,-10}", stat4.EchoRequestsSent, stat4.EchoRequestsReceived); Console.WriteLine("ICMP v4 Echo Replies .................. Sent: {0,-10} Received: {1,-10}", stat4.EchoRepliesSent, stat4.EchoRepliesReceived); } }
private string GetIcmpV4Statistics(IPGlobalProperties properties) { IcmpV4Statistics icmpV4Stat = null; StringBuilder icmpV4StatBuilder = new StringBuilder(); try { icmpV4Stat = properties.GetIcmpV4Statistics(); } catch (NetworkInformationException) { return(String.Empty); } icmpV4StatBuilder.Append("ICMPv4 Statistics\n"); icmpV4StatBuilder.Append("=================================================\n"); icmpV4StatBuilder.AppendFormat(" Messages ...................... : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.MessagesSent, icmpV4Stat.MessagesReceived); icmpV4StatBuilder.AppendFormat(" Errors ........................ : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.ErrorsSent, icmpV4Stat.ErrorsReceived); icmpV4StatBuilder.AppendFormat(" Echo Requests ................. : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.EchoRequestsSent, icmpV4Stat.EchoRequestsReceived); icmpV4StatBuilder.AppendFormat(" Echo Replies .................. : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.EchoRepliesSent, icmpV4Stat.EchoRepliesReceived); icmpV4StatBuilder.AppendFormat(" Destination Unreachables ...... : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.DestinationUnreachableMessagesSent, icmpV4Stat.DestinationUnreachableMessagesReceived); icmpV4StatBuilder.AppendFormat(" Source Quenches ............... : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.SourceQuenchesSent, icmpV4Stat.SourceQuenchesReceived); icmpV4StatBuilder.AppendFormat(" Redirects ..................... : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.RedirectsSent, icmpV4Stat.RedirectsReceived); icmpV4StatBuilder.AppendFormat(" TimeExceeded .................. : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.TimeExceededMessagesSent, icmpV4Stat.TimeExceededMessagesReceived); icmpV4StatBuilder.AppendFormat(" Parameter Problems ............ : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.ParameterProblemsSent, icmpV4Stat.ParameterProblemsReceived); icmpV4StatBuilder.AppendFormat(" Timestamp Requests ............ : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.TimestampRequestsSent, icmpV4Stat.TimestampRequestsReceived); icmpV4StatBuilder.AppendFormat(" Timestamp Replies ............. : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.TimestampRepliesSent, icmpV4Stat.TimestampRepliesReceived); icmpV4StatBuilder.AppendFormat(" Address Mask Requests ......... : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.AddressMaskRequestsSent, icmpV4Stat.AddressMaskRequestsReceived); icmpV4StatBuilder.AppendFormat(" Address Mask Replies .......... : Sent: {0,-10} Received: {1,-10}\n", icmpV4Stat.AddressMaskRepliesSent, icmpV4Stat.AddressMaskRepliesReceived); return(icmpV4StatBuilder.ToString()); }
//</Snippet5> //<Snippet6> public static void ShowIcmpV4Statistics() { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IcmpV4Statistics stat = properties.GetIcmpV4Statistics(); Console.WriteLine("ICMP V4 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(" Source Quenches ..................... Sent: {0,-10} Received: {1,-10}", stat.SourceQuenchesSent, stat.SourceQuenchesReceived); Console.WriteLine(" Redirects ........................... Sent: {0,-10} Received: {1,-10}", stat.RedirectsSent, stat.RedirectsReceived); Console.WriteLine(" TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", stat.TimeExceededMessagesSent, stat.TimeExceededMessagesReceived); Console.WriteLine(" Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", stat.ParameterProblemsSent, stat.ParameterProblemsReceived); Console.WriteLine(" Timestamp Requests .................. Sent: {0,-10} Received: {1,-10}", stat.TimestampRequestsSent, stat.TimestampRequestsReceived); Console.WriteLine(" Timestamp Replies ................... Sent: {0,-10} Received: {1,-10}", stat.TimestampRepliesSent, stat.TimestampRepliesReceived); Console.WriteLine(" Address Mask Requests ............... Sent: {0,-10} Received: {1,-10}", stat.AddressMaskRequestsSent, stat.AddressMaskRequestsReceived); Console.WriteLine(" Address Mask Replies ................ Sent: {0,-10} Received: {1,-10}", stat.AddressMaskRepliesSent, stat.AddressMaskRepliesReceived); Console.WriteLine(""); }
// Display the data for given IcmpV4Statistics object. private static void DisplayIcmpV4Statistics( IPGlobalProperties ipGlobal) { string protocol = GetProtocolString(ProtocolTypes.Icmp); Console.WriteLine(); Console.WriteLine("{0} Statistics", protocol); try { IcmpV4Statistics icmpStat = ipGlobal.GetIcmpV4Statistics(); 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, "Source Quenches", icmpStat.SourceQuenchesReceived, icmpStat.SourceQuenchesSent); Console.WriteLine( sendReceiveFormatString, "Redirects", icmpStat.RedirectsReceived, icmpStat.RedirectsSent); Console.WriteLine( sendReceiveFormatString, "Echos", icmpStat.EchoRequestsReceived, icmpStat.EchoRequestsSent); Console.WriteLine( sendReceiveFormatString, "Echo Replies", icmpStat.EchoRepliesReceived, icmpStat.EchoRepliesSent); Console.WriteLine( sendReceiveFormatString, "Timestamps", icmpStat.TimestampRequestsReceived, icmpStat.TimestampRequestsSent); Console.WriteLine( sendReceiveFormatString, "Timestamp Replies", icmpStat.TimestampRepliesReceived, icmpStat.TimestampRepliesSent); Console.WriteLine( sendReceiveFormatString, "Address Masks", icmpStat.AddressMaskRequestsReceived, icmpStat.AddressMaskRequestsSent); Console.WriteLine( sendReceiveFormatString, "Address Mask Replies", icmpStat.AddressMaskRepliesReceived, icmpStat.AddressMaskRepliesSent); } catch (NetworkInformationException ex) { Console.WriteLine(errorFormatString, protocol, ex.Message); } }