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.
29 using System.Collections.Specialized;
30 using System.Globalization;
32 namespace System.Net.NetworkInformation {
33 class MibTcpStatistics : TcpStatistics
37 public MibTcpStatistics (StringDictionary dic)
42 long Get (string name)
44 return dic [name] != null ? long.Parse (dic [name], NumberFormatInfo.InvariantInfo) : 0;
47 public override long ConnectionsAccepted {
48 get { return Get ("PassiveOpens"); }
50 public override long ConnectionsInitiated {
51 get { return Get ("ActiveOpens"); }
53 public override long CumulativeConnections {
54 get { return Get ("NumConns"); }
56 public override long CurrentConnections {
57 get { return Get ("CurrEstab"); }
59 public override long ErrorsReceived {
60 get { return Get ("InErrs"); }
62 public override long FailedConnectionAttempts {
63 get { return Get ("AttemptFails"); }
65 public override long MaximumConnections {
66 get { return Get ("MaxConn"); }
68 public override long MaximumTransmissionTimeout {
69 get { return Get ("RtoMax"); }
71 public override long MinimumTransmissionTimeout {
72 get { return Get ("RtoMin"); }
74 public override long ResetConnections {
75 get { return Get ("EstabResets"); }
77 public override long ResetsSent {
78 get { return Get ("OutRsts"); }
80 public override long SegmentsReceived {
81 get { return Get ("InSegs"); }
83 public override long SegmentsResent {
84 get { return Get ("RetransSegs"); }
86 public override long SegmentsSent {
87 get { return Get ("OutSegs"); }
92 class Win32TcpStatistics : TcpStatistics
94 Win32_MIB_TCPSTATS info;
96 public Win32TcpStatistics (Win32_MIB_TCPSTATS info)
101 public override long ConnectionsAccepted {
102 get { return info.PassiveOpens; }
105 public override long ConnectionsInitiated {
106 get { return info.ActiveOpens; }
109 public override long CumulativeConnections {
110 get { return info.NumConns; }
113 public override long CurrentConnections {
114 get { return info.CurrEstab; }
117 public override long ErrorsReceived {
118 get { return info.InErrs; }
121 public override long FailedConnectionAttempts {
122 get { return info.AttemptFails; }
125 public override long MaximumConnections {
126 get { return info.MaxConn; }
129 public override long MaximumTransmissionTimeout {
130 get { return info.RtoMax; }
133 public override long MinimumTransmissionTimeout {
134 get { return info.RtoMin; }
137 public override long ResetConnections {
138 get { return info.EstabResets; }
141 public override long ResetsSent {
142 get { return info.OutRsts; }
145 public override long SegmentsReceived {
146 get { return info.InSegs; }
149 public override long SegmentsResent {
150 get { return info.RetransSegs; }
153 public override long SegmentsSent {
154 get { return info.OutSegs; }
158 struct Win32_MIB_TCPSTATS
160 public uint RtoAlgorithm;
164 public uint ActiveOpens;
165 public uint PassiveOpens;
166 public uint AttemptFails;
167 public uint EstabResets;
168 public uint CurrEstab;
171 public uint RetransSegs;
174 public uint NumConns;