MIB_TCPSTATS_LH
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Anonymous | _Anonymous_e__Union | 4 | +0 | +0 | RTOアルゴリズム種別を保持する匿名共用体で、dwRtoAlgorithm等としてアクセスする。 |
| dwRtoMin | DWORD | 4 | +4 | +4 | RTO の最小値 (ミリ秒単位) です。 |
| dwRtoMax | DWORD | 4 | +8 | +8 | RTO の最大値 (ミリ秒単位) です。 |
| dwMaxConn | DWORD | 4 | +12 | +12 | 接続の最大数です。このメンバーが -1 の場合、接続の最大数は可変です。 |
| dwActiveOpens | DWORD | 4 | +16 | +16 | アクティブオープンの数です。アクティブオープンでは、クライアントがサーバーとの接続を開始します。 |
| dwPassiveOpens | DWORD | 4 | +20 | +20 | パッシブオープンの数です。パッシブオープンでは、サーバーがクライアントからの接続要求を待ち受けます。 |
| dwAttemptFails | DWORD | 4 | +24 | +24 | 失敗した接続試行の数です。 |
| dwEstabResets | DWORD | 4 | +28 | +28 | リセットされた確立済み接続の数です。 |
| dwCurrEstab | DWORD | 4 | +32 | +32 | 現在確立されている接続の数です。 |
| dwInSegs | DWORD | 4 | +36 | +36 | 受信したセグメントの数です。 |
| dwOutSegs | DWORD | 4 | +40 | +40 | 送信したセグメントの数です。この数には再送されたセグメントは含まれません。 |
| dwRetransSegs | DWORD | 4 | +44 | +44 | 再送したセグメントの数です。 |
| dwInErrs | DWORD | 4 | +48 | +48 | 受信したエラーの数です。 |
| dwOutRsts | DWORD | 4 | +52 | +52 | リセットフラグが設定された状態で送信されたセグメントの数です。 |
| dwNumConns | DWORD | 4 | +56 | +56 | 現在システム内に存在する接続の数です。この合計数には、リッスン中の接続を除くすべての状態の接続が含まれます。 |
共用体: _Anonymous_e__Union x64 4B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dwRtoAlgorithm | DWORD | 4 | +0 | +0 | 使用されている再送タイムアウト (RTO) アルゴリズムです。このメンバーには、次のいずれかの値を指定できます。
| ||||||||||
| RtoAlgorithm | TCP_RTO_ALGORITHM | 4 | +0 | +0 |
公式ドキュメント
MIB_TCPSTATS 構造体には、ローカルコンピューター上で実行されている TCP プロトコルの統計情報が格納されます。
解説(Remarks)
GetTcpStatistics 関数は、MIB_TCPSTATS 構造体へのポインターを返します。
MIB_TCPSTATS 構造体は、Windows Vista 以降でわずかに変更されました。Windows Vista 以降では、dwRtoAlgorithm メンバーは、次のメンバーを含む共用体に置き換えられています。
Windows SDK では、Windows Vista 以降で使用するこの構造体のバージョンが MIB_TCPSTATS_LH として定義されています。Windows SDK では、Windows 2000 以降を含むそれ以前のシステムで使用するこの構造体のバージョンが MIB_TCPSTATS_W2K として定義されています。アプリケーションのコンパイル時に、対象プラットフォームが Windows Vista 以降である場合 (NTDDI_VERSION >= NTDDI_LONGHORN、_WIN32_WINNT >= 0x0600、または WINVER >= 0x0600)、MIB_TCPSTATS_LH 構造体が MIB_TCPSTATS 構造体として typedef されます。アプリケーションのコンパイル時に、対象プラットフォームが Windows Vista 以降でない場合は、MIB_TCPSTATS_W2K 構造体が MIB_TCPSTATS 構造体として typedef されます。
Windows Vista 以降向けにリリースされた Microsoft Windows Software Development Kit (SDK) では、ヘッダーファイルの構成が変更されています。この構造体は、Iprtrmib.h ヘッダーファイルではなく Tcpmib.h ヘッダーファイルで定義されています。Tcpmib.h ヘッダーファイルは Iprtrmib.h に自動的にインクルードされ、Iprtrmib.h は Iphlpapi.h ヘッダーファイルに自動的にインクルードされます。Tcpmib.h および Iprtrmib.h ヘッダーファイルを直接使用してはなりません。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// MIB_TCPSTATS_LH (x64 60 / x86 60 バイト)
typedef struct MIB_TCPSTATS_LH {
_Anonymous_e__Union Anonymous;
DWORD dwRtoMin;
DWORD dwRtoMax;
DWORD dwMaxConn;
DWORD dwActiveOpens;
DWORD dwPassiveOpens;
DWORD dwAttemptFails;
DWORD dwEstabResets;
DWORD dwCurrEstab;
DWORD dwInSegs;
DWORD dwOutSegs;
DWORD dwRetransSegs;
DWORD dwInErrs;
DWORD dwOutRsts;
DWORD dwNumConns;
} MIB_TCPSTATS_LH;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_TCPSTATS_LH
{
public _Anonymous_e__Union Anonymous;
public uint dwRtoMin;
public uint dwRtoMax;
public uint dwMaxConn;
public uint dwActiveOpens;
public uint dwPassiveOpens;
public uint dwAttemptFails;
public uint dwEstabResets;
public uint dwCurrEstab;
public uint dwInSegs;
public uint dwOutSegs;
public uint dwRetransSegs;
public uint dwInErrs;
public uint dwOutRsts;
public uint dwNumConns;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_TCPSTATS_LH
Public Anonymous As _Anonymous_e__Union
Public dwRtoMin As UInteger
Public dwRtoMax As UInteger
Public dwMaxConn As UInteger
Public dwActiveOpens As UInteger
Public dwPassiveOpens As UInteger
Public dwAttemptFails As UInteger
Public dwEstabResets As UInteger
Public dwCurrEstab As UInteger
Public dwInSegs As UInteger
Public dwOutSegs As UInteger
Public dwRetransSegs As UInteger
Public dwInErrs As UInteger
Public dwOutRsts As UInteger
Public dwNumConns As UInteger
End Structureimport ctypes
from ctypes import wintypes
class MIB_TCPSTATS_LH(ctypes.Structure):
_fields_ = [
("Anonymous", _Anonymous_e__Union),
("dwRtoMin", wintypes.DWORD),
("dwRtoMax", wintypes.DWORD),
("dwMaxConn", wintypes.DWORD),
("dwActiveOpens", wintypes.DWORD),
("dwPassiveOpens", wintypes.DWORD),
("dwAttemptFails", wintypes.DWORD),
("dwEstabResets", wintypes.DWORD),
("dwCurrEstab", wintypes.DWORD),
("dwInSegs", wintypes.DWORD),
("dwOutSegs", wintypes.DWORD),
("dwRetransSegs", wintypes.DWORD),
("dwInErrs", wintypes.DWORD),
("dwOutRsts", wintypes.DWORD),
("dwNumConns", wintypes.DWORD),
]#[repr(C)]
pub struct MIB_TCPSTATS_LH {
pub Anonymous: _Anonymous_e__Union,
pub dwRtoMin: u32,
pub dwRtoMax: u32,
pub dwMaxConn: u32,
pub dwActiveOpens: u32,
pub dwPassiveOpens: u32,
pub dwAttemptFails: u32,
pub dwEstabResets: u32,
pub dwCurrEstab: u32,
pub dwInSegs: u32,
pub dwOutSegs: u32,
pub dwRetransSegs: u32,
pub dwInErrs: u32,
pub dwOutRsts: u32,
pub dwNumConns: u32,
}import "golang.org/x/sys/windows"
type MIB_TCPSTATS_LH struct {
Anonymous _Anonymous_e__Union
dwRtoMin uint32
dwRtoMax uint32
dwMaxConn uint32
dwActiveOpens uint32
dwPassiveOpens uint32
dwAttemptFails uint32
dwEstabResets uint32
dwCurrEstab uint32
dwInSegs uint32
dwOutSegs uint32
dwRetransSegs uint32
dwInErrs uint32
dwOutRsts uint32
dwNumConns uint32
}type
MIB_TCPSTATS_LH = record
Anonymous: _Anonymous_e__Union;
dwRtoMin: DWORD;
dwRtoMax: DWORD;
dwMaxConn: DWORD;
dwActiveOpens: DWORD;
dwPassiveOpens: DWORD;
dwAttemptFails: DWORD;
dwEstabResets: DWORD;
dwCurrEstab: DWORD;
dwInSegs: DWORD;
dwOutSegs: DWORD;
dwRetransSegs: DWORD;
dwInErrs: DWORD;
dwOutRsts: DWORD;
dwNumConns: DWORD;
end;const MIB_TCPSTATS_LH = extern struct {
Anonymous: _Anonymous_e__Union,
dwRtoMin: u32,
dwRtoMax: u32,
dwMaxConn: u32,
dwActiveOpens: u32,
dwPassiveOpens: u32,
dwAttemptFails: u32,
dwEstabResets: u32,
dwCurrEstab: u32,
dwInSegs: u32,
dwOutSegs: u32,
dwRetransSegs: u32,
dwInErrs: u32,
dwOutRsts: u32,
dwNumConns: u32,
};type
MIB_TCPSTATS_LH {.bycopy.} = object
Anonymous: _Anonymous_e__Union
dwRtoMin: uint32
dwRtoMax: uint32
dwMaxConn: uint32
dwActiveOpens: uint32
dwPassiveOpens: uint32
dwAttemptFails: uint32
dwEstabResets: uint32
dwCurrEstab: uint32
dwInSegs: uint32
dwOutSegs: uint32
dwRetransSegs: uint32
dwInErrs: uint32
dwOutRsts: uint32
dwNumConns: uint32struct MIB_TCPSTATS_LH
{
_Anonymous_e__Union Anonymous;
uint dwRtoMin;
uint dwRtoMax;
uint dwMaxConn;
uint dwActiveOpens;
uint dwPassiveOpens;
uint dwAttemptFails;
uint dwEstabResets;
uint dwCurrEstab;
uint dwInSegs;
uint dwOutSegs;
uint dwRetransSegs;
uint dwInErrs;
uint dwOutRsts;
uint dwNumConns;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIB_TCPSTATS_LH サイズ: 60 バイト(x64)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; Anonymous : _Anonymous_e__Union (+0, 4byte) varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; dwRtoMin : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dwRtoMax : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwMaxConn : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; dwActiveOpens : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; dwPassiveOpens : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwAttemptFails : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; dwEstabResets : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwCurrEstab : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; dwInSegs : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dwOutSegs : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; dwRetransSegs : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; dwInErrs : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; dwOutRsts : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; dwNumConns : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MIB_TCPSTATS_LH
#field byte Anonymous 4
#field int dwRtoMin
#field int dwRtoMax
#field int dwMaxConn
#field int dwActiveOpens
#field int dwPassiveOpens
#field int dwAttemptFails
#field int dwEstabResets
#field int dwCurrEstab
#field int dwInSegs
#field int dwOutSegs
#field int dwRetransSegs
#field int dwInErrs
#field int dwOutRsts
#field int dwNumConns
#endstruct
stdim st, MIB_TCPSTATS_LH ; NSTRUCT 変数を確保
st->dwRtoMin = 100
mes "dwRtoMin=" + st->dwRtoMin
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。