Article View: be.comp.programming
Article #15138VC++/Win32 API : Network Load
From: Armin Gerritsen
Date: Wed, 15 Nov 2000 00:00
Date: Wed, 15 Nov 2000 00:00
42 lines
2153 bytes
2153 bytes
Hallo,
Weet iemand een goede method eom de totale network load van een systeem te
meten?
Voor de duidelijkheid, ik beodle daarmee de totale bits/sec die door een NIC
gaat. het targetplatform is NT.
Ik gebruik Visuals C++ als tool, maar preferer Win32 API calls.
Ik heb al een oplossing, maar deze is nogal traag. Iemand een beter of enige
hints?
De oplossing die ik al heb met errorcheck & Co even weggelaten om de posting
niet te lang te maken):
hStatus = PdhOpenQuery( NULL, dwUserData, &hQuery ) ;
hStatus = PdhAddCounter( hQuery, "\\Network Interface(2)\\Bytes Sent/sec",
dwUserData, &hCounterSent ) ;
hStatus = PdhAddCounter( hQuery, "\\Network Interface(2)\\Bytes
Received/sec", dwUserData, &hCounterReceived ) ;
hStatus = PdhCollectQueryData( hQuery ) ;
hStatus = PdhGetFormattedCounterValue( hCounterSent, PDH_FMT_LONG, NULL,
&fmtValueSent ) ;
hStatus = PdhGetFormattedCounterValue( hCounterReceived, PDH_FMT_LONG, NULL,
&fmtValueReceived ) ;
hStatus = PdhCloseQuery( hQuery ) ;
en dan bijvoorbeeld:
printf("Sent = %d bytes/sec\n", fmtValueSent.longValue ) ;
printf("Received = %d bytes/sec\n", fmtValueReceived.longValue ) ;
M.v.g.,
Armin
--
Philips Semiconductors B.V.
Systems Laboratory Eindhoven (PS-SLE)
Backup not found: (A)bort (R)etry (P)anic
Tools:
http://www.phys.uu.nl/~gerritsn/download.html
Technical Details
Message-ID:
<8utta2$5po$1@porthos.nl.uu.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 107324,88c42dc32b652b67,start X-Google-Attributes: gid107324,public X-Google-Thread: fcea4,88c42dc32b652b67,start X-Google-Attributes: gidfcea4,public From: "Armin Gerritsen" <Armin.Gerritsen@philips.com> Subject: VC++/Win32 API : Network Load Date: 2000/11/15 Message-ID: <8utta2$5po$1@porthos.nl.uu.net> X-Deja-AN: 693861949 Distribution: global X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 X-Complaints-To: abuse@nl.uu.net X-Trace: porthos.nl.uu.net 974289026 5944 212.153.190.3 (15 Nov 2000 11:50:26 GMT) Organization: Philips Semiconductors Keywords: performance, netwerk, throughput, Win32 API NNTP-Posting-Date: 15 Nov 2000 11:50:26 GMT Newsgroups: be.comp.programming,nl.comp.programmeren