Networking Performance Counters
The Performance console .NET CLR Networking category includes counters that provide information about data that an application sends and receives over the network. The following table describes these performance counters.
Performance counter |
Description |
---|---|
Bytes Received |
The cumulative total number of bytes received by all Socket objects within the AppDomain since the process started. This number includes data and any protocol information that is not defined by TCP/IP. |
Bytes Sent |
The cumulative number of bytes sent by all Socket objects within the AppDomain since the process started. This number includes data and any protocol information that is not defined by TCP/IP. |
Connections Established |
The cumulative total number of Socket objects for stream sockets that were ever connected within the AppDomain since the process started. |
Datagrams Received |
The cumulative total number of datagram packets received by all Socket objects within the AppDomain since the process started. |
Datagrams Sent |
The cumulative total number of datagram packets sent by all Socket objects within the AppDomain since the process started. |
HttpWebRequest Average Lifetime |
The average time to completion for all HttpWebRequest objects that ended in the last interval within the AppDomain since the process started. |
HttpWebRequest Average Queue Time |
The average time-on-queue for all HttpWebRequest objects that left the queue in the last interval within the AppDomain since the process started. |
HttpWebRequests Created/sec |
The number of HttpWebRequest objects created per second within the AppDomain. |
HttpWebRequests Queued/sec |
The number of HttpWebRequest objects that were added to the queue per second within the AppDomain. |
HttpWebRequests Aborted/sec |
The number of HttpWebRequest objects where the application called the Abort method per second within the AppDomain. |
HttpWebRequests Failed/sec |
The number of HttpWebRequest objects that received a failed status code from the server per second within the AppDomain. |
Remarks
There are several classes of networking performance counters supported:
Event counters that measure the number of times some event occurred.
Data counters that measure the quantity of data sent or received.
Duration counters that measure how long different processes take. The times are measured on the objects each interval (usually in seconds) after they come out of different states.
Per-Interval counters that measure the number of objects that are making a particular transition per interval (normally per second).
The networking performance counters for events include the following:
Connections Established
Datagrams Received
Datagrams Sent
These performance counters provide counts since the process started. The counts of Socket connections established includes explicit Socket method calls by an application for a stream socket connection that was established as well as internal calls made by other classes (HttpWebRequest, FtpWebRequest, WebClient, and TcpClient, for example) to Socket class
The counts for Datagrams Received and Datagrams Sent includes datagram packets sent or received using explicit Socket method calls by an application as well internal calls made by other classes (UdpClient, for example) to Socket. class. The counts Datagrams Received and Datagrams Sent may also be used to provide a very crude measure of how many bytes were sent or received using datagrams by assuming an average size for a datagram.
The networking performance counters for data include the following:
Bytes Received
Bytes Sent
The above counters provide counts of bytes since the process started.
There are two duration counters that measure how long it took for HttpWebRequest objects to pass through either their entire life cycle or just part of it:
HttpWebRequest Average Lifetime
HttpWebRequest Average Queue Time
For the HttpWebRequest Average Lifetime counter, the lifetime of most HttpWebRequest objects always starts with the time that the object is created up until the time that the response stream is closed by the application. There are two uncommon cases:
If the application never calls the GetResponse or BeginGetResponse methods, then the lifetime of the HttpWebRequest object is ignored.
If the HttpWebRequest object throws a WebException when calling the GetResponse or EndGetResponse methods, the lifetime ends when the exception is thrown. Technically, the underlying response stream is also closed at that point (the response stream returned to the user is really a memory stream containing a copy of the response stream).
There are four counters that track certain HttpWebRequest object issues per interval. These performance counters can help application developers, administrators, and support staff better understand what the HttpWebRequest objects are doing. The counters include the following:
HttpWebRequests Created/sec
HttpWebRequests Queued/sec
HttpWebRequests Aborted/sec
HttpWebRequests Failed/sec
For the HttpWebRequests Aborted/sec counter, internal calls to Abort are also counted. These internal calls are usually caused by timeouts that an application may want to measure.
The HttpWebRequests Failed/sec counter contains the number of HttpWebRequest objects that received a failed status code from the server per second. This means that the status code received from the Http server at the end of the request was not in the range between 200 to 299. Status codes that are handled and result in a new request (many of the 401 Unauthorized status codes, for example) will fail or not fail based on the result of the retry. If the application would see an error based on the retry, then this counter is incremented.
Networking performance counters can be accessed and managed using the PerformanceCounter and related classes in the System.Diagnostics namespace. Networking performance counters can also be viewed with the Windows Performance Monitor console.
Networking performance counters need to be enabled in the configuration file to be used. All networking performance counters are enabled or disabled with a single setting in the configuration file. Individual networking performance counters cannot be enabled or disabled. For more information, see <performanceCounter> Element (Network Settings).
If networking counters are enabled, this will create and update both per-AppDomain and global performance counters. If disabled, the application will not provide any networking performance counter data.
Performance counters are grouped into Categories. An application can list all of the categories with the following example code:
PerformanceCounterCategory[] Array = PerformanceCounterCategory.GetCategories();
for (int i = 0; i < Array.Length; i++)
{
Console.Out.WriteLine("{0}. Name={1} Help={2}", i, Array[i].CategoryName, Array[i].CategoryHelp);
}
The networking performance counters are listed in two categories:
".NET CLR Networking" - the original performance counters introduced on .NET Framework Version 2 and supported on .NET Framework Version 2 and later.
".NET CLR Networking 4.0.0.0" - All of the above socket counters plus the new performance counters supported on .NET Framework Version 4 and later. These new counters provide performance information on HttpWebRequest objects.
For more information on accessing and managing performance counters in an application, see Performance Counters in the .NET Framework.
See Also
Reference
<performanceCounter> Element (Network Settings)