Detecting network connection speed and bandwidth usage in C#
Asked Answered
C

3

46

Is there a way to detect the network speed and bandwidth usage in C#? Even pointers to open-source components are welcome.

Catalase answered 19/2, 2009 at 16:37 Comment(0)
P
34

Try using the System.Net.NetworkInformation classes. In particular, System.Net.NetworkInformation.IPv4InterfaceStatistics ought to have some information along the lines of what you're looking for.

Specifically, you can check the bytesReceived property, wait a given interval, and then check the bytesReceived property again to get an idea of how many bytes/second your connection is processing. To get a good number, though, you should try to download a large block of information from a given source, and check then; that way you should be 'maxing' the connection when you do the test, which should give more helpful numbers.

Poetize answered 19/2, 2009 at 16:54 Comment(0)
A
9

You should be able to calculate everything you need from the IPGlobalStatistics class.

Assay answered 19/2, 2009 at 16:57 Comment(0)
B
2

If you only care about the negotiated speed, you can look at the NetworkInterface.Speed property

MSDN NetworkInterface.Speed

Bouley answered 19/7, 2021 at 16:13 Comment(1)
Not the accurate oneVanya

© 2022 - 2024 — McMap. All rights reserved.