1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System.Net.Sockets;
6 
7 namespace System.Net.NetworkInformation
8 {
9     // TCP specific statistics.
10     internal class SystemTcpStatistics : TcpStatistics
11     {
12         private readonly Interop.IpHlpApi.MibTcpStats _stats;
13 
SystemTcpStatistics()14         private SystemTcpStatistics() { }
15 
SystemTcpStatistics(AddressFamily family)16         internal SystemTcpStatistics(AddressFamily family)
17         {
18             uint result = Interop.IpHlpApi.GetTcpStatisticsEx(out _stats, family);
19 
20             if (result != Interop.IpHlpApi.ERROR_SUCCESS)
21             {
22                 throw new NetworkInformationException((int)result);
23             }
24         }
25 
26         public override long MinimumTransmissionTimeout { get { return _stats.minimumRetransmissionTimeOut; } }
27 
28         public override long MaximumTransmissionTimeout { get { return _stats.maximumRetransmissionTimeOut; } }
29 
30         public override long MaximumConnections { get { return _stats.maximumConnections; } }
31 
32         public override long ConnectionsInitiated { get { return _stats.activeOpens; } }
33 
34         public override long ConnectionsAccepted { get { return _stats.passiveOpens; } }//  is this true?  We should check
35 
36         public override long FailedConnectionAttempts { get { return _stats.failedConnectionAttempts; } }
37 
38         public override long ResetConnections { get { return _stats.resetConnections; } }
39 
40         public override long CurrentConnections { get { return _stats.currentConnections; } }
41 
42         public override long SegmentsReceived { get { return _stats.segmentsReceived; } }
43 
44         public override long SegmentsSent { get { return _stats.segmentsSent; } }
45 
46         public override long SegmentsResent { get { return _stats.segmentsResent; } }
47 
48         public override long ErrorsReceived { get { return _stats.errorsReceived; } }
49 
50         public override long ResetsSent { get { return _stats.segmentsSentWithReset; } }
51 
52         public override long CumulativeConnections { get { return _stats.cumulativeConnections; } }
53     }
54 }
55