Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved the problem. To get TCP statistics for IPV4, I used this code :</p> <pre><code>#include "stdafx.h" #include &lt;winsock2.h&gt; #include &lt;ws2tcpip.h&gt; #include &lt;iphlpapi.h&gt; #include &lt;stdio.h&gt; #pragma comment(lib, "iphlpapi.lib") #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) /* Note: could also use malloc() and free() */ int main() { PMIB_TCPSTATS pTCPStats; DWORD dwRetVal = 0; pTCPStats = (MIB_TCPSTATS*) MALLOC (sizeof(MIB_TCPSTATS)); if (pTCPStats == NULL) { printf("Error allocating memory\n"); return 1; } if ((dwRetVal = GetTcpStatisticsEx(pTCPStats,AF_INET)) == NO_ERROR) { printf("\tActive Opens: %ld\n", pTCPStats-&gt;dwActiveOpens); printf("\tPassive Opens: %ld\n", pTCPStats-&gt;dwPassiveOpens); printf("\tSegments Recv: %ld\n", pTCPStats-&gt;dwInSegs); printf("\tSegments Xmit: %ld\n", pTCPStats-&gt;dwOutSegs); printf("\tTotal # Conxs: %ld\n", pTCPStats-&gt;dwAttemptFails); printf("\tAttemp failed: %ld\n", pTCPStats-&gt;dwAttemptFails); printf("\tcurr estab: %ld\n", pTCPStats-&gt;dwCurrEstab); printf("\testab reset: %ld\n", pTCPStats-&gt;dwEstabResets); printf("\tIn err: %ld\n", pTCPStats-&gt;dwInErrs); printf("\tmax conn: %ld\n", pTCPStats-&gt;dwMaxConn); printf("\tNum conn: %ld\n", pTCPStats-&gt;dwNumConns); printf("\tout rst: %ld\n", pTCPStats-&gt;dwOutRsts); printf("\tretrans seg: %ld\n", pTCPStats-&gt;dwRetransSegs); printf("\tRtoAlgorithm: %ld\n", pTCPStats-&gt;dwRtoAlgorithm); printf("\RtoMax: %ld\n", pTCPStats-&gt;dwRtoMax); printf("\RtoMin: %ld\n", pTCPStats-&gt;dwRtoMin); printf("\RtoAlgorithm: %ld\n", pTCPStats-&gt;RtoAlgorithm); } else { printf("GetTcpStatistics failed with error: %ld\n", dwRetVal); LPVOID lpMsgBuf; if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &amp;lpMsgBuf, 0, NULL )) { printf("\tError: %s", lpMsgBuf); } LocalFree( lpMsgBuf ); } if (pTCPStats) FREE (pTCPStats); system("pause"); } </code></pre> <p>and to get statistics for IPv6, I just replace <code>AF_INET</code> by <code>AF_INET6</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload