2 // System.Net.NetworkInformation.TcpStatistics
5 // Gonzalo Paniagua Javier (gonzalo@novell.com)
6 // Atsushi Enomoto (atsushi@ximian.com)
8 // Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System
.Collections
.Specialized
;
31 using System
.Globalization
;
33 namespace System
.Net
.NetworkInformation
{
34 public abstract class TcpStatistics
{
35 protected TcpStatistics ()
39 public abstract long ConnectionsAccepted { get; }
40 public abstract long ConnectionsInitiated { get; }
41 public abstract long CumulativeConnections { get; }
42 public abstract long CurrentConnections { get; }
43 public abstract long ErrorsReceived { get; }
44 public abstract long FailedConnectionAttempts { get; }
45 public abstract long MaximumConnections { get; }
46 public abstract long MaximumTransmissionTimeout { get; }
47 public abstract long MinimumTransmissionTimeout { get; }
48 public abstract long ResetConnections { get; }
49 public abstract long ResetsSent { get; }
50 public abstract long SegmentsReceived { get; }
51 public abstract long SegmentsResent { get; }
52 public abstract long SegmentsSent { get; }
55 class MibTcpStatistics
: TcpStatistics
59 public MibTcpStatistics (StringDictionary dic
)
64 long Get (string name
)
66 return dic
[name
] != null ? long.Parse (dic
[name
], NumberFormatInfo
.InvariantInfo
) : 0;
69 public override long ConnectionsAccepted
{
70 get { return Get ("PassiveOpens"); }
72 public override long ConnectionsInitiated
{
73 get { return Get ("ActiveOpens"); }
75 public override long CumulativeConnections
{
76 get { return Get ("NumConns"); }
78 public override long CurrentConnections
{
79 get { return Get ("CurrEstab"); }
81 public override long ErrorsReceived
{
82 get { return Get ("InErrs"); }
84 public override long FailedConnectionAttempts
{
85 get { return Get ("AttemptFails"); }
87 public override long MaximumConnections
{
88 get { return Get ("MaxConn"); }
90 public override long MaximumTransmissionTimeout
{
91 get { return Get ("RtoMax"); }
93 public override long MinimumTransmissionTimeout
{
94 get { return Get ("RtoMin"); }
96 public override long ResetConnections
{
97 get { return Get ("EstabResets"); }
99 public override long ResetsSent
{
100 get { return Get ("OutRsts"); }
102 public override long SegmentsReceived
{
103 get { return Get ("InSegs"); }
105 public override long SegmentsResent
{
106 get { return Get ("RetransSegs"); }
108 public override long SegmentsSent
{
109 get { return Get ("OutSegs"); }
113 class Win32TcpStatistics
: TcpStatistics
115 Win32_MIB_TCPSTATS info
;
117 public Win32TcpStatistics (Win32_MIB_TCPSTATS info
)
122 public override long ConnectionsAccepted
{
123 get { return info.PassiveOpens; }
126 public override long ConnectionsInitiated
{
127 get { return info.ActiveOpens; }
130 public override long CumulativeConnections
{
131 get { return info.NumConns; }
134 public override long CurrentConnections
{
135 get { return info.CurrEstab; }
138 public override long ErrorsReceived
{
139 get { return info.InErrs; }
142 public override long FailedConnectionAttempts
{
143 get { return info.AttemptFails; }
146 public override long MaximumConnections
{
147 get { return info.MaxConn; }
150 public override long MaximumTransmissionTimeout
{
151 get { return info.RtoMax; }
154 public override long MinimumTransmissionTimeout
{
155 get { return info.RtoMin; }
158 public override long ResetConnections
{
159 get { return info.EstabResets; }
162 public override long ResetsSent
{
163 get { return info.OutRsts; }
166 public override long SegmentsReceived
{
167 get { return info.InSegs; }
170 public override long SegmentsResent
{
171 get { return info.RetransSegs; }
174 public override long SegmentsSent
{
175 get { return info.OutSegs; }
179 struct Win32_MIB_TCPSTATS
181 public uint RtoAlgorithm
;
185 public uint ActiveOpens
;
186 public uint PassiveOpens
;
187 public uint AttemptFails
;
188 public uint EstabResets
;
189 public uint CurrEstab
;
192 public uint RetransSegs
;
195 public uint NumConns
;