Skip to content

Measure Data Sent and Received

Peter Foot edited this page May 22, 2024 · 3 revisions

The InTheHand.Net.NetworkInformation namespace has functionality to access network statistics on a per-adapter basis. e.g.

using InTheHand.Net.NetworkInformation;
NetworkInterface[] interfaces = NetworkInterface.GetAllInterfaces();     
//check the name properties to determine which interface to use
IPv4InterfaceStatistics stats = chosenInterface.GetIPv4Statistics();     
int sent = stats.BytesSent;     
int received = stats.BytesReceived;     
//etc