IPGlobalProperties.GetIcmpV4Statistics 方法

定義

提供本機電腦的網際網路控制訊息通訊協定 (Internet Control Message Protocol,ICMP) 第 4 版統計資料。

public:
 abstract System::Net::NetworkInformation::IcmpV4Statistics ^ GetIcmpV4Statistics();
public abstract System.Net.NetworkInformation.IcmpV4Statistics GetIcmpV4Statistics ();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IcmpV4Statistics GetIcmpV4Statistics ();
abstract member GetIcmpV4Statistics : unit -> System.Net.NetworkInformation.IcmpV4Statistics
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
abstract member GetIcmpV4Statistics : unit -> System.Net.NetworkInformation.IcmpV4Statistics
Public MustOverride Function GetIcmpV4Statistics () As IcmpV4Statistics

傳回

IcmpV4Statistics 物件,提供本機電腦的 ICMP 第 4 版流量統計資料。

屬性

例外狀況

Win32 函式 GetIcmpStatistics 失敗。

範例

下列範例會顯示目前的ICMPv4統計數據。

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( "" );
}
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("");
}

備註

ICMP 是一組訊息,可與因特網通訊協定第 4 版 (IPv4) 搭配使用。 IPv4 節點會使用ICMP來報告處理數據封包時遇到的錯誤,以及執行其他因特網層函式。 ICMP 第 4 版是在 IETF RFC 792 中定義。

如需應用程式可用ICMP第4版流量統計數據的詳細資訊,請參閱 IcmpV4Statistics 類別檔。 請注意, IcmpV4Statistics 這個方法所傳回的物件會反映建立物件時所傳回的統計數據。 這項資訊不會動態更新。

適用於