NetStatisticsGet() API behavior not consistent across all Windows 7 machines
Hi, I have written a test application to query the network statistics for the workstation during a network file copy(write) operation. While I am executing the test application , let us say a PST file of around 500MB is being copied from the workstation to a network share(on a different machine) Below is the pseudo code to query the network information while the above said operation is in progress: Query the perfLib performance counters to retrieve the following values(through the registry) RegKey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009NIC statistics: Network Interface Bytes Received/sec Network Interface Bytes Sent/sec Network Interface Bytes Total/secRedirector statistics: Redirector Bytes Received/sec Redirector Bytes Transmitted/sec Redirector File Read Operations/sec Redirector File Write Operations/sec 2. Use the NetStatisticsGet() API to query the following values struct _STAT_WORKSTATION_0 * pStat = NULL NetStatisticsGet(NULL, L"LanmanWorkstation", 0, 0, (LPBYTE *) &pStat); The return value is NERR_SUCCESS and the pStat shows the correct updated value for the BytesTransmittedWriteOperations The above information is required for further processing . Issue: The test application works fine on Windows XP machine. However when the test application is run on Windows 7 machine, the behavior is inconsistent. The test application fails on most of the windows 7 machine with the following behavior: The query to retrieve the information from the Perf Lib counters consistently reports the following parameters as 0 Redirector Bytes Transmitted/sec Redirector File Write Operations/sec This is despite the data being written over the network and the operation is successful. Also the NetStatisticsGet() method reports the following erroneous values: struct _STAT_WORKSTATION_0 { LARGE_INTEGER bytesTransmitted // is constant 256 Kb LARGE_INTEGER CacheWriteBytesRequested //is updated for every write operation that happens DWORD WriteOperations //updated on every write } The test application works on few of the windows 7 machines and the behavior is as follows: The query to retrieve the information from the Perf Lib counters reports the following parameters as per the write operations and its up to date Redirector Bytes Transmitted/sec Redirector File Write Operations/sec For the NetStatisticsGet() API struct _STAT_WORKSTATION_0 { LARGE_INTEGER bytesTransmitted // is updated every time the write happens LARGE_INTEGER CacheWriteBytesRequested //almost constant for a file DWORD WriteOperations //is updated as the writes are completed } As per my observations while debugging : Looks like caching happens during the network file write that causes the CacheWriteBytesRequested data field to be updated, instead of the bytesTransmitted on most of the windows 7 machine Possibly there may be a configuration issue that is causing the above calls to report data differently across the windows 7 machine. Would greatly appreciate if we could get more details on the following: Why the behavior differs across windows XP and windows 7Why the behavior is not consistent across all windows 7 machine. Thanks, Seema
March 14th, 2013 2:13pm

I think you should contact MSDN forum. http://msdn.microsoft.com/en-US/aa937802.aspx
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2013 9:17am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics