Boost Your .NET Projects with Spargine: Supercharge Your .NET Apps with NetworkHelper

Spargine is a collection of open-source assemblies and NuGet packages designed for .NET 10, which I have been developing and maintaining since the release of .NET Framework 2. These assemblies are not only a core part of my projects but are also actively deployed in production environments across several companies I collaborate with.

Get Spargine

You can access the source code and NuGet packages here:

Retrieving information about the network a computer is running on is critical for modern applications. It impacts diagnostics, logging, telemetry, performance tuning, and even feature enablement or disablement when an internet connection is unavailable.

That’s exactly why I created the NetworkHelper type in the DotNetTips.Spargine.Core assembly and NuGet package. I wanted a single, reliable, and easy-to-use utility that centralizes the most common network-related operations developers need—without rewriting the same boilerplate code in every project.

NetworkHelper provides a clean, strongly-typed, and high-performance API for querying network state, connections, bandwidth, addressing, and interface capabilities. It turns what is usually messy, repetitive, and error-prone code into a simple and consistent developer experience.

Methods

  • GetDnsServerAddresses()
    Gets the DNS server addresses configured for the active network interfaces.
  • GetGatewayAddresses()
    Gets the gateway addresses configured for the active network interfaces.
  • GetHostName()
    Gets the hostname of the local computer.
  • GetLocalIPAddresses(AddressFamily? addressFamily)
    Gets the local IP addresses for the computer.
  • GetMacAddresses()
    Gets the MAC (physical) addresses of the active network interface.
  • GetNetworkConnections()
    Checks the network connections and returns a collection of active network interfaces.
  • GetNetworkConnectionsReport(bool includeIPProperties)
    Builds a detailed, human-readable report of active network connections.
  • GetNetworkSpeeds()
    Gets the network speed (bandwidth) of active network interfaces in bits per second.
  • GetNetworkStatistics(NetworkInterfaceType? interfaceType)
    Gets network statistics for the specified network interface type.
  • GetPrimaryNetworkInterface()
    Gets detailed information about the primary network interface.
  • IsConnectedToBluetooth()
    Checks if the computer is connected to a Bluetooth network.
  • IsConnectedToEthernet()
    Checks if the computer is connected to an Ethernet network.
  • IsConnectedToNetwork()
    Checks if the computer is connected to any network.
  • IsConnectedToWiFi()
    Checks if the computer is connected to a Wi-Fi network.
  • IsIPv6Supported()
    Checks if the specified network interface supports IPv6.

Examples

Here are examples of real-world data returned by NetworkHelper.

GetNetWorkSpeeds()

[0]: ("Wi-Fi", 325000000)
[1]: ("Loopback Pseudo-Interface 1", 1073741824)
[2]: ("Wi-Fi-WFP Native MAC Layer LightWeight Filter-0000", 325000000)
[3]: ("Wi-Fi-Virtual WiFi Filter Driver-0000", 325000000)
[4]: ("Wi-Fi-Native WiFi Filter Driver-0000", 325000000)
[5]: ("Wi-Fi-QoS Packet Scheduler-0000", 325000000)
[6]: ("Wi-Fi-WFP 802.3 MAC Layer LightWeight Filter-0000", 325000000)

This shows not only the active Wi-Fi interface but also the underlying drivers and filters that participate in the network stack, along with their respective bandwidth capabilities.

GetNetworkStatistics

[0]: ("Wi-Fi", {System.Net.NetworkInformation.SystemIPv4InterfaceStatistics})
[1]: ("Loopback Pseudo-Interface 1", {System.Net.NetworkInformation.SystemIPv4InterfaceStatistics})

This provides access to rich IPv4 statistics such as bytes sent/received, packets, errors, and dropped packets—perfect for diagnostics, monitoring, and telemetry scenarios.

GetNetworkConnectionsReport()

Name: Wi-Fi
========================================
  Description: Intel(R) Dual Band Wireless-AC 3165
  Type: Wireless80211
  Status: Up
  Speed: 260000000
  Receive only: False
  Physical Address: C4BDE5750599

IP Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

IPv4 Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

