Export (0) Print
Expand All

IPGlobalStatistics Class

Note: This class is new in the .NET Framework version 2.0.

Provides Internet Protocol (IP) statistical data.

Namespace: System.Net.NetworkInformation
Assembly: System (in system.dll)

public abstract class IPGlobalStatistics
public abstract class IPGlobalStatistics
public abstract class IPGlobalStatistics

This class is used by the GetIPv4GlobalStatistics and GetIPv6GlobalStatistics methods to return IP traffic information.

The Internet protocol is used to move IP packets from a source computer to a destination computer. IP also handles dividing a packet that is too large into multiple packets that are small enough for transport, in a process known as fragmentation.

The properties in this class correlate to the Management Information Base objects for IP defined in IETF RFC 2011.

The following code code example displays IP statistics.

public static void ShowIPStatistics(NetworkInterfaceComponent version)
{
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    IPGlobalStatistics ipstat = null;
    switch (version)
    {
        case NetworkInterfaceComponent.IPv4:
             ipstat = properties.GetIPv4GlobalStatistics();
           Console.WriteLine("{0}IPv4 Statistics ",Environment.NewLine);
            break;
        case NetworkInterfaceComponent.IPv6:
            ipstat = properties.GetIPv4GlobalStatistics();
            Console.WriteLine("{0}IPv6 Statistics ",Environment.NewLine);
            break;
        default:
            throw new ArgumentException("version");
            break;
    }
    Console.WriteLine("  Forwarding enabled ...................... : {0}", 
        ipstat.ForwardingEnabled);
    Console.WriteLine("  Interfaces .............................. : {0}", 
        ipstat.NumberOfInterfaces);
    Console.WriteLine("  IP addresses ............................ : {0}", 
        ipstat.NumberOfIPAddresses);
    Console.WriteLine("  Routes .................................. : {0}", 
        ipstat.NumberOfRoutes);
    Console.WriteLine("  Default TTL ............................. : {0}", 
        ipstat.DefaultTtl);
    Console.WriteLine("");    
    Console.WriteLine("  Inbound Packet Data:");
    Console.WriteLine("      Received ............................ : {0}", 
        ipstat.ReceivedPackets);
    Console.WriteLine("      Forwarded ........................... : {0}", 
        ipstat.ReceivedPacketsForwarded);
    Console.WriteLine("      Delivered ........................... : {0}", 
        ipstat.ReceivedPacketsDelivered);
    Console.WriteLine("      Discarded ........................... : {0}", 
        ipstat.ReceivedPacketsDiscarded);
    Console.WriteLine("      Header Errors ....................... : {0}", 
        ipstat.ReceivedPacketsWithHeadersErrors);
    Console.WriteLine("      Address Errors ...................... : {0}", 
        ipstat.ReceivedPacketsWithAddressErrors);
    Console.WriteLine("      Unknown Protocol Errors ............. : {0}", 
        ipstat.ReceivedPacketsWithUnknownProtocol);
    Console.WriteLine("");    
    Console.WriteLine("  Outbound Packet Data:");
    Console.WriteLine("      Requested ........................... : {0}", 
         ipstat.OutputPacketRequests);
    Console.WriteLine("      Discarded ........................... : {0}", 
        ipstat.OutputPacketsDiscarded);
    Console.WriteLine("      No Routing Discards ................. : {0}", 
        ipstat.OutputPacketsWithNoRoute);
    Console.WriteLine("      Routing Entry Discards .............. : {0}", 
        ipstat.OutputPacketRoutingDiscards);
    Console.WriteLine("");    
    Console.WriteLine("  Reassembly Data:");
    Console.WriteLine("      Reassembly Timeout .................. : {0}", 
        ipstat.PacketReassemblyTimeout);
    Console.WriteLine("      Reassemblies Required ............... : {0}", 
        ipstat.PacketReassembliesRequired);
    Console.WriteLine("      Packets Reassembled ................. : {0}", 
        ipstat.PacketsReassembled);
    Console.WriteLine("      Packets Fragmented .................. : {0}", 
        ipstat.PacketsFragmented);
    Console.WriteLine("      Fragment Failures ................... : {0}", 
        ipstat.PacketFragmentFailures);
    Console.WriteLine("");
}

System.Object
  System.Net.NetworkInformation.IPGlobalStatistics

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft