IPGlobalProperties.GetTcpIPv6Statistics 方法

定义

提供本地计算机的传输控制协议/Internet 协议版本 6 (TCP/IPv6) 统计数据。

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

返回

一个 TcpStatistics 对象,提供本地计算机的 TCP/IPv6 流量统计数据。

属性

例外

调用 Win32 函数 GetTcpStatistics 失败。

本地计算机运行的操作系统不支持 IPv6。

示例

以下示例显示本地计算机的 TCP/IP 统计信息。

void ShowTcpStatistics( NetworkInterfaceComponent version )
{
   IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
   TcpStatistics ^ tcpstat = nullptr;
   Console::WriteLine( "" );
   switch ( version )
   {
      case NetworkInterfaceComponent::IPv4:
         tcpstat = properties->GetTcpIPv4Statistics();
         Console::WriteLine( "TCP/IPv4 Statistics:" );
         break;

      case NetworkInterfaceComponent::IPv6:
         tcpstat = properties->GetTcpIPv6Statistics();
         Console::WriteLine( "TCP/IPv6 Statistics:" );
         break;

      default:
         throw gcnew ArgumentException( "version" );
         break;
   }
   Console::WriteLine( "  Minimum Transmission Timeout............. : {0}",
      tcpstat->MinimumTransmissionTimeout );
   Console::WriteLine( "  Maximum Transmission Timeout............. : {0}",
      tcpstat->MaximumTransmissionTimeout );
   Console::WriteLine( "  Connection Data:" );
   Console::WriteLine( "      Current  ............................ : {0}",
      tcpstat->CurrentConnections );
   Console::WriteLine( "      Cumulative .......................... : {0}",
      tcpstat->CumulativeConnections );
   Console::WriteLine( "      Initiated ........................... : {0}",
      tcpstat->ConnectionsInitiated );
   Console::WriteLine( "      Accepted ............................ : {0}",
      tcpstat->ConnectionsAccepted );
   Console::WriteLine( "      Failed Attempts ..................... : {0}",
      tcpstat->FailedConnectionAttempts );
   Console::WriteLine( "      Reset ............................... : {0}",
      tcpstat->ResetConnections );
   Console::WriteLine( "" );
   Console::WriteLine( "  Segment Data:" );
   Console::WriteLine( "      Received  ........................... : {0}",
      tcpstat->SegmentsReceived );
   Console::WriteLine( "      Sent ................................ : {0}",
      tcpstat->SegmentsSent );
   Console::WriteLine( "      Retransmitted ....................... : {0}",
      tcpstat->SegmentsResent );
   Console::WriteLine( "" );
}
public static void ShowTcpStatistics(NetworkInterfaceComponent version)
{
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    TcpStatistics tcpstat = null;
    Console.WriteLine("");
    switch (version)
    {
        case NetworkInterfaceComponent.IPv4:
             tcpstat = properties.GetTcpIPv4Statistics();
            Console.WriteLine("TCP/IPv4 Statistics:");
            break;
        case NetworkInterfaceComponent.IPv6:
            tcpstat = properties.GetTcpIPv6Statistics();
            Console.WriteLine("TCP/IPv6 Statistics:");
            break;
        default:
            throw new ArgumentException("version");
        //    break;
    }
    Console.WriteLine("  Minimum Transmission Timeout............. : {0}",
        tcpstat.MinimumTransmissionTimeout);
    Console.WriteLine("  Maximum Transmission Timeout............. : {0}",
        tcpstat.MaximumTransmissionTimeout);

    Console.WriteLine("  Connection Data:");
    Console.WriteLine("      Current  ............................ : {0}",
    tcpstat.CurrentConnections);
    Console.WriteLine("      Cumulative .......................... : {0}",
        tcpstat.CumulativeConnections);
    Console.WriteLine("      Initiated ........................... : {0}",
        tcpstat.ConnectionsInitiated);
    Console.WriteLine("      Accepted ............................ : {0}",
        tcpstat.ConnectionsAccepted);
    Console.WriteLine("      Failed Attempts ..................... : {0}",
        tcpstat.FailedConnectionAttempts);
    Console.WriteLine("      Reset ............................... : {0}",
        tcpstat.ResetConnections);

    Console.WriteLine("");
    Console.WriteLine("  Segment Data:");
    Console.WriteLine("      Received  ........................... : {0}",
        tcpstat.SegmentsReceived);
    Console.WriteLine("      Sent ................................ : {0}",
        tcpstat.SegmentsSent);
    Console.WriteLine("      Retransmitted ....................... : {0}",
        tcpstat.SegmentsResent);

    Console.WriteLine("");
}

注解

TCP 是负责可靠地发送和接收数据包的传输层协议。 它在 IETF RFC 793 中定义。

有关可用于应用程序的 TCP 流量统计信息的详细信息,请参阅 TcpStatistics 类文档。 请注意,此方法返回的对象反映了创建对象时的 TcpStatistics 统计信息。 此信息不会动态更新。

适用于