Name: Wi-Fi-WFP Native MAC Layer LightWeight Filter-0000
========================================
  Description: Intel(R) Dual Band Wireless-AC 3165-WFP Native MAC Layer LightWeight Filter-0000
  Type: Wireless80211
  Status: Up
  Speed: 260000000
  Receive only: False
  Physical Address: C4BDE5750599

IP Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

IPv4 Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

Name: Wi-Fi-Virtual WiFi Filter Driver-0000
========================================
  Description: Intel(R) Dual Band Wireless-AC 3165-Virtual WiFi Filter Driver-0000
  Type: Wireless80211
  Status: Up
  Speed: 260000000
  Receive only: False
  Physical Address: C4BDE5750599

IP Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

IPv4 Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

Name: Wi-Fi-Native WiFi Filter Driver-0000
========================================
  Description: Intel(R) Dual Band Wireless-AC 3165-Native WiFi Filter Driver-0000
  Type: Wireless80211
  Status: Up
  Speed: 260000000
  Receive only: False
  Physical Address: C4BDE5750599

IP Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

IPv4 Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

Name: Wi-Fi-QoS Packet Scheduler-0000
========================================
  Description: Intel(R) Dual Band Wireless-AC 3165-QoS Packet Scheduler-0000
  Type: Wireless80211
  Status: Up
  Speed: 260000000
  Receive only: False
  Physical Address: C4BDE5750599

IP Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

IPv4 Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

Name: Wi-Fi-WFP 802.3 MAC Layer LightWeight Filter-0000
========================================
  Description: Intel(R) Dual Band Wireless-AC 3165-WFP 802.3 MAC Layer LightWeight Filter-0000
  Type: Wireless80211
  Status: Up
  Speed: 260000000
  Receive only: False
  Physical Address: C4BDE5750599

IP Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

IPv4 Statistics:
  OutputQueueLength: 0
  BytesSent: 528060907
  BytesReceived: 6824809887
  UnicastPacketsSent: 1248922
  UnicastPacketsReceived: 2008827
  NonUnicastPacketsSent: 653
  NonUnicastPacketsReceived: 90944
  IncomingPacketsDiscarded: 0
  OutgoingPacketsDiscarded: 0
  IncomingPacketsWithErrors: 0
  OutgoingPacketsWithErrors: 0
  IncomingUnknownProtocolPackets: 0

Why NetworkHelper Matters

Without a centralized utility, most applications end up with:

  • Duplicated network detection code
  • Inconsistent behavior across projects
  • Hard-to-maintain platform logic
  • Subtle bugs in interface filtering and state detection

NetworkHelper eliminates all of that by giving you:

  • A single authoritative API
  • Strong typing and predictable return values
  • Read-only collections for safety
  • Clean abstraction over complex .NET networking APIs
  • Production-ready behavior you can trust

Summary

NetworkHelper is a perfect example of what Spargine was built for: turning complex, repetitive, and error-prone infrastructure code into simple, fast, and reusable building blocks. With just a few method calls, you can detect network connectivity, identify interface types, inspect bandwidth, retrieve IP addressing information, and gather detailed network statistics.

Instead of reinventing this logic in every project, NetworkHelper lets you standardize how your applications understand and interact with the network. The result is cleaner code, fewer bugs, easier diagnostics, and more resilient applications.

If your .NET application cares about connectivity, performance, telemetry, or reliability—and most modern apps do—NetworkHelper should already be in your toolbox.

Get Involved!

The success of open-source projects like Spargine relies on community contributions. If you find these updates useful or have ideas for further improvements, I encourage you to contribute by:

  • Submitting pull requests
  • Reporting issues
  • Suggesting new features

Your input is invaluable in making Spargine an even more powerful tool for the .NET community.

If you are interested in contributing or have any questions, feel free to contact me via email at dotnetdave@live.com. Your support and collaboration are greatly appreciated!

Thank you, and happy coding!

Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

$5.00
$15.00
$100.00
$5.00
$15.00
$100.00
$5.00
$15.00
$100.00

Or enter a custom amount

$

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

If you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave

© The information in this article is copywritten and cannot be preproduced in any way without express permission from David McCarter.


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